A comprehensive microservices-based e-commerce platform featuring a modern Angular web client, ASP.NET Core backend services, FastAPI authentication service, and complete Docker orchestration.
This project implements a complete microservices architecture with:
- API Gateway (Ocelot) - Central request routing
- Authentication Service (FastAPI) - JWT token generation and user management
- Catalog Service (ASP.NET Core) - Product catalog with MongoDB
- Cart Service (ASP.NET Core) - Shopping cart with Redis
- Ordering Service (ASP.NET Core) - Order management with SQL Server
- Angular Web Client - Modern responsive SPA
- Message Bus (RabbitMQ) - Asynchronous service communication
# Navigate to project root
cd e:\GitRepo\MicroservicesMyApp
# Start all services
docker-compose up --build
# Access the applications:
# Angular Web Client: http://localhost:3000
# Ocelot Gateway: http://localhost:7000
# FastAPI Auth Service: http://localhost:8010
# Catalog API: http://localhost:8000
# Cart API: http://localhost:8001
# Ordering API: http://localhost:8002Email: demo@example.com
Password: secret
The authentication system is built with FastAPI and provides:
- User Registration - Create new accounts with email/password
- User Login - Authenticate and receive JWT tokens
- Token Verification - Validate token integrity
- User Profile - Get current user information
- Logout - Invalidate sessions
Service Details:
- Port: 8010 (Docker), 8003 (Direct)
- Token Type: JWT (Bearer)
- Token Expiry: 30 minutes
- Password Hashing: bcrypt
- Product Catalog - Browse products with filtering
- Product Details - View complete product information
- Shopping Cart - Add/remove items with quantity management
- Checkout - Multi-step secure checkout process
- Order History - View all previous orders
- Order Confirmation - Print-friendly receipts
- JWT Authentication - Secure token-based auth
- Password Hashing - Bcrypt password protection
- Route Guards - Protected checkout and order pages
- HTTP Interceptors - Automatic token injection
- CORS Enabled - Secure cross-origin requests
- Form Validation - Real-time input validation
- Material Design - Professional Google Material components
- Responsive Layout - Mobile, tablet, and desktop support
- Real-time Updates - RxJS-based reactive state management
- Smooth Animations - CSS transitions and Material effects
- Dark Mode Ready - Angular Material theming support
.
βββ docker-compose.yml # Service definitions
βββ docker-compose.override.yml # Development configuration
βββ LICENSE
βββ README.md
βββ MicroservicesMyApp.sln # Visual Studio solution
βββ src/
β βββ ApiGateWays/
β β βββ OcelotGateWay/ # Request routing and aggregation
β βββ Catalog/
β β βββ Catalog.API/ # Product catalog service
β βββ Cart/
β β βββ Cart.API/ # Shopping cart service
β βββ Common/
β β βββ EventBusRabbitMq/ # Message bus implementation
β βββ Ordering/
β β βββ Ordering.API/ # Order management service
β β βββ Ordering.Application/ # Business logic
β β βββ Ordering.Core/ # Domain models
β β βββ Ordering.Infrastructure/ # Data access
β βββ Services/
β β βββ AuthService/ # FastAPI authentication
β β βββ main.py # FastAPI application
β β βββ requirements.txt # Python dependencies
β β βββ Dockerfile # Container configuration
β βββ WebClient/
β βββ TraditionalWebClient/ # ASP.NET Core MVC client
β βββ AngularWebClient/ # Modern Angular SPA
β βββ src/
β β βββ app/
β β β βββ core/ # Services, guards, interceptors
β β β βββ features/ # Page components
β β β βββ layouts/ # Header, footer
β β β βββ shared/ # Common components
β β β βββ app.routes.ts # Route definitions
β β β βββ app.component.ts
β β βββ environments/ # Config files
β β βββ assets/ # Images, fonts
β β βββ index.html
β β βββ main.ts
β β βββ styles.scss
β βββ angular.json # Angular CLI config
β βββ tsconfig.json # TypeScript config
β βββ package.json # NPM dependencies
β βββ Dockerfile # Container build
β βββ README.md # Client-specific docs
βββ DevAssets/
βββ bin/
| Service | Port (Docker) | Port (Direct) | Protocol | Database |
|---|---|---|---|---|
| API Gateway (Ocelot) | 7000 | 7000 | HTTP | N/A |
| Catalog API | 8000 | 8000 | HTTP | MongoDB |
| Cart API | 8001 | 8001 | HTTP | Redis |
| Ordering API | 8002 | 8002 | HTTP | SQL Server |
| FastAPI Auth | 8010 | 8003 | HTTP | In-Memory* |
| Angular Client | 3000 | 4200 | HTTP/WS | N/A |
| RabbitMQ | 5672 | 5672 | AMQP | N/A |
| RabbitMQ Console | 15672 | 15672 | HTTP | N/A |
*Dev: In-memory dict, Prod: PostgreSQL/MongoDB recommended
The Ocelot Gateway aggregates services:
/api/catalog/* β Catalog Service (8000)
/api/cart/* β Cart Service (8001)
/api/orders/* β Ordering Service (8002)
/api/auth/* β FastAPI Auth Service (8010)
- Framework: ASP.NET Core 8.0
- APIs: RESTful Web APIs
- Databases: MongoDB, Redis, SQL Server
- Message Bus: RabbitMQ
- API Gateway: Ocelot
- Framework: FastAPI 0.104
- Server: Uvicorn ASGI
- Security: python-jose (JWT), passlib (Bcrypt)
- Validation: Pydantic
- Framework: Angular 17
- UI Library: Angular Material 17
- CSS Framework: Bootstrap 5
- Reactive: RxJS 7.8
- Language: TypeScript 5.2
- Styling: SCSS
- Containerization: Docker & docker-compose
- Orchestration: Docker Compose
- Monitoring: RabbitMQ Management Console
# Build images
docker-compose build
# Start services
docker-compose up
# Run in background
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Remove volumes (clean state)
docker-compose down -v# Check running containers
docker-compose ps
# View specific service logs
docker-compose logs auth.api
docker-compose logs ocelotgatewayDevelopment (docker-compose.override.yml):
catalog.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- CatalogDbSettings:ConnectionString=mongodb://catalogdb:27017
cart.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings:Redis=cartdb:6379
- EventBus:HostName=rabbitmq
auth.api:
environment:
- PYTHONUNBUFFERED=1cd src/WebClient/AngularWebClient
# Install dependencies
npm install
# Start development server
ng serve
# Access: http://localhost:4200
# Production build
ng build --configuration productioncd src/Services/AuthService
# Create virtual environment
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run development server
uvicorn main:app --reload --port 8003
# Access: http://localhost:8003/docs (Swagger UI)# Build solution
dotnet build
# Run specific service
cd src/Ordering/Ordering.API
dotnet run
# Watch mode
dotnet watch run- User submits email/password on login page
- FastAPI validates credentials and returns JWT token
- Token stored in browser localStorage
- HTTP interceptor automatically injects token in API requests
- Backend validates token on protected endpoints
- 401 response triggers automatic logout
Routes requiring authentication:
/checkout- Requires valid JWT token/confirmation- Requires valid JWT token/orders- Requires valid JWT token
FastAPI enables CORS for development:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Configure for production
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)- Minimum 6 characters
- Hashed with bcrypt (cost factor 12)
- Never transmitted in plain text
- JWT tokens used for subsequent requests
-
Backend API Endpoint
// Add endpoint in ASP.NET Core service [HttpGet("endpoint")] public async Task<ActionResult> Endpoint() { }
-
API Gateway Route
{ "DownstreamPathTemplate": "/api/service/endpoint", "DownstreamScheme": "http", "DownstreamHostAndPorts": [{ "Host": "service.api", "Port": 8000 }] } -
Angular Service
getEndpoint(): Observable<Data> { return this.http.get<Data>(`${this.apiUrl}/endpoint`); }
-
Angular Component
ngOnInit() { this.service.getEndpoint().subscribe(data => { this.data = data; }); }
# Angular unit tests
cd src/WebClient/AngularWebClient
ng test
# ASP.NET Core tests
dotnet test
# API integration tests
# (FastAPI tests in src/Services/AuthService/tests/)URL: http://localhost:15672
Username: guest
Password: guest
Monitor message queues and service communication.
# Check port conflicts
lsof -i :3000 # macOS/Linux
netstat -ano | findstr 3000 # Windows
# Clear Docker cache
docker-compose down -v
docker system prune
docker-compose up --build# Check if auth service is running
curl http://localhost:8010/health
# Verify token in browser
localStorage.getItem('access_token')
# Check browser console for CORS errors# Verify MongoDB
docker-compose logs catalogdb
# Verify Redis
docker-compose logs cartdb
# Verify SQL Server
docker-compose logs orderdb# Check gateway logs
docker-compose logs ocelotgateway
# Verify service availability
curl http://localhost:7000/api/catalog/products- Ocelot Gateway: http://localhost:7000/swagger
- FastAPI Auth: http://localhost:8010/docs
- Catalog API: http://localhost:8000/swagger
- Cart API: http://localhost:8001/swagger
- Ordering API: http://localhost:8002/swagger
- Angular lazy loading for routes
- Production builds with ahead-of-time (AOT) compilation
- Bundle analysis and optimization
- Entity Framework Core query optimization
- Caching layers (Redis for cart)
- Async/await patterns throughout
# Build production images
docker build -t myregistry/auth-api:1.0 src/Services/AuthService
docker build -t myregistry/angular-client:1.0 src/WebClient/AngularWebClient
# Push to registry
docker push myregistry/auth-api:1.0
docker push myregistry/angular-client:1.0
# Deploy with Helm or kubectl
kubectl apply -f k8s/ASPNETCORE_ENVIRONMENT=Production
DATABASE_CONNECTION_STRING=<prod-db-connection>
RABBITMQ_HOST=<prod-rabbitmq-host>
JWT_SECRET_KEY=<secure-random-key>
ALLOWED_ORIGINS=https://yourdomain.com- Angular Documentation
- ASP.NET Core Documentation
- FastAPI Documentation
- Docker Documentation
- RabbitMQ Documentation
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a pull request
For questions or issues:
- Check Troubleshooting section
- Review Docker logs:
docker-compose logs - Check browser DevTools console for client-side errors
- Verify all services running:
docker-compose ps
Start the application with: docker-compose up --build
Access at: http://localhost:3000
Happy coding! π
Port already in use?
ng serve --port 4300API not connecting?
- Check API Gateway is running on port 7000
- Verify environment configuration
- Check browser console for errors
This project is licensed under the MIT License. See the LICENSE file for details.
Built with β€οΈβοΈπΊ Happy Coding ππ