A full-stack e-commerce platform built using a microservices architecture with Spring Boot backend and Next.js frontend. The platform provides a complete online shopping experience including product browsing, shopping cart, order management, and secure payment processing via Stripe.
- Features
- Architecture
- Technology Stack
- Microservices
- Getting Started
- API Documentation
- Project Structure
- Security
- Payment Flow
- Testing
- Deployment
- Contributing
- License
- π User Authentication - Secure registration and login with JWT
- π¦ Product Catalog - Browse products with search and category filters
- π Shopping Cart - Add, update, and remove items
- π Order Management - Track order history and status
- π³ Secure Payments - Stripe integration for card payments
- π€ User Profile - Manage account and change password
- π Dashboard - Overview of orders and products
- π¦ Product Management - Full CRUD with image upload
- π Order Management - View and update order statuses
- π₯ User Management - View registered users
- ποΈ Microservices Architecture - Scalable and maintainable
- π Service Discovery - Netflix Eureka for dynamic service registration
- πͺ API Gateway - Centralized routing and security
- π³ Containerized - Docker and Docker Compose ready
- π API Documentation - Swagger/OpenAPI integration
π View Interactive Diagram (Mermaid)
flowchart TB
subgraph Client["π Client Layer"]
Browser["Browser"]
Mobile["Mobile App"]
end
subgraph Frontend["π± Frontend (Next.js 13.5)"]
NextApp["Next.js Application"]
Components["React Components"]
Services["API Services"]
end
subgraph Gateway["πͺ API Gateway Layer"]
APIGateway["API Gateway<br/>(Spring Cloud Gateway)"]
SecurityFilter["JWT Security Filter"]
end
subgraph Discovery["π Service Discovery"]
Eureka["Netflix Eureka<br/>Service Registry"]
end
subgraph Microservices["βοΈ Microservices Layer"]
AuthService["Auth Service<br/>(JWT Token Management)"]
UserService["User Service<br/>(User Management)"]
ProductService["Product Service<br/>(Product Catalog)"]
PaymentService["Payment Service<br/>(Orders, Cart, Payments)"]
end
subgraph Databases["ποΈ Data Layer"]
MongoDB[(MongoDB<br/>Products, Users, Cart, Orders)]
PostgreSQL[(PostgreSQL<br/>Payment Transactions)]
end
subgraph External["βοΈ External Services"]
Stripe["Stripe API<br/>(Payment Processing)"]
end
Browser --> NextApp
Mobile --> NextApp
NextApp --> APIGateway
APIGateway --> SecurityFilter
SecurityFilter --> AuthService
APIGateway --> UserService
APIGateway --> ProductService
APIGateway --> PaymentService
AuthService -.->|Register| Eureka
UserService -.->|Register| Eureka
ProductService -.->|Register| Eureka
PaymentService -.->|Register| Eureka
UserService --> MongoDB
ProductService --> MongoDB
PaymentService --> MongoDB
PaymentService --> PostgreSQL
PaymentService --> Stripe
APIGateway -.->|Discover| Eureka
π View Interactive Diagram (Mermaid)
flowchart LR
subgraph MS["Microservices"]
direction TB
SD["π Service Discovery<br/>Port: 8761"]
GW["πͺ API Gateway<br/>Port: 9000"]
AS["π Auth Service<br/>Port: 8084"]
US["π€ User Service<br/>Port: 8083"]
PS["π¦ Product Service<br/>Port: 8080"]
PY["π³ Payment Service<br/>Port: 8085"]
end
GW --> SD
AS --> SD
US --> SD
PS --> SD
PY --> SD
| Technology | Version | Purpose |
|---|---|---|
| Java | 17 | Programming Language |
| Spring Boot | 3.3.4 | Core Framework |
| Spring Cloud | 2023.0.3 | Microservices Infrastructure |
| Spring Cloud Gateway | 2023.0.3 | API Gateway |
| Netflix Eureka | 2023.0.3 | Service Discovery |
| Spring Security | 3.3.4 | Authentication & Authorization |
| Spring Data MongoDB | 3.3.4 | MongoDB Integration |
| Spring Data JPA | 3.3.4 | PostgreSQL Integration |
| Flyway | Latest | Database Migrations |
| Stripe Java SDK | 22.4.0 | Payment Processing |
| SpringDoc OpenAPI | 2.6.0 | API Documentation |
| Lombok | Latest | Boilerplate Reduction |
| Maven | 3.x | Build Tool |
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 13.5.1 | React Framework |
| React | 18.2.0 | UI Library |
| TypeScript | 5.2.2 | Type-Safe JavaScript |
| Tailwind CSS | 3.3.3 | Styling |
| Radix UI | Various | Accessible Components |
| React Hook Form | 7.53.0 | Form Management |
| Zod | 3.23.8 | Schema Validation |
| Axios | 1.7.8 | HTTP Client |
| Stripe React | 2.8.1 | Payment UI |
| Recharts | 2.12.7 | Data Visualization |
| Lucide React | 0.446.0 | Icons |
| Technology | Purpose |
|---|---|
| Docker | Containerization |
| Docker Compose | Container Orchestration |
| GitHub Actions | CI/CD Pipeline |
| MongoDB | NoSQL Database |
| PostgreSQL | Relational Database |
Port: 8761
Central service registry that enables dynamic service discovery and load balancing.
Port: 9000
Single entry point for all client requests with JWT validation, routing, and CORS handling.
Port: 8084
| Endpoint | Method | Description |
|---|---|---|
/api/auth/token |
POST | Generate JWT token |
/api/auth/validate |
POST | Validate JWT token |
Port: 8083
| Endpoint | Method | Description |
|---|---|---|
/api/user/register |
POST | Register new user |
/api/user/login |
POST | User login |
/api/user/change-password |
POST | Change password |
/api/user/all |
GET | Get all users |
Port: 8080
| Endpoint | Method | Description |
|---|---|---|
/api/v1/products |
POST | Create product |
/api/v1/products |
GET | Get all products |
/api/v1/products/{id} |
GET | Get product by ID |
/api/v1/products/{id} |
PUT | Update product |
/api/v1/products/{id} |
DELETE | Delete product |
/api/v1/products/categories |
GET | Get categories |
/api/v1/products/search |
GET | Search products |
Port: 8085
| Endpoint | Method | Description |
|---|---|---|
/api/v1/cart/{userId} |
POST | Add to cart |
/api/v1/cart/{userId} |
GET | Get cart |
/api/v1/cart/{userId} |
DELETE | Clear cart |
/api/v1/cart/{userId}/{productId} |
DELETE | Remove item |
| Endpoint | Method | Description |
|---|---|---|
/api/v1/orders |
POST | Create order |
/api/v1/orders |
GET | Get all orders |
/api/v1/orders/{id} |
GET | Get order by ID |
/api/v1/orders/user/{userId} |
GET | Get user orders |
/api/v1/orders/{id}/status |
PUT | Update status |
/api/v1/orders/{id} |
DELETE | Cancel order |
| Endpoint | Method | Description |
|---|---|---|
/api/v1/payments/create |
POST | Create payment |
/api/v1/payments/{id} |
GET | Get payment |
/api/v1/payments/{id}/status |
PUT | Update status |
/api/v1/payments/{id}/confirm |
POST | Confirm payment |
/api/v1/payments/{id}/cancel |
POST | Cancel payment |
- Java 17 or higher
- Node.js 18 or higher
- Docker and Docker Compose
- Maven 3.x
- MongoDB (or use Docker)
- Stripe Account (for payments)
git clone https://github.com/yourusername/ead-project.git
cd ead-projectcd microservices-backend
docker-compose up -d mongodbStart services in this order:
# Terminal 1 - Service Discovery
cd service-discovery
./mvnw spring-boot:run
# Terminal 2 - Auth Service
cd auth-service
./mvnw spring-boot:run
# Terminal 3 - User Service
cd user-service
./mvnw spring-boot:run
# Terminal 4 - Product Service
cd product-service
./mvnw spring-boot:run
# Terminal 5 - Payment Service
cd payment-service
./mvnw spring-boot:run
# Terminal 6 - API Gateway
cd api-gateway
./mvnw spring-boot:runcd microservices-frontend
npm install
npm run dev- Frontend: http://localhost:3000
- API Gateway: http://localhost:9000
- Eureka Dashboard: http://localhost:8761
- Swagger UI: http://localhost:9000/swagger-ui.html
Create .env file in microservices-frontend:
NEXT_PUBLIC_API_URL=http://localhost:9000
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_keyConfigure Stripe in payment-service/src/main/resources/application.properties:
stripe.api.key=your_stripe_secret_keyAPI documentation is available via Swagger UI once the services are running:
- Product Service: http://localhost:8080/swagger-ui.html
- Payment Service: http://localhost:8085/swagger-ui.html
- User Service: http://localhost:8083/swagger-ui.html
- Auth Service: http://localhost:8084/swagger-ui.html
ead-project/
βββ microservices-backend/
β βββ api-gateway/ # Spring Cloud Gateway
β β βββ src/main/java/
β β βββ config/ # Security & routing config
β β
β βββ auth-service/ # Authentication Service
β β βββ src/main/java/
β β βββ controller/ # REST endpoints
β β βββ dto/ # Data transfer objects
β β βββ util/ # JWT utilities
β β
β βββ user-service/ # User Management
β β βββ src/main/java/
β β βββ controller/ # REST endpoints
β β βββ model/ # User entity
β β βββ repository/ # Data access
β β βββ service/ # Business logic
β β
β βββ product-service/ # Product Catalog
β β βββ src/main/java/
β β βββ controller/ # REST endpoints
β β βββ dto/ # Request/Response DTOs
β β βββ model/ # Product entity
β β βββ repository/ # MongoDB repository
β β βββ service/ # Business logic
β β
β βββ payment-service/ # Cart, Orders & Payments
β β βββ src/main/java/
β β βββ controller/ # Cart, Order, Payment APIs
β β βββ dto/ # Data transfer objects
β β βββ model/ # Cart, Order, Payment entities
β β βββ repository/ # Data repositories
β β βββ service/ # Business logic
β β
β βββ service-discovery/ # Netflix Eureka Server
β β
β βββ docker-compose.yml # Container orchestration
β βββ pom.xml # Parent POM
β
βββ microservices-frontend/
βββ app/ # Next.js App Router
β βββ admin/ # Admin pages
β βββ auth/ # Login/Register
β βββ cart/ # Shopping cart
β βββ orders/ # Order history
β βββ payment/ # Checkout
β βββ products/ # Product pages
β βββ profile/ # User profile
β
βββ components/ # React components
β βββ ui/ # Radix UI components
β βββ ProductGrid.tsx
β βββ Header.tsx
β βββ Footer.tsx
β
βββ services/ # API services
β βββ productService.ts
β βββ cartService.jsx
β βββ OrderService.ts
β
βββ hooks/ # Custom hooks
βββ context/ # React contexts
βββ lib/ # Utilities
π View Interactive Diagram (Mermaid)
sequenceDiagram
participant C as Client
participant GW as API Gateway
participant AS as Auth Service
participant US as User Service
participant PS as Protected Service
C->>US: 1. Login (username, password)
US->>AS: 2. Request JWT Token
AS-->>US: 3. Return JWT Token
US-->>C: 4. Return Token to Client
C->>GW: 5. Request with JWT Bearer Token
GW->>GW: 6. Validate JWT Locally
GW->>PS: 7. Forward Request (if valid)
PS-->>GW: 8. Response
GW-->>C: 9. Return Response
- β JWT Authentication - Stateless token-based auth
- β OAuth2 Resource Server - Standard authorization
- β BCrypt Password Hashing - Secure password storage
- β Role-Based Access Control - User/Admin roles
- β API Gateway Security - Centralized enforcement
π View Interactive Diagram (Mermaid)
sequenceDiagram
participant U as User
participant F as Frontend
participant C as Cart Service
participant O as Order Service
participant P as Payment Service
participant S as Stripe
U->>F: 1. Add items to cart
F->>C: 2. POST /cart/{userId}
C-->>F: 3. Cart updated
U->>F: 4. Proceed to checkout
F->>O: 5. POST /orders
O-->>F: 6. Order created
F->>P: 7. POST /payments/create
P->>S: 8. Create PaymentIntent
S-->>P: 9. Return client_secret
P-->>F: 10. Return client_secret
F->>S: 11. Confirm payment (Stripe.js)
S-->>F: 12. Payment result
F->>P: 13. POST /payments/{id}/confirm
P->>O: 14. Update order status
O-->>F: 15. Order confirmed
# Run all tests
cd microservices-backend
./mvnw test
# Run specific service tests
cd product-service
./mvnw test
cd payment-service
./mvnw test| Service | Unit Tests | Integration Tests | API Tests |
|---|---|---|---|
| Product Service | β | β | β |
| Payment Service | β | β | β |
| Cart Service | β | β | - |
| User Service | β | β | β |
| Auth Service | β | - | - |
- JUnit 5 - Unit testing
- Mockito - Mocking framework
- TestContainers - Integration testing with real databases
- REST Assured - API testing
cd microservices-backend
# Build all services
./mvnw clean package -DskipTests
# Start all containers
docker-compose up -dflowchart TB
subgraph Docker["Docker Compose"]
MongoDB[(MongoDB)]
SD["Service Discovery"]
GW["API Gateway"]
AS["Auth Service"]
US["User Service"]
PS["Product Service"]
PY["Payment Service"]
end
subgraph Volume["Persistent Storage"]
Data[("mongodb_data")]
end
MongoDB --> Data
SD --> MongoDB
GW --> SD
AS --> SD
US --> SD
PS --> SD
PY --> SD
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ using Microservices Architecture



