A full-featured food delivery system built with .NET 9 using a microservices architecture, Clean Architecture principles, the CQRS pattern, and Event-Driven Architecture. It includes dedicated services for catalog, basket, ordering, discounts, and authentication, leveraging technologies like PostgreSQL, Redis, RabbitMQ, MinIO, Keycloak, and Angular.
This application follows a microservices architecture pattern with the following services:
- Catalog Service: Manages food products and categories
- Basket Service: Handles shopping cart functionality
- Ordering Service: Processes orders and order management
- Discount Service: Manages discount coupons via gRPC
- Gateway API: API Gateway for routing and authentication
- .NET 9: Core framework
- PostgreSQL: Database for Catalog, Basket, and Keycloak
- SQL Server: Database for Ordering service
- Redis: Distributed caching
- RabbitMQ: Message broker for event-driven communication
- MinIO: Object storage for image management
- Keycloak: Identity and access management
- Docker & Docker Compose: Containerization
- Angular: Frontend web application
MinIO is used as the object storage solution for managing product images in the food delivery application.
Docker Compose Setup:
minio:
image: minio/minio:latest
container_name: minio
environment:
- MINIO_ROOT_USER=admin
- MINIO_ROOT_PASSWORD=admin123
- MINIO_DEFAULT_BUCKETS=food-delivery-catalog
ports:
- "9000:9000" # MinIO API
- "9001:9001" # MinIO Console
command: server /data --console-address ":9001"
volumes:
- minio_data:/data- Image Upload: Automatically uploads product images from external URLs
- Presigned URLs: Generates temporary URLs for secure image access (1-hour expiry)
- Image Download: Provides download links with proper content disposition
- Image Deletion: Removes images when products are deleted
- Bucket Management: Automatically creates the
food-deliverybucket if it doesn't exist
The MinIO integration is primarily used in the Catalog service for:
- Product Creation: Images are uploaded to MinIO when creating new products
- Product Retrieval: Presigned URLs are generated when fetching products
- Product Updates: Old images are replaced with new ones
- Product Deletion: Associated images are removed from storage
- MinIO API:
http://localhost:9000 - MinIO Console:
http://localhost:9001(admin/admin123) - Default Bucket:
food-delivery
The project includes a custom storage building block (BuildingBlocks.Storage) that provides:
// Upload image from URL
var (objectName, objectUrl) = await MinioBucket.SendImageAsync(imageUrl);
// Get presigned URL for viewing
var viewUrl = await MinioBucket.GetImageAsync(imageName);
// Get download URL
var downloadUrl = await MinioBucket.GetImageToDownload(imageName);
// Delete image
await MinioBucket.DeleteImageAsync(imageName);The application uses Nginx as a reverse proxy to serve the Angular frontend and route API requests to the appropriate backend services.
Docker Setup: The webapp service runs in a Docker container using Nginx to serve the Angular application and proxy API requests:
webapp:
image: webapp
build:
context: .
dockerfile: UserInterfaces/WebApplication/Dockerfile
container_name: webapp
environment:
- NODE_ENV=production
ports:
- "4001:80"
volumes:
- ./UserInterfaces/WebApplication/nginx.conf:/etc/nginx/conf.d/default.confStatic File Serving:
- Serves the compiled Angular application from
/usr/share/nginx/html - Implements Single Page Application (SPA) routing with fallback to
index.html - Optimized caching for static assets (JS, CSS, images) with 1-year expiry
API Proxying:
/api/*: Proxies to Gateway API (gatewayapi:8080)/auth/*: Proxies to Keycloak authentication (keycloak:8080)
Security & Performance:
- Security headers (X-Frame-Options, X-Content-Type-Options, X-XSS-Protection)
- Gzip compression for text-based assets
- Request buffering optimization for better performance
- Health check endpoint at
/health
Error Handling:
- Minimized log noise with critical-level error logging only
- Suppressed SSL handshake failure logs
- Proper HTTP headers for proxied requests
- Web Application:
http://localhost:4001 - API Gateway (via proxy):
http://localhost:4001/api/ - Keycloak (via proxy):
http://localhost:4001/auth/ - Health Check:
http://localhost:4001/health
The Dockerfile uses a multi-stage build process:
- Build Stage: Uses Node.js 20 Alpine to compile the Angular application
- Runtime Stage: Uses Nginx Alpine to serve the compiled application
- Custom Configuration: Mounts the custom
nginx.conffor optimized routing and proxying
- Docker Desktop
- .NET 9 SDK
- Node.js (for Angular frontend)
- Clone the repository
git clone <repository-url>
cd FoodDelivery- Start all services with Docker Compose
cd src
docker-compose up -d- Access the services
- Web Application:
http://localhost:4001 - Gateway API:
http://localhost:6004 - Catalog API:
http://localhost:6000 - Basket API:
http://localhost:6001 - Discount gRPC:
http://localhost:6002 - Ordering API:
http://localhost:6003 - Keycloak:
http://localhost:6005 - MinIO Console:
http://localhost:9001 - RabbitMQ Management:
http://localhost:15672
- Web Application:
| Service | HTTP Port | HTTPS Port | Database Port |
|---|---|---|---|
| Web Application (Nginx) | 4001 | - | - |
| Catalog API | 6000 | 6060 | 5432 |
| Basket API | 6001 | 6061 | 5433 |
| Discount gRPC | 6002 | 6062 | - |
| Ordering API | 6003 | 6063 | 1433 |
| Gateway API | 6004 | 6064 | - |
| Keycloak | 6005 | - | 5434 |
| MinIO API | 9000 | - | - |
| MinIO Console | 9001 | - | - |
| Redis | 6379 | - | - |
| RabbitMQ | 5672 | - | - |
| RabbitMQ Management | 15672 | - | - |
- MinIO: admin / admin123
- Keycloak: admin / admin
- RabbitMQ: guest / guest
- Databases: postgres / postgres (PostgreSQL), sa / Password123 (SQL Server)
src/
βββ BuildingBlocks/ # Shared libraries
β βββ BuildingBlocks/ # Common utilities and exceptions
β βββ BuildingBlocks.Mediator/ # MediatR configuration
β βββ BuildingBlocks.Messaging/ # Event handling
β βββ BuildingBlocks.Storage/ # MinIO storage abstraction
βββ Services/ # Microservices
β βββ Catalog/ # Product catalog management
β βββ Basket/ # Shopping cart functionality
β βββ Discount/ # Discount and coupon service
β βββ Ordering/ # Order processing
βββ Gateways/
β βββ GatewayApi/ # API Gateway
βββ UserInterfaces/
β βββ WebApplication/ # Angular frontend
βββ docker-compose.yml # Container orchestration
The project includes API testing collections in the docs/bruno/ directory for testing all endpoints across different services.
- Port Mapping: See
docs/port-mapping.mdfor detailed port configurations - API Collections: Bruno API testing collections available in
docs/bruno/
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.