A complete, production-ready e-commerce platform featuring Spring Boot microservices, Angular frontend, Jenkins CI/CD, and SonarQube code quality integration.
- Architecture Overview
- Prerequisites
- Quick Start
- Running the Application
- Jenkins CI/CD Pipeline
- SonarQube Code Quality
- API Documentation
- Project Structure
- Development Workflow
- Troubleshooting
The Buy-01 platform is a three-tier distributed system:
The foundational microservices architecture with the following components:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Angular Frontend β
β (Port 4200, HTTPS Enabled) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ
β API Gateway (Spring Cloud Gateway) β
β Port 8443 (HTTPS), Routes & Auth β
ββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββββ
β β β β
ββββββββΌββββ ββββββΌβββββ βββββΌβββββ ββββΌβββββββ
β Discoveryβ βUser β βProduct β β Media β
β Service β βService β βService β β Service β
β(8761) β β(8081) β β(8082) β β(8083) β
ββββββββββββ βββββββββββ ββββββββββ βββββββββββ
β β
βββββββββΌββββββββββββββββββββββββββββ¬βββΌβββββββββ
β MongoDB (NoSQL Database) β Kafka β
β Port 27017, Replicas Ready β(Async Msg)β
βββββββββββββββββββββββββββββββββββββ΄ββββββββββββ
Additional Services:
- Zookeeper (Kafka coordination)
- SonarQube (Code Quality, Port 9000)
Automated continuous integration and deployment:
- Triggers: GitHub push events
- Stages: Checkout β Build β Test β SonarQube β Docker Push β Deploy β Notify
- Agents: Distributed build support
- Deployment: Local Docker or SSH-based
Continuous code quality monitoring:
- Static code analysis
- Security vulnerability detection
- Technical debt tracking
- GitHub integration via webhooks
- OS: macOS, Linux, or Windows (with WSL2)
- RAM: Minimum 8GB (16GB recommended)
- Disk: 20GB free space
- CPU: 4+ cores
# Core tools
- Docker Desktop (with Docker Compose) # https://docs.docker.com/desktop/
- Git # https://git-scm.com/
- Java 17+ (for local development) # https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
- Maven 3.9+ (for local builds) # https://maven.apache.org/
- Node.js 18+ & npm (for frontend) # https://nodejs.org/
# Optional (for local Jenkins/SonarQube development)
- Jenkins (for CI/CD testing) # https://www.jenkins.io/
- SonarQube Community Edition # https://www.sonarqube.org/# Verify installations
docker --version
docker-compose --version
git --version
java -version
mvn --version
npm --versiongit clone https://github.com/mahdikheirkhah/buy-01.git
cd buy-01# Create .env file for Docker Compose overrides
cat > .env << 'EOF'
IMAGE_TAG=latest
DOCKER_REPO=mahdikheirkhah
MONGO_INITDB_ROOT_USERNAME=admin
MONGO_INITDB_ROOT_PASSWORD=password
EOF# Option A: Using Makefile (Recommended - FIXED!)
make all
# This runs:
# 1. make build - Builds all Java services and Angular frontend using their individual Dockerfiles
# 2. make up - Starts all services with docker-compose
# Output should look like:
# --- Building Java Microservices ---
# Building api-gateway...
# Building user-service...
# Building product-service...
# Building media-service...
# Building discovery-service...
# Building dummy-data...
# --- Building Angular Frontend ---
# --- Starting Docker Compose Services ---Note: The Makefile was just fixed! It now correctly uses each service's individual Dockerfile (e.g., backend/api-gateway/Dockerfile) instead of looking for a non-existent Dockerfile.java.
# Check container status
docker ps
# Expected output:
# - discovery-service (8761)
# - api-gateway (8443)
# - user-service (8081)
# - product-service (8082)
# - media-service (8083)
# - frontend (4200)
# - kafka, zookeeper, mongo, sonarqubeLocal Access:
- Frontend: https://localhost:4200
- API Gateway: https://localhost:8443/actuator/health
- Eureka Discovery: http://localhost:8761
- SonarQube: http://localhost:9000 (admin/admin)
External Access with ngrok:
If you need to access your services from outside your network (e.g., testing on mobile, sharing with team):
# Start with ngrok tunnels
./setup.sh --ngrok
# Or start everything including Jenkins and ngrok
./setup.sh --jenkins --ngrokAfter starting with --ngrok:
- Check the ngrok dashboard: http://localhost:4040
- Frontend will be accessible via:
https://[random-name].ngrok-free.app - Jenkins (if enabled) will be accessible via:
https://[random-name].ngrok-free.app
Note: You need to install and authenticate ngrok first:
# Install ngrok
brew install ngrok/ngrok/ngrok # macOS
snap install ngrok # Linux
# Or download from: https://ngrok.com/download
# Authenticate (get token from https://dashboard.ngrok.com/)
ngrok config add-authtoken <your-token>Problem: make all was failing with error: failed to read dockerfile: open Dockerfile.java: no such file or directory
Root Cause: The original Makefile was looking for a non-existent generic Dockerfile.java in the root directory.
Solution Applied:
- β Updated Makefile to use each service's individual Dockerfile in its directory
- β
Updated
docker-compose.ymlto use defaultIMAGE_TAG:-latestvalues - β
Added
backend/discovery-serviceto the build list
Changes Made:
# BEFORE (broken):
docker build --file Dockerfile.java --tag backend/user-service ...
# AFTER (fixed):
docker build --file backend/user-service/Dockerfile --tag mahdikheirkhah/user-service:latest ...Result: make all now works correctly! β
Your project uses three Docker configurations:
Purpose: Generic multi-stage builder for Java microservices
Used by: Makefile to build API Gateway, User Service, Product Service, Media Service, Discovery Service
# Build a single service using this Dockerfile
docker build \
--file Dockerfile \
--tag backend/user-service \
--build-arg SERVICE_NAME=user-service \
.Purpose: Jenkins agent/slave image for running CI/CD pipelines
Used by: Jenkins container in docker-compose.jenkins.yml
# Build Jenkins agent image
docker build -f Dockerfile.jenkins -t jenkins-agent .Purpose: Orchestrates all microservices + infrastructure for LOCAL DEVELOPMENT
Starts: User Service, Product Service, Media Service, Discovery Service, API Gateway, Frontend, MongoDB, Kafka, Zookeeper, SonarQube
# Start all services
docker-compose up -d
# View all running containers
docker-compose ps
# View logs
docker-compose logs -f
# Stop all services
docker-compose downPurpose: Deploys the full application + Jenkins for CI/CD pipeline testing
Starts: All microservices (as pre-built images) + Jenkins
Used for: Production-like deployments or Jenkins testing environment
# Start with Jenkins integration
docker-compose -f docker-compose.jenkins.yml up -d
# View Jenkins logs
docker-compose -f docker-compose.jenkins.yml logs -f jenkins
# Stop
docker-compose -f docker-compose.jenkins.yml downPurpose: Individual service Dockerfiles for building service-specific images
Examples:
frontend/Dockerfile- Builds Angular frontend with Nginxbackend/api-gateway/Dockerfile- Builds API Gateway servicebackend/user-service/Dockerfile- Builds User Servicebackend/media-service/Dockerfile- Builds Media Service- etc.
Using Makefile (Recommended - NOW FIXED!)
# Build all Java services + Frontend (uses individual Dockerfiles)
make build
# This builds:
# - backend/api-gateway using backend/api-gateway/Dockerfile
# - backend/user-service using backend/user-service/Dockerfile
# - backend/product-service using backend/product-service/Dockerfile
# - backend/media-service using backend/media-service/Dockerfile
# - backend/discovery-service using backend/discovery-service/Dockerfile
# - backend/dummy-data using backend/dummy-data/Dockerfile
# - frontend/angular app using frontend/Dockerfile
# Image tags created: mahdikheirkhah/service-name:latestManual Docker Build Commands
# Build a specific service (using its individual Dockerfile)
docker build \
--file backend/api-gateway/Dockerfile \
--tag mahdikheirkhah/api-gateway:latest \
backend/api-gateway/
# Build frontend
docker build \
--file frontend/Dockerfile \
--tag mahdikheirkhah/frontend:latest \
frontend/
# Build with specific tag/version
docker build \
--file backend/user-service/Dockerfile \
--tag mahdikheirkhah/user-service:v1.0.0 \
backend/user-service/
# Build with no cache (fresh build)
docker build --no-cache -f backend/api-gateway/Dockerfile -t mahdikheirkhah/api-gateway backend/api-gateway/Using Makefile
# Start all services
make up
# Or manually with docker-compose
docker-compose up -dUsing docker-compose directly
# Start services in background
docker-compose up -d
# Start with logs visible (foreground)
docker-compose up
# Start only specific services
docker-compose up -d api-gateway user-service mongo
# Start with rebuild (if images changed)
docker-compose up -d --build# List running containers
docker ps
# List all containers (including stopped)
docker ps -a
# View container logs
docker logs container-name
docker logs -f container-name # Follow logs (Ctrl+C to exit)
# Execute command in running container
docker exec -it container-name bash
docker exec -it mongo mongosh # Access MongoDB shell
# Stop services
docker-compose stop
# Stop and remove services
docker-compose down
# Remove volumes too (data loss!)
docker-compose down -v
# Restart services
docker-compose restart
docker-compose restart api-gateway# Check service health
curl -k https://localhost:8443/actuator/health
curl http://localhost:8761/actuator/health
# View container resource usage
docker stats
# Inspect container details
docker inspect container-name
# View container events in real-time
docker events
# Check network connectivity
docker-compose exec api-gateway ping user-service# Stop and remove containers
docker-compose down
# Remove all stopped containers
docker container prune
# Remove unused images
docker image prune
# Remove unused volumes
docker volume prune
# Complete cleanup (containers, images, volumes, networks)
docker system prune -a --volumes
# Remove specific image
docker rmi backend/api-gateway| Component | Required? | Purpose | When to Use |
|---|---|---|---|
| Docker Compose | β YES | Runs all microservices & infrastructure | Always (unless running services locally) |
| MongoDB | β YES | Database for storing data | Always |
| Kafka | Async messaging between services | Production / Advanced features | |
| SonarQube | β NO | Code quality analysis (non-functional) | Only if you want code quality metrics |
| Jenkins | β NO | CI/CD automation (non-functional) | Only if you want automated pipelines |
β Application will work perfectly fine without it:
- All microservices run normally
- Database operations work
- API endpoints respond
- Frontend loads and functions
- Users can register, login, create products, upload media
β What you lose without SonarQube:
- Code quality metrics
- Vulnerability detection
- Technical debt tracking
- Code smell identification
- Security hotspot reporting
- Enterprise/Corporate Environments - Mandatory code quality gates
- Security-Critical Applications - Must identify vulnerabilities
- Large Teams - Track code quality across team
- Compliance Requirements - Regulatory standards (HIPAA, SOC2, etc.)
- Long-term Projects - Monitor technical debt over time
- Learning/Educational Projects - Like this one! Focus on features first
- Prototypes & MVPs - Speed matters more than code quality
- Small Projects - Manual code reviews sufficient
- Development Environments - Run it locally only when needed
# Run WITHOUT SonarQube - Focus on features
make all
# This starts:
# β
All microservices
# β
Database & Kafka
# β
Frontend
# β SonarQube (skipped - not needed)What to do: Use the application, test APIs, explore the code. Come back to SonarQube later.
# Run WITH SonarQube - Complete setup
make all
# SonarQube starts automatically on port 9000
# Access: http://localhost:9000 (admin/admin)
# Then analyze code:
cd backend && mvn sonar:sonar \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=admin \
-Dsonar.password=admin# Run Jenkins environment WITHOUT full SonarQube integration
docker-compose -f docker-compose.jenkins.yml up -d
# This starts:
# β
All microservices (pre-built)
# β
Jenkins (CI/CD)
# β οΈ SonarQube (included but optional)
# Access Jenkins: http://localhost:8080If you've already started services with make up and want to disable SonarQube:
Option 1: Stop only SonarQube
docker-compose stop sonarqube
docker-compose rm sonarqube # Remove containerOption 2: Edit docker-compose.yml
# Comment out the sonarqube section in docker-compose.yml
# Then restart
docker-compose down
docker-compose up -dOption 3: Start services without SonarQube
# Start all EXCEPT sonarqube
docker-compose up -d \
kafka zookeeper mongo \
discovery-service api-gateway \
user-service product-service media-service \
frontendβββββββββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββββββββββββββ
β Component β Requirement β Run Command β
βββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββββββββββββββ€
β Core App β β
REQUIRED β make all β
β Microservices β β
REQUIRED β (started by docker-compose) β
β Database (MongoDB) β β
REQUIRED β (started automatically) β
β Message Broker β β οΈ Optional β (started by default) β
β SonarQube β β Optional β Stop it if not needed β
β Jenkins β β Optional β docker-compose.jenkins.yml β
βββββββββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββββββββββββββββββ
Use the setup.sh script for one-command startup:
# Basic startup (core services only)
./setup.sh
# Clean Docker and start fresh
./setup.sh --clean
# Start with Jenkins CI/CD
./setup.sh --jenkins
# Start with ngrok for external access
./setup.sh --ngrok
# Complete setup: clean + Jenkins + ngrok
./setup.sh --clean --jenkins --ngrokWhat the script does:
- β Validates Docker is running
- β
Optionally cleans Docker (with
--clean) - β Starts all microservices and infrastructure
- β
Optionally starts Jenkins (with
--jenkins) - β
Optionally starts ngrok tunnels (with
--ngrok) - β Displays all access URLs and credentials
- β Shows useful commands for monitoring
# Build all images (first time or after code changes)
make build
# Start services in background
make up
# View logs (all services)
docker-compose logs -f
# View logs for specific service
docker-compose logs -f api-gateway
docker-compose logs -f user-service
docker-compose logs -f product-service
docker-compose logs -f media-service
docker-compose logs -f frontend# Stop all services
make down
# Stop without removing volumes
docker-compose stop
# Restart services
docker-compose restart
# Complete cleanup (removes volumes, networks, etc.)
make clean# Navigate to backend
cd backend
# Build parent project
mvn clean install
# Start Discovery Service
cd discovery-service
mvn spring-boot:run
# In another terminal, start other services
cd ../user-service && mvn spring-boot:run
cd ../product-service && mvn spring-boot:run
cd ../media-service && mvn spring-boot:runcd backend/api-gateway
mvn spring-boot:runcd frontend
# Install dependencies
npm install
# Run development server
npm start
# Access at http://localhost:4200# This uses the Jenkins-specific configuration
docker-compose -f docker-compose.jenkins.yml up -d
# View Jenkins logs
docker-compose -f docker-compose.jenkins.yml logs -f jenkins
# Stop
docker-compose -f docker-compose.jenkins.yml down- Docker installed
- GitHub repository access
- Docker Hub account (for image registry)
# Start Jenkins using docker-compose.jenkins.yml
docker-compose -f docker-compose.jenkins.yml up -d
# Retrieve initial admin password
docker-compose -f docker-compose.jenkins.yml exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
# Access Jenkins
# URL: http://localhost:8080
# Username: admin
# Password: [paste the password from above]# Download and install Jenkins (macOS with Homebrew)
brew install jenkins-lts
brew services start jenkins-lts
# Access Jenkins at http://localhost:8080-
Go to Manage Jenkins β Manage Credentials β System β Global credentials
-
Add the following credentials:
Docker Hub Credentials
- Kind: Username with password
- Username:
[your-docker-hub-username] - Password:
[your-docker-hub-token] - ID:
dockerhub-credentials
GitHub Credentials (for repo access)
- Kind: Username with password
- Username:
[your-github-username] - Password:
[your-github-personal-access-token] - ID:
github-credentials
SonarQube Credentials (optional)
- Kind: Secret text
- Secret:
[your-sonarqube-token] - ID:
sonarqube-token
-
Go to New Item
-
Enter job name:
Buy-01-Pipeline -
Select: Pipeline
-
Configure:
Definition: Pipeline script from SCM
SCM: Git
- Repository URL:
https://github.com/mahdikheirkhah/buy-01.git - Credentials: Select
github-credentials - Branch:
*/main - Script path:
Jenkinsfile
- Repository URL:
-
Save
- In job configuration, check GitHub hook trigger for GITScm polling
- In GitHub Settings:
- Go to Settings β Webhooks β Add webhook
- Payload URL:
http://[your-jenkins-ip]:8080/github-webhook/ - Content type:
application/json - Events: Push events
# Option 1: Via Jenkins UI
1. Click on "Build Now" in job page
# Option 2: Via curl
curl -X POST http://localhost:8080/job/Buy-01-Pipeline/build \
--user admin:${JENKINS_API_TOKEN}The pipeline supports customizable parameters:
BRANCH // Git branch to build (default: main)
RUN_TESTS // Execute unit tests (default: true)
RUN_INTEGRATION_TESTS // Execute integration tests (default: false)
RUN_SONAR // Run SonarQube analysis (default: true)
SKIP_DEPLOY // Skip deployment step (default: true)
DEPLOY_LOCALLY // Deploy via Docker Compose (default: true)Example: Build with custom parameters via UI or CLI
# Build specific branch with SonarQube enabled
curl -X POST http://localhost:8080/job/Buy-01-Pipeline/buildWithParameters \
-F BRANCH=develop \
-F RUN_SONAR=true \
-F DEPLOY_LOCALLY=true \
--user admin:${JENKINS_API_TOKEN}| Stage | Purpose | Details |
|---|---|---|
| Initialization | Setup | Logs build parameters and environment |
| Checkout | SCM | Pulls latest code from Git branch |
| Backend Build | Compile | Builds Java services with Maven |
| Backend Tests | QA | Runs JUnit tests (if RUN_TESTS=true) |
| Frontend Build | Compile | Builds Angular app with npm |
| Frontend Tests | QA | Runs Jasmine/Karma tests |
| SonarQube | Analysis | Publishes code quality metrics |
| Docker Build | Package | Creates container images for each service |
| Docker Push | Registry | Pushes images to Docker Hub |
| Deploy | Deployment | Deploys via Docker Compose (local or SSH) |
| Notifications | Alerts | Sends Slack/Email notifications |
SonarQube is automatically started when you run make up. No additional setup needed.
# SonarQube is running at http://localhost:9000
# Default credentials: admin / admin# Pull and run SonarQube
docker run -d \
--name sonarqube \
-p 9000:9000 \
-e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true \
-v sonarqube_data:/opt/sonarqube/data \
-v sonarqube_logs:/opt/sonarqube/logs \
sonarqube:lts-community- Access http://localhost:9000
- Login with admin / admin
- Click Create β New organization
- Organization key:
buy-01 - Organization name:
Buy-01 E-Commerce
- Organization key:
For each module (Backend, Frontend), create separate projects:
Projects to create:
- buy-01-backend (Java)
- buy-01-frontend (TypeScript/Angular)
- Go to Administration β Security β Tokens
- Generate tokens for:
buy-01-backendbuy-01-frontend
- Copy tokens and store securely (for Jenkins)
The pipeline automatically runs SonarQube when RUN_SONAR=true:
stage('π SonarQube Analysis') {
when { expression { params.RUN_SONAR } }
steps {
withSonarQubeEnv('SonarQube') {
sh '''
mvn clean verify sonar:sonar \
-Dsonar.projectKey=buy-01-backend
'''
}
}
}Backend (Java)
cd backend
# Run analysis with Maven
mvn clean verify sonar:sonar \
-Dsonar.projectKey=buy-01-backend \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=[your-token]Frontend (Angular/TypeScript)
cd frontend
# Install SonarScanner for JS/TS
npm install -D sonar-scanner
# Run analysis
./node_modules/.bin/sonar-scanner \
-Dsonar.projectKey=buy-01-frontend \
-Dsonar.sources=src \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=[your-token]-
Dashboard: http://localhost:9000/dashboard
- Overview of all projects
- Code coverage metrics
- Security hotspots
-
Issue Tracking
- View bugs, code smells, vulnerabilities
- Filter by severity (Blocker, Critical, Major, Minor, Info)
- Assign to developers
-
Quality Gates
- Define pass/fail criteria
- Block releases if standards not met
- Gate: Coverage > 80%, Rating A+
# In SonarQube (Administration β General Settings β GitHub):
1. Configure GitHub App:
- Organization: mahdikheirkhah
- Repository: buy-01
- Generate app credentials
2. PR Decoration:
- Automatic comments on PRs with analysis results
- Report quality gates status- Local Development:
http://localhost:8443 - Production:
https://api.buy-01.com
JWT tokens are stored in HTTP-only secure cookies for enhanced security. The browser automatically sends the cookie with each request, so no manual Authorization header is needed.
How it works:
- On successful login/register, the server sets an HTTP-only cookie containing the JWT
- The cookie is automatically included in subsequent requests by the browser
- This prevents XSS attacks from accessing the token via JavaScript
# Cookie is set automatically by the server after login:
Set-Cookie: jwt=eyJhbGc...; HttpOnly; Secure; SameSite=Strict; Path=/Authentication
# Register User
POST /auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "secure123",
"firstName": "John",
"lastName": "Doe",
"role": "SELLER" // or CLIENT
}
# Login
POST /auth/login
{
"email": "user@example.com",
"password": "secure123"
}
Response:
{
"token": "eyJhbGc...",
"refreshToken": "eyJhbGc...",
"expiresIn": 3600
}
# Note: Token is also set as HTTP-only cookie automaticallyUser Profile
# Get Current User
GET /api/users/me
Authorization: Bearer <token>
# Update Profile
PUT /api/users/me
{
"firstName": "John",
"lastName": "Doe"
}
# Upload Avatar (delegates to Media Service)
PUT /api/users/me/avatar
Content-Type: multipart/form-data
File: [image.jpg]Public Endpoints
# List All Products
GET /api/products
Response:
[
{
"id": "507f1f77bcf86cd799439011",
"name": "Product Name",
"description": "...",
"price": 99.99,
"imageUrls": ["https://..."],
"seller": { "id": "...", "name": "..." },
"createdAt": "2026-01-05T10:00:00Z"
}
]
# Get Product Details
GET /api/products/{id}Seller-Only Endpoints
# Create Product (requires SELLER role)
POST /api/products
Authorization: Bearer <token>
{
"name": "New Product",
"description": "Description",
"price": 199.99,
"imageUrls": []
}
# Update Product (owner only)
PUT /api/products/{id}
{
"name": "Updated Name",
"price": 149.99
}
# Delete Product (owner only)
DELETE /api/products/{id}Upload Images
# Upload Product Image (max 2MB)
POST /api/media/images
Authorization: Bearer <token>
Content-Type: multipart/form-data
File: [image.jpg]
Response:
{
"id": "507f1f77bcf86cd799439012",
"url": "https://localhost:8443/api/media/images/507f1f77bcf86cd799439012",
"fileName": "image.jpg",
"mimeType": "image/jpeg",
"size": 150000,
"createdAt": "2026-01-05T10:00:00Z"
}Download Images
# Get Image
GET /api/media/images/{id}
# Get Thumbnail
GET /api/media/images/{id}/thumbnailbuy-01/
βββ backend/ # Spring Boot Microservices
β βββ pom.xml # Parent POM (multi-module)
β βββ common/ # Shared libraries, utilities, DTOs
β β βββ src/main/java/
β β β βββ com/buy01/
β β β βββ common/
β β β βββ dto/
β β β βββ exception/
β β β βββ security/
β β β βββ kafka/
β β β βββ util/
β β βββ pom.xml
β β
β βββ discovery-service/ # Eureka Service Registry
β β βββ src/main/java/com/buy01/discovery/
β β βββ src/main/resources/application.properties
β β βββ Dockerfile
β β βββ pom.xml
β β
β βββ api-gateway/ # Spring Cloud Gateway
β β βββ src/main/java/com/buy01/gateway/
β β β βββ config/ # Gateway routing, security
β β β βββ filter/ # Auth, CORS, logging filters
β β βββ src/main/resources/application.properties
β β βββ Dockerfile
β β βββ pom.xml
β β
β βββ user-service/ # User Management & Authentication
β β βββ src/main/java/com/buy01/user/
β β β βββ controller/ # REST endpoints
β β β βββ service/ # Business logic
β β β βββ repository/ # MongoDB operations
β β β βββ entity/ # Domain models
β β β βββ security/ # JWT, Spring Security
β β β βββ exception/ # Error handling
β β βββ src/test/java/ # Unit & integration tests
β β βββ Dockerfile
β β βββ pom.xml
β β
β βββ product-service/ # Product Management
β β βββ src/main/java/com/buy01/product/
β β β βββ controller/
β β β βββ service/
β β β βββ repository/
β β β βββ entity/
β β β βββ event/ # Kafka event publishing
β β βββ src/test/java/
β β βββ Dockerfile
β β βββ pom.xml
β β
β βββ media-service/ # Image Upload & Management
β β βββ src/main/java/com/buy01/media/
β β β βββ controller/
β β β βββ service/
β β β βββ repository/
β β β βββ entity/
β β β βββ validation/ # File type, size validation
β β β βββ storage/ # File system operations
β β βββ uploads/ # Image storage directory
β β βββ src/test/java/
β β βββ Dockerfile
β β βββ pom.xml
β β
β βββ dummy-data/ # Data seeding service
β β βββ src/main/java/
β β βββ pom.xml
β β
β βββ certificates/ # SSL/TLS Certificates
β β βββ generate-certificates.sh # Certificate generation script
β β βββ ca/
β β βββ keystores/ # JKS keystores per service
β β
β βββ target/ # Maven build output
β
βββ frontend/ # Angular Single Page Application
β βββ src/
β β βββ app/
β β β βββ core/ # Services, guards, interceptors
β β β β βββ services/
β β β β β βββ auth.service.ts
β β β β β βββ user.service.ts
β β β β β βββ product.service.ts
β β β β β βββ media.service.ts
β β β β βββ guards/
β β β β β βββ auth.guard.ts
β β β β β βββ role.guard.ts
β β β β βββ interceptors/
β β β β βββ auth.interceptor.ts
β β β β βββ error.interceptor.ts
β β β β
β β β βββ shared/ # Reusable components, pipes
β β β β βββ components/
β β β β βββ pipes/
β β β β βββ directives/
β β β β
β β β βββ auth/ # Auth module (Login, Register)
β β β β βββ login/
β β β β βββ register/
β β β β βββ auth-routing.module.ts
β β β β
β β β βββ dashboard/ # Seller dashboard
β β β β βββ products/ # Manage products
β β β β βββ media/ # Upload/manage images
β β β β βββ dashboard-routing.module.ts
β β β β
β β β βββ products/ # Public product browsing
β β β β βββ list/
β β β β βββ detail/
β β β β βββ products-routing.module.ts
β β β β
β β β βββ app-routing.module.ts
β β β
β β βββ assets/ # Static files
β β βββ index.html
β β βββ main.ts
β β βββ styles.scss # Global styles
β β βββ custom-theme.scss # Material theme customization
β β βββ app.component.ts
β β
β βββ public/ # Public static assets
β βββ angular.json # Angular CLI config
β βββ package.json # Dependencies
β βββ tsconfig.json # TypeScript config
β βββ Dockerfile # Multi-stage build
β βββ nginx.conf # Nginx reverse proxy
β βββ README.md
β
βββ lib/ # Custom libraries (if any)
βββ scripts/ # (Optional) Utility scripts
β
βββ certs/ # SSL certificates (Let's Encrypt)
β
βββ Dockerfile # Multi-stage generic Java builder
βββ Dockerfile.jenkins # Jenkins agent image (if needed)
βββ Makefile # Build automation
βββ Jenkinsfile # CI/CD pipeline definition
βββ docker-compose.yml # Local development environment
βββ docker-compose.jenkins.yml # Jenkins deployment environment
β
βββ README.md # This file
# Clone repository
git clone https://github.com/mahdikheirkhah/buy-01.git
cd buy-01
# Install Git hooks (optional)
git config core.hooksPath .github/hooks
# Create local environment file
cp .env.example .envBuild Parent Project
cd backend
mvn clean install -DskipTestsRunning Individual Services
# Terminal 1: Discovery Service
cd backend/discovery-service
mvn spring-boot:run
# Terminal 2: User Service
cd backend/user-service
mvn spring-boot:run
# Terminal 3: Product Service
cd backend/product-service
mvn spring-boot:run
# Terminal 4: Media Service
cd backend/media-service
mvn spring-boot:run
# Terminal 5: API Gateway
cd backend/api-gateway
mvn spring-boot:runcd frontend
# Install dependencies
npm install
# Start development server
npm start
# Runs on http://localhost:4200
# Auto-reload on file changesBackend Unit Tests
cd backend
mvn testBackend Integration Tests
mvn verifyFrontend Unit Tests
cd frontend
npm testFrontend End-to-End Tests
npm run e2e# Create and checkout feature branch
git checkout -b feature/user-authentication
# or
git checkout -b fix/login-bug
# Make changes...
git add .
git commit -m "feat: implement user authentication with JWT"
# Push to remote
git push origin feature/user-authentication
# Create Pull Request via GitHub UIfeature/<feature-name> # New features
fix/<bug-name> # Bug fixes
refactor/<area> # Code refactoring
docs/<topic> # Documentation
test/<area> # Test additions
feat: add new user registration endpoint
fix: resolve NPE in product listing
refactor: extract gateway routing config
docs: update API documentation
test: add unit tests for media upload validation
style: format code according to checkstyle
chore: update dependencies
Before pushing, run quality checks:
# Backend: CheckStyle & SpotBugs
cd backend
mvn checkstyle:check
mvn spotbugs:check
# Frontend: ESLint & Prettier
cd frontend
npm run lint
npm run format
# Backend: SonarQube Analysis (requires running SonarQube)
mvn sonar:sonar -Dsonar.host.url=http://localhost:9000For detailed troubleshooting guides and solutions to common issues, see TROUBLESHOOTING.md.
- Issues & Bugs: Create GitHub Issues
- Features: Create GitHub Discussions
- PRs: Submit Pull Requests with description
License: MIT
Contributors:
- Follow the Quick Start to get the application running
- Access the Frontend at https://localhost:4200
- Register as a Seller to test product creation
- Upload Products and manage media
- Monitor Code Quality via SonarQube at http://localhost:9000
- Run Jenkins Pipeline to test CI/CD automation