Skip to content

yelmach/ecom-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

126 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecom-platform

Microservices-based e-commerce platform with a Spring Boot backend and Angular frontend.

Architecture

Backend services:

  • discovery-service (Eureka service registry)
  • gateway-service (single entrypoint, JWT auth, routing)
  • user-service (auth + profile)
  • product-service (catalog management)
  • media-service (image upload + media metadata)

Supporting infrastructure:

  • MongoDB
  • MinIO (object storage)

Frontend:

  • Angular app consuming gateway APIs

Service docs

  • backend/discovery-service/README.md
  • backend/gateway-service/README.md
  • backend/user-service/README.md
  • backend/product-service/README.md
  • backend/media-service/README.md
  • docs/backend-unit-testing-guide.md (JUnit + backend testing walkthrough)
  • frontend/README.md
  • docs/frontend-unit-testing-guide.md (Jasmine/Karma frontend testing walkthrough)
  • docs/jenkins-ci-guide.md (Jenkins setup + CI pipeline walkthrough)

Config files

  • backend/.env for manual local service runs (dev mode).
  • backend/docker.env for Docker Compose runs (prod and dev infra).
  • backend/.env.example and backend/docker.env.example as templates.
  • Mongo logical DB isolation uses:
    • MONGO_USER_DATABASE
    • MONGO_PRODUCT_DATABASE
    • MONGO_MEDIA_DATABASE on the same MongoDB instance.

Prerequisites

  • Docker + Docker Compose
  • OpenSSL
  • Java 17
  • Node.js + npm

One-time setup

1) Generate gateway TLS certs (for HTTPS gateway)

mkdir -p backend/certs
openssl req -x509 -nodes -newkey rsa:2048 -sha256 -days 825 \
  -keyout backend/certs/gateway.key \
  -out backend/certs/gateway.crt \
  -subj "/CN=localhost" \
  -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
openssl pkcs12 -export \
  -out backend/certs/gateway.p12 \
  -inkey backend/certs/gateway.key \
  -in backend/certs/gateway.crt \
  -name gateway \
  -passout pass:changeit

2) Generate JWT RSA keys (user-service signs, gateway verifies)

mkdir -p backend/keys
openssl genpkey -algorithm RSA -out backend/keys/private.pem -pkeyopt rsa_keygen_bits:2048
openssl pkey -in backend/keys/private.pem -pubout -out backend/keys/public.pem

Launch modes

Prod mode (all backend + infra in Docker)

From repo root:

make prod-up

This starts backend services plus the Dockerized frontend on https://localhost:4200.

Stop:

make prod-down

Stop and remove volumes:

make prod-down-v

Direct Docker Compose equivalent:

docker compose --env-file backend/docker.env -f docker-compose.yml up --build -d

Dev mode (infra in Docker, services/frontend manual)

  1. Start infra (mongo, minio, discovery-service) from repo root:
make dev-infra-up
  1. Run backend services manually (each in a separate terminal):
cd backend/media-service && ./mvnw spring-boot:run
cd backend/user-service && ./mvnw spring-boot:run
cd backend/product-service && ./mvnw spring-boot:run
cd backend/gateway-service && ./mvnw spring-boot:run
  1. Run frontend:
cd frontend
npm install
npm run start:https
  1. Stop infra:
make dev-infra-down

Note: in dev mode, backend services load local env values from backend/.env. Frontend in dev mode still runs manually with npm run start:https.

Main URLs

  • Frontend: https://localhost:4200
  • Gateway: https://localhost:8443
  • Eureka: http://localhost:8761
  • MinIO API: http://localhost:9000
  • MinIO Console: http://localhost:9001

API flow notes

Auth and profile avatar

  1. POST /auth/register
  2. Optional avatar upload: POST /media/profile
  3. Link avatar to profile: PATCH /users/me with avatarMediaId

Product and images

  1. Create product: POST /products with mediaIds: []
  2. Upload images: POST /media/images with productId + files[]
  3. Save image IDs on product: PUT /products/{id} with mediaIds

Compatibility note

  • Canonical compose files are at repo root: docker-compose.yml and docker-compose.dev.yml.
  • backend/docker-compose.yml is kept for compatibility with existing commands.
  • Frontend Docker runtime uses Nginx with TLS certs from backend/certs and proxies API routes to gateway-service.

About

Microservices-based e-commerce platform with a Spring Boot backend and Angular frontend.

Topics

Resources

Stars

Watchers

Forks

Contributors