Skip to content

jump3rhood/ecomm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ E-Commerce Microservices Platform

A production-ready, scalable e-commerce platform built with Spring Boot microservices architecture, featuring user authentication (JWT + OAuth2), product catalog management with Redis caching, Stripe payment integration, and asynchronous email notifications via Kafka.

Spring Boot Java Docker License


πŸ“‹ Table of Contents


πŸ— System Architecture

High-Level Architecture Overview

%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#6366f1','primaryTextColor':'#fff','primaryBorderColor':'#4f46e5','lineColor':'#6366f1','secondaryColor':'#22c55e','tertiaryColor':'#f59e0b','background':'#ffffff','mainBkg':'#f3f4f6','secondBkg':'#e5e7eb','tertiaryBkg':'#d1d5db','textColor':'#1f2937','fontSize':'16px','fontFamily':'Inter, system-ui, sans-serif'}}}%%
graph TB
    Client([πŸ‘€ Client/Browser]):::clientStyle
    
    subgraph EntryLayer["🌐 Entry Layer"]
        Gateway[API Gateway<br/>πŸ“ Port: 3001<br/>πŸ” JWT Validation]:::gatewayStyle
        Discovery[Service Discovery<br/>πŸ“ Port: 8761<br/>πŸ“‘ Eureka Server]:::discoveryStyle
    end
    
    subgraph BusinessLayer["βš™οΈ Business Services Layer"]
        UserService[User Service<br/>πŸ“ Port: 8080<br/>πŸ” Auth & JWT]:::serviceStyle
        ProductService[Product Service<br/>πŸ“ Port: 8081<br/>πŸ›οΈ Catalog]:::serviceStyle
        PaymentService[Payment Service<br/>πŸ“ Port: 8082<br/>πŸ’³ Payments]:::serviceStyle
        EmailService[Email Service<br/>πŸ“ Port: 8181<br/>πŸ“§ Notifications]:::serviceStyle
    end
    
    subgraph DataLayer["πŸ’Ύ Data Layer"]
        PostgreSQL[(PostgreSQL<br/>Users DB)]:::dbStyle
        MySQL[(MySQL<br/>Products DB)]:::dbStyle
        Redis[(Redis<br/>Cache)]:::cacheStyle
    end
    
    subgraph MessageLayer["πŸ“¨ Message Queue"]
        Kafka[Kafka Broker<br/>πŸ“ Port: 9092]:::messageStyle
        Zookeeper[Zookeeper<br/>πŸ“ Port: 2181]:::messageStyle
    end
    
    subgraph ExternalLayer["🌍 External Services"]
        Google[Google OAuth2<br/>πŸ”‘ Authentication]:::externalStyle
        Stripe[Stripe API<br/>πŸ’° Payments]:::externalStyle
        Gmail[Gmail SMTP<br/>βœ‰οΈ Email Delivery]:::externalStyle
    end
    
    Client ==>|All API Requests| Gateway
    Gateway -.->|Service Lookup| Discovery
    
    Gateway ==>|/api/auth/**<br/>/api/user/**| UserService
    Gateway ==>|/api/products/**<br/>/api/categories/**| ProductService
    Gateway ==>|/api/payments/**| PaymentService
    
    UserService ==>|Store/Retrieve Users| PostgreSQL
    ProductService ==>|CRUD Operations| MySQL
    ProductService <-->|Cache Queries| Redis
    
    UserService -->|Publish Events| Kafka
    Kafka -->|Consume Events| EmailService
    Kafka -.->|Coordination| Zookeeper
    
    UserService -.->|OAuth2 Login| Google
    PaymentService -.->|Process Payments| Stripe
    EmailService -.->|Send Emails| Gmail
    
    UserService -.->|Register Service| Discovery
    ProductService -.->|Register Service| Discovery
    PaymentService -.->|Register Service| Discovery
    EmailService -.->|Register Service| Discovery
    
    classDef clientStyle fill:#6366f1,stroke:#4f46e5,stroke-width:3px,color:#fff
    classDef gatewayStyle fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
    classDef discoveryStyle fill:#22c55e,stroke:#16a34a,stroke-width:2px,color:#fff
    classDef serviceStyle fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#fff
    classDef dbStyle fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff
    classDef cacheStyle fill:#ec4899,stroke:#db2777,stroke-width:2px,color:#fff
    classDef messageStyle fill:#14b8a6,stroke:#0d9488,stroke-width:2px,color:#fff
    classDef externalStyle fill:#64748b,stroke:#475569,stroke-width:2px,color:#fff
Loading

Architecture Components

Component Port Technology Purpose
API Gateway 3001 Spring Cloud Gateway Single entry point, routing, JWT validation
Service Discovery 8761 Netflix Eureka Service registration & discovery
User Service 8080 Spring Boot, PostgreSQL Authentication, authorization, user management
Product Service 8081 Spring Boot, MySQL, Redis Product catalog, caching
Payment Service 8082 Spring Boot, Stripe API Payment processing
Email Service 8181 Spring Boot, Kafka Async email notifications
PostgreSQL 5432 PostgreSQL 15 User data persistence
MySQL 3306 MySQL 8.0 Product data persistence
Redis 6379 Redis Caching layer
Kafka 9092 Apache Kafka Message broker
Zookeeper 2181 Apache Zookeeper Kafka coordination

✨ Features

πŸ” Authentication & Authorization

  • JWT Authentication with RSA-256 signing
  • OAuth2 Integration with Google Sign-In
  • Multi-Authentication Support (Local + OAuth2)
  • Role-Based Access Control (ADMIN, USER)
  • Password Security with BCrypt hashing
  • Token Expiration (1 hour by default)

πŸ›οΈ Product Management

  • Full CRUD Operations for products and categories
  • Redis Caching with 1-hour TTL for performance
  • Soft Delete pattern for data retention
  • Pagination & Sorting for efficient data retrieval
  • Category Management with automatic creation
  • Input Validation with custom constraints
  • Flyway Migrations for database versioning

πŸ’³ Payment Processing

  • Stripe Integration for secure payments
  • Payment Link Generation with custom callbacks
  • Multi-Gateway Support (Stripe active, Razorpay ready)
  • Success/Failure Callbacks for order confirmation
  • Extensible Gateway Interface for future integrations

πŸ“§ Email Notifications

  • Kafka-Based Async Processing for scalability
  • Gmail SMTP Integration with TLS
  • Welcome Emails on user registration
  • Customizable Templates for different events
  • Retry Mechanism via Kafka consumer groups

🌐 API Gateway Features

  • Centralized Routing to all microservices
  • JWT Token Validation before forwarding requests
  • Public Endpoint Exemptions for auth and product browsing
  • Load Balancing via Eureka integration
  • Request/Response Logging capabilities

πŸ” Service Discovery

  • Automatic Service Registration on startup
  • Health Monitoring of all services
  • Client-Side Load Balancing for resilience
  • Eureka Dashboard for service visualization
  • Dynamic Service Location without hard-coded URLs

πŸ›  Technology Stack

Backend

  • Java 17 - Programming language
  • Spring Boot 3.5.x - Application framework
  • Spring Cloud - Microservices infrastructure
    • Spring Cloud Gateway - API Gateway
    • Netflix Eureka - Service Discovery
  • Spring Security - Authentication & Authorization
  • Spring Data JPA - Data persistence
  • Hibernate - ORM framework

Databases

  • PostgreSQL 15 - User service database
  • MySQL 8.0 - Product service database
  • Redis - Caching layer

Message Queue

  • Apache Kafka 7.4.0 - Event streaming
  • Apache Zookeeper 7.4.0 - Kafka coordination

Security

  • JWT (JSON Web Tokens) - Stateless authentication
  • OAuth2 - Third-party authentication
  • BCrypt - Password hashing
  • RSA-256 - JWT signing algorithm

External APIs

  • Stripe API - Payment processing
  • Google OAuth2 API - Social login
  • Gmail SMTP - Email delivery

DevOps

  • Docker - Containerization
  • Docker Compose - Multi-container orchestration
  • Maven - Dependency management & build tool
  • Flyway - Database migration tool

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Docker (20.10+) and Docker Compose (2.0+)
  • Java 17 (for local development without Docker)
  • Maven 3.9+ (for local development)
  • Git (for cloning the repository)

Required Accounts & API Keys

You'll need to create accounts and obtain API keys from:

  1. Google Cloud Console - For OAuth2 credentials
  2. Stripe - For payment processing API key
  3. Gmail - For SMTP email sending (App Password required)

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/ecommerce-microservices.git
cd ecommerce-microservices

2. Create Environment Configuration

Create a .env file in the project root:

# Copy the example file
cp .env.example .env

Edit .env and add your credentials:

# Google OAuth2 Credentials
GOOGLE_CLIENT_ID=your-google-client-id-here
GOOGLE_CLIENT_SECRET=your-google-client-secret-here

# Stripe API Key
STRIPE_KEY=sk_test_your-stripe-test-key-here

# Gmail SMTP Credentials
SENDER_EMAIL=your-email@gmail.com
SENDER_PASSWORD=your-gmail-app-password-here

3. Generate JWT Keystore (Optional - included in repo)

If you need to regenerate the keystore:

keytool -genkeypair -alias auth-server -keyalg RSA -keysize 2048 \
  -keystore user-service/src/main/resources/keystore.jks \
  -storepass password -validity 3650 \
  -dname "CN=Auth Server, OU=Development, O=ECommerce, L=City, ST=State, C=US"

# Copy to API Gateway
cp user-service/src/main/resources/keystore.jks api-gateway/src/main/resources/

4. Start All Services with Docker Compose

# Build and start all services
docker-compose up --build

# Or run in detached mode
docker-compose up -d --build

# View logs
docker-compose logs -f

# View logs for specific service
docker-compose logs -f user-service

5. Verify Services are Running

Wait for all services to start (approximately 2-3 minutes). You can check:

6. Test the Application

# Health check
curl http://localhost:3001/api/test/check

# Get all products
curl http://localhost:3001/api/products/

# Get all categories
curl http://localhost:3001/api/categories/

πŸ”§ Detailed Setup

Setting Up Google OAuth2

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Navigate to APIs & Services > Credentials
  4. Click Create Credentials > OAuth 2.0 Client ID
  5. Configure consent screen if prompted
  6. Select Web application as application type
  7. Add authorized redirect URIs:
    http://localhost:8080/login/oauth2/code/google
    http://localhost:3001/login/oauth2/code/google
    
  8. Copy Client ID and Client Secret to your .env file

Setting Up Stripe

  1. Go to Stripe Dashboard
  2. Create an account or sign in
  3. Navigate to Developers > API Keys
  4. Copy your Test Mode secret key (starts with sk_test_)
  5. Add to .env file as STRIPE_KEY

Important: Never use production keys in development!

Setting Up Gmail SMTP

  1. Enable 2-Factor Authentication on your Gmail account
  2. Go to Google Account Settings
  3. Navigate to Security > 2-Step Verification
  4. Scroll down to App passwords
  5. Generate a new app password for "Mail"
  6. Copy the 16-character password (remove spaces)
  7. Add to .env file as SENDER_PASSWORD

Security Note: Use app-specific passwords, never your actual Gmail password!

Database Configuration Files

Each service needs an application.properties file. Examples are provided:

# User Service
cp user-service/application.properties.example user-service/src/main/resources/application.properties

# Product Service  
cp product-service/src/main/resources/templates/application-template.properties \
   product-service/src/main/resources/application.properties

# Email Service
cp email-service/application.properties.example \
   email-service/src/main/resources/application.properties

πŸ“‘ API Endpoints

User Service (Authentication & User Management)

Public Endpoints (No Authentication Required)

Method Endpoint Description Request Body
POST /api/auth/register Register new user {email, password, firstName, lastName, roles}
POST /api/auth/login Login with credentials {email, password}
GET /api/auth/oauth2/success OAuth2 success callback Query: token
GET /api/auth/oauth2/error OAuth2 error callback Query: message

Protected Endpoints (JWT Required)

Method Endpoint Required Role Description
GET /api/user/profile USER Get current user profile
GET /api/user/list ADMIN List all users
GET /api/user/debug-roles Any Debug role information

Product Service

Product Endpoints (All Public)

Method Endpoint Description Request Body/Params
GET /api/products/ Get all products -
GET /api/products/{id} Get product by ID -
POST /api/products/ Create product {title, description, price, image, categoryTitle}
PUT /api/products/{id} Update product {title, description, price, image, categoryTitle}
DELETE /api/products/{id} Soft delete product -
GET /api/products/list Paginated products Query: pageNumber, pageSize, sortBy, ascending
GET /api/products/category/{title} Products by category -

Category Endpoints (All Public)

Method Endpoint Description Request Body
GET /api/categories/ Get all categories -
GET /api/categories/{id} Get category by ID -
POST /api/categories/ Create category {title}
PUT /api/categories/{id} Update category {title}
DELETE /api/categories/{id} Soft delete category -

Payment Service

Method Endpoint Auth Description
POST /api/payments/initiatePayment/{orderId} JWT Initiate Stripe payment
GET /api/payments/success Public Payment success callback

πŸ§ͺ Testing the Application

1. Register a New User

curl -X POST http://localhost:3001/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john.doe@example.com",
    "password": "SecurePassword123!",
    "firstName": "John",
    "lastName": "Doe",
    "roles": ["USER"]
  }'

Expected Response:

{
  "email": "john.doe@example.com",
  "firstName": "John",
  "lastName": "Doe",
  "roles": ["USER"]
}

You should also receive a welcome email!

2. Login and Get JWT Token

curl -X POST http://localhost:3001/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john.doe@example.com",
    "password": "SecurePassword123!"
  }'

Expected Response:

{
  "access_token": "eyJhbGciOiJSUzI1NiJ9...",
  "expires_in": 3600
}

Save the access_token for subsequent requests!

3. Create a Product

curl -X POST http://localhost:3001/api/products/ \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Awesome Laptop",
    "description": "High-performance laptop for developers",
    "price": 1299.99,
    "image": "https://example.com/laptop.jpg",
    "categoryTitle": "electronics"
  }'

4. Get All Products (with Caching)

# First call - hits database
curl http://localhost:3001/api/products/

# Second call - served from Redis cache
curl http://localhost:3001/api/products/

5. Get User Profile (Protected Endpoint)

curl http://localhost:3001/api/user/profile \
  -H "Authorization: Bearer YOUR_JWT_TOKEN_HERE"

Expected Response:

{
  "userId": 1,
  "email": "john.doe@example.com",
  "firstName": "John",
  "lastName": "Doe",
  "roles": ["ROLE_USER"]
}

6. Initiate Payment

curl -X POST http://localhost:3001/api/payments/initiatePayment/123 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN_HERE"

Expected Response:

https://checkout.stripe.com/c/pay/cs_test_...

Open this URL in your browser to complete test payment.

7. Get Paginated Products

curl "http://localhost:3001/api/products/list?pageNumber=0&pageSize=5&sortBy=price&ascending=false"

8. OAuth2 Login with Google

  1. Open browser: http://localhost:3001/oauth2/authorization/google
  2. Login with Google account
  3. Authorize the application
  4. You'll be redirected to success page with JWT token

9. Admin-Only Endpoint

First, create an admin user:

curl -X POST http://localhost:3001/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@example.com",
    "password": "AdminPassword123!",
    "firstName": "Admin",
    "lastName": "User",
    "roles": ["USER", "ADMIN"]
  }'

Login as admin and get all users:

curl http://localhost:3001/api/user/list \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN_HERE"

βš™οΈ Configuration

Environment Variables

All services use environment variables for configuration:

Variable Service Description Example
DATABASE_URL User Service PostgreSQL connection string jdbc:postgresql://localhost:5432/authserver
DATABASE_USERNAME User Service PostgreSQL username postgres
DATABASE_PASSWORD User Service PostgreSQL password root
GOOGLE_CLIENT_ID User Service Google OAuth2 client ID 123456.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET User Service Google OAuth2 client secret GOCSPX-xxx
KEYSTORE_PASSWORD User Service, Gateway Keystore password password
DB_HOST Product Service MySQL host localhost
DB_PORT Product Service MySQL port 3306
DB_USER Product Service MySQL username root
DB_PASSWORD Product Service MySQL password password
REDIS_HOST Product Service Redis host localhost
STRIPE_KEY Payment Service Stripe API key sk_test_xxx
SENDER_EMAIL Email Service Gmail address sender@gmail.com
SENDER_PASSWORD Email Service Gmail app password abcd efgh ijkl mnop
KAFKA_BOOTSTRAP_SERVERS Email Service Kafka brokers localhost:9092

Service Ports

Default ports (can be changed in application.properties):

# Infrastructure
Service Discovery: 8761
API Gateway: 3001
PostgreSQL: 5432
MySQL: 3306 (mapped to 3307 in Docker)
Redis: 6379
Kafka: 9092
Zookeeper: 2181

# Application Services
User Service: 8080
Product Service: 8081
Payment Service: 8082
Email Service: 8181

Database Configuration

PostgreSQL (User Service):

spring.datasource.url=jdbc:postgresql://localhost:5432/authserver
spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=validate

MySQL (Product Service):

spring.datasource.url=jdbc:mysql://localhost:3306/productservice
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update

Redis Cache Configuration

spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.cache.type=redis

Cache Keys:

  • Products: PRODUCTSSERVICE:product-list:all-products
  • Individual Product: PRODUCTS:PRODUCT_{id}
  • Categories: PRODUCTSSERVICE:category-list:all-categories
  • Individual Category: CATEGORIES:CATEGORY_{id}

TTL: 1 hour (3600 seconds)

Kafka Configuration

spring.kafka.bootstrap-servers=localhost:9092
spring.kafka.consumer.group-id=emailService

Topics:

  • send-email - Email notification events

πŸ› Troubleshooting

Common Issues and Solutions

1. Services Not Starting

Problem: Docker containers fail to start

Solutions:

# Check Docker is running
docker --version
docker-compose --version

# Clean up and rebuild
docker-compose down -v
docker-compose up --build

# Check logs for specific service
docker-compose logs user-service

2. Database Connection Errors

Problem: Could not connect to database

Solutions:

# Verify database is healthy
docker-compose ps

# Check database logs
docker-compose logs postgres-user
docker-compose logs mysql

# Restart database services
docker-compose restart postgres-user mysql

3. JWT Token Invalid

Problem: 401 Unauthorized or Invalid token

Solutions:

  • Ensure keystore.jks exists in both user-service and api-gateway
  • Verify keystore password matches in .env file
  • Check token hasn't expired (1 hour validity)
  • Ensure token is sent with Bearer prefix
# Regenerate keystore if needed
keytool -genkeypair -alias auth-server -keyalg RSA -keysize 2048 \
  -keystore keystore.jks -storepass password -validity 3650

4. OAuth2 Google Login Fails

Problem: Redirect URI mismatch

Solutions:

  • Verify redirect URIs in Google Cloud Console match exactly:
    http://localhost:8080/login/oauth2/code/google
    
  • Check GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in .env
  • Ensure user-service is running on port 8080

5. Email Not Sending

Problem: Welcome email not received

Solutions:

  • Verify Gmail App Password is correct (16 characters, no spaces)
  • Check Kafka is running: docker-compose logs kafka
  • Verify email-service logs: docker-compose logs email-service
  • Ensure SENDER_EMAIL and SENDER_PASSWORD in .env

6. Stripe Payment Fails

Problem: Payment link not generated

Solutions:

  • Verify Stripe API key starts with sk_test_
  • Check Stripe dashboard for API errors
  • Ensure payment-service is running: docker-compose logs payment-service

7. Redis Cache Not Working

Problem: Products always fetched from database

Solutions:

# Check Redis is running
docker-compose ps redis

# Connect to Redis CLI
docker exec -it my-product-service-redis redis-cli

# Check cached keys
KEYS *

# Clear cache if needed
FLUSHALL

8. Service Discovery Issues

Problem: Services not registering with Eureka

Solutions:

  • Access Eureka dashboard: http://localhost:8761
  • Verify eureka.client.serviceUrl.defaultZone in service configs
  • Check service-discovery logs: docker-compose logs service-discovery
  • Wait 30-60 seconds for services to register

9. Port Conflicts

Problem: Port already in use

Solutions:

# Find process using port (e.g., 8080)
lsof -i :8080  # macOS/Linux
netstat -ano | findstr :8080  # Windows

# Kill process or change port in application.properties

10. Maven Build Fails

Problem: Compilation errors or dependency issues

Solutions:

# Clean Maven cache
mvn clean install -U

# Skip tests during build
mvn clean install -DskipTests

# Delete and recreate .m2 repository
rm -rf ~/.m2/repository
mvn clean install

Viewing Logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f user-service

# Last 100 lines
docker-compose logs --tail=100 product-service

# Since specific time
docker-compose logs --since 2024-01-01T10:00:00

---

## πŸ“ Project Structure

ecommerce-microservices/ β”‚ β”œβ”€β”€ api-gateway/ # API Gateway Service β”‚ β”œβ”€β”€ src/main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── com/john/personal/api_gateway/ β”‚ β”‚ β”‚ β”œβ”€β”€ configuration/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ FilterConfig.java β”‚ β”‚ β”‚ β”‚ └── GatewayConfig.java β”‚ β”‚ β”‚ └── security/ β”‚ β”‚ β”‚ └── AuthenticationPreFilter.java β”‚ β”‚ └── resources/ β”‚ β”‚ β”œβ”€β”€ application.properties β”‚ β”‚ └── keystore.jks β”‚ β”œβ”€β”€ Dockerfile β”‚ └── pom.xml β”‚ β”œβ”€β”€ service-discovery/ # Eureka Server β”‚ β”œβ”€β”€ src/main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── org/john/personal/service_discovery/ β”‚ β”‚ β”‚ └── ServiceDiscoveryApplication.java β”‚ β”‚ └── resources/ β”‚ β”‚ └── application.properties β”‚ β”œβ”€β”€ Dockerfile β”‚ └── pom.xml β”‚ β”œβ”€β”€ user-service/ # User & Auth Service β”‚ β”œβ”€β”€ src/main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── org/john/personal/userservice/ β”‚ β”‚ β”‚ β”œβ”€β”€ config/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ JwtUserPrincipal.java β”‚ β”‚ β”‚ β”‚ └── SecurityConfig.java β”‚ β”‚ β”‚ β”œβ”€β”€ controllers/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ AuthController.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ UserController.java β”‚ β”‚ β”‚ β”‚ └── OAuth2Controller.java β”‚ β”‚ β”‚ β”œβ”€β”€ dtos/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ request/ β”‚ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ LoginRequestDto.java β”‚ β”‚ β”‚ β”‚ β”‚ └── RegisterRequestDto.java β”‚ β”‚ β”‚ β”‚ └── response/ β”‚ β”‚ β”‚ β”‚ └── UserResponseDTO.java β”‚ β”‚ β”‚ β”œβ”€β”€ models/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ UserEntity.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ Role.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ AuthProvider.java β”‚ β”‚ β”‚ β”‚ └── UserAuthMethodEntity.java β”‚ β”‚ β”‚ β”œβ”€β”€ repositories/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ UserRepository.java β”‚ β”‚ β”‚ β”‚ └── UserAuthMethodRepository.java β”‚ β”‚ β”‚ β”œβ”€β”€ security/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ JwtAuthenticationFilter.java β”‚ β”‚ β”‚ β”‚ └── OAuth2AuthenticationSuccessHandler.java β”‚ β”‚ β”‚ └── services/ β”‚ β”‚ β”‚ β”œβ”€β”€ UserServiceImpl.java β”‚ β”‚ β”‚ β”œβ”€β”€ CustomUserDetailsService.java β”‚ β”‚ β”‚ └── JwtService.java β”‚ β”‚ └── resources/ β”‚ β”‚ β”œβ”€β”€ application.properties β”‚ β”‚ β”œβ”€β”€ keystore.jks β”‚ β”‚ └── db/migration/ β”‚ β”‚ β”œβ”€β”€ V1__initial_schema.sql β”‚ β”‚ β”œβ”€β”€ V2__add_user_roles_table.sql β”‚ β”‚ β”œβ”€β”€ V3__change_username_to_email.sql β”‚ β”‚ β”œβ”€β”€ V4__add_oauth2_fields.sql β”‚ β”‚ β”œβ”€β”€ V5__.sql β”‚ β”‚ └── V6__password_set_null.sql β”‚ β”œβ”€β”€ Dockerfile β”‚ └── pom.xml β”‚ β”œβ”€β”€ product-service/ # Product Catalog Service β”‚ β”œβ”€β”€ src/main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── org/john/personal/productservice/ β”‚ β”‚ β”‚ β”œβ”€β”€ configurations/ β”‚ β”‚ β”‚ β”‚ └── ApplicationConfig.java β”‚ β”‚ β”‚ β”œβ”€β”€ controller/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductController.java β”‚ β”‚ β”‚ β”‚ └── CategoryController.java β”‚ β”‚ β”‚ β”œβ”€β”€ dto/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductRequestDTO.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductResponseDTO.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ CategoryRequestDTO.java β”‚ β”‚ β”‚ β”‚ └── CategoryResponseDTO.java β”‚ β”‚ β”‚ β”œβ”€β”€ model/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ BaseModel.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ Product.java β”‚ β”‚ β”‚ β”‚ └── Category.java β”‚ β”‚ β”‚ β”œβ”€β”€ repository/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductRepo.java β”‚ β”‚ β”‚ β”‚ └── CategoryRepo.java β”‚ β”‚ β”‚ β”œβ”€β”€ service/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductService.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductServiceImpl.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ CategoryService.java β”‚ β”‚ β”‚ β”‚ └── CategoryServiceImpl.java β”‚ β”‚ β”‚ └── mapper/ β”‚ β”‚ β”‚ β”œβ”€β”€ ProductMapper.java β”‚ β”‚ β”‚ └── CategoryMapper.java β”‚ β”‚ └── resources/ β”‚ β”‚ β”œβ”€β”€ application.properties β”‚ β”‚ └── db/migration/ β”‚ β”‚ └── V1__init.sql β”‚ β”œβ”€β”€ Dockerfile β”‚ └── pom.xml β”‚ β”œβ”€β”€ payment-service/ # Payment Processing Service β”‚ β”œβ”€β”€ src/main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── org/john/personal/paymentservice/ β”‚ β”‚ β”‚ β”œβ”€β”€ controllers/ β”‚ β”‚ β”‚ β”‚ └── PaymentController.java β”‚ β”‚ β”‚ β”œβ”€β”€ paymentgateways/ β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ PaymentGateway.java β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ StripePaymentGateway.java β”‚ β”‚ β”‚ β”‚ └── RazorpayPaymentGateway.java β”‚ β”‚ β”‚ └── services/ β”‚ β”‚ β”‚ └── PaymentService.java β”‚ β”‚ └── resources/ β”‚ β”‚ └── application.properties β”‚ β”œβ”€β”€ Dockerfile β”‚ └── pom.xml β”‚ β”œβ”€β”€ email-service/ # Email Notification Service β”‚ β”œβ”€β”€ src/main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── org/john/personal/email_service/ β”‚ β”‚ β”‚ β”œβ”€β”€ consumers/ β”‚ β”‚ β”‚ β”‚ └── SendEmailEventConsumer.java β”‚ β”‚ β”‚ β”œβ”€β”€ dto/ β”‚ β”‚ β”‚ β”‚ └── SendEmailDto.java β”‚ β”‚ β”‚ └── utils/ β”‚ β”‚ β”‚ └── EmailUtil.java β”‚ β”‚ └── resources/ β”‚ β”‚ └── application.properties β”‚ β”œβ”€β”€ Dockerfile β”‚ └── pom.xml β”‚ β”œβ”€β”€ docker-compose.yml # Docker Compose Configuration β”œβ”€β”€ .env.example # Environment Variables Template β”œβ”€β”€ .gitignore # Git Ignore Rules └── README.md # This File


🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository

  2. Create a feature branch:

    git checkout -b feature/amazing-feature
  3. Commit your changes:

    git commit -m 'Add amazing feature'
  4. Push to the branch:

    git push origin feature/amazing-feature
  5. Open a Pull Request

Coding Standards

  • Follow Java coding conventions
  • Write unit tests for new features
  • Update documentation
  • Add Javadoc comments
  • Keep code DRY (Don't Repeat Yourself)

Commit Messages

Use conventional commits:

feat: add user profile picture upload
fix: resolve JWT token expiration issue
docs: update API endpoint documentation
refactor: improve product service caching logic
test: add integration tests for payment service

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Spring Boot Team for amazing framework
  • Netflix OSS for Eureka
  • Stripe for payment processing
  • All open-source contributors

πŸ“š Additional Resources

Official Documentation

Tutorials & Guides


Made with ❀️ by John Manohar

⭐ Star this repository if you find it helpful!

About

Ecommerce microservices project in springboot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published