This project is a microservices-based e-commerce application built with .NET 8.0. The implementation includes multiple microservices: Catalog, Basket, Ordering, and Discount services.
- .NET 8.0 - Core framework for all microservices
- ASP.NET Core Web API - REST API endpoints
- gRPC - Inter-service communication (Discount service)
- MediatR - CQRS pattern implementation
- Entity Framework Core - ORM for SQL Server (Ordering service)
- Dapper - Micro-ORM for PostgreSQL (Discount service)
- MongoDB - Document database for Catalog service
- Redis - In-memory cache for Basket service
- SQL Server - Relational database for Ordering service
- PostgreSQL - Relational database for Discount service
- RabbitMQ - Message bus for event-driven communication
- MassTransit - Distributed application framework for message-based systems
- Swagger/OpenAPI - API documentation and testing interface
- API Versioning - Version management for REST APIs
- Serilog - Structured logging across all services
- Docker - Containerization platform
- Docker Compose - Multi-container application orchestration
- Visual Studio 2022 / VS Code - IDE support
- Git - Version control
- Postman - API testing (optional)
- Gemini CLI - AI-powered project analysis and documentation
- Microservices Architecture - Service decomposition
- CQRS (Command Query Responsibility Segregation) - Data access pattern
- Domain-Driven Design (DDD) - Domain modeling approach
- Event-Driven Architecture - Asynchronous communication
- Repository Pattern - Data access abstraction
- Clean Architecture - Layered application structure
E-Shop/
βββ Catalog.API/ # REST API endpoints and controllers
βββ Catalog.Application/ # Application logic, CQRS commands/queries
βββ Catalog.Core/ # Domain entities and interfaces
βββ Catalog.Infrastructure/ # Data access and implementations
- .NET 8.0 SDK
- Docker Desktop
- MongoDB (containerized)
- Start the containers:
docker compose -f docker-compose.yml -f docker-compose.override.yml up -d- Access Swagger UI:
http://localhost:8000/swagger
- GET
/api/v1/Catalog/GetAllProducts- Gets all products with optional filtering, sorting, and pagination
- Query Parameters:
PageIndex(int): Page number, starts at 1 (default: 1)PageSize(int): Number of items per page, max 70 (default: 10)BrandId(string): Filter by brand IDTypeId(string): Filter by product type IDSort(string): Sort parameter (e.g., "price_asc", "price_desc", "name_asc")Search(string): Search term to filter products
- Example:
/api/v1/Catalog/GetAllProducts?PageIndex=2&PageSize=20&BrandId=1&TypeId=2&Sort=price_asc&Search=gaming - Response Model:
{ "products": [ { "id": "string", "name": "string", "description": "string", "price": 0.0, "pictureUrl": "string", "productBrand": "string", "productType": "string" } ] }
- GET
/api/v1/Catalog/GetProductById/{id}- Parameters: id (string)
- Response Model:
{ "id": "string", "name": "string", "description": "string", "price": 0.0, "pictureUrl": "string", "productBrand": "string", "productType": "string" }
- GET
/api/v1/Catalog/GetProductByProductName/{productName}- Parameters: productName (string)
- Response Model: Same as Get Product By ID
- GET
/api/v1/Catalog/GetProductsByBrandName/{brand}- Parameters: brand (string)
- Response Model:
{ "products": [ { "id": "string", "name": "string", "description": "string", "price": 0.0, "pictureUrl": "string", "productBrand": "string", "productType": "string" } ] }
- POST
/api/v1/Catalog/CreateProduct- Request Model:
{ "name": "string", "description": "string", "price": 0.0, "pictureUrl": "string", "productBrand": "string", "productType": "string" } - Response Model:
{ "id": "string", "name": "string", "description": "string", "price": 0.0, "pictureUrl": "string", "productBrand": "string", "productType": "string" }
- Request Model:
- PUT
/api/v1/Catalog/UpdateProduct- Request Model:
{ "id": "string", "name": "string", "description": "string", "price": 0.0, "pictureUrl": "string", "productBrand": "string", "productType": "string" } - Response: 200 OK
- Request Model:
- DELETE
/api/v1/Catalog/{id}- Parameters: id (string)
- Response: 200 OK
- GET
/api/v1/Catalog/GetAllBrands- Response Model:
{ "brands": [ { "id": "string", "name": "string" } ] }
- Response Model:
- GET
/api/v1/Catalog/GetAllTypes- Response Model:
{ "types": [ { "id": "string", "name": "string" } ] }
- Response Model:
If you're encountering MongoDB connection issues when running the application from Visual Studio:
-
Make sure MongoDB is running in Docker with proper port mapping:
docker run --name mongodb -d -p 27017:27017 mongo:latest
-
Verify MongoDB Connection String:
- When running in Docker:
mongodb://catalogdb:27017 - When running on localhost:
mongodb://127.0.0.1:27017
- When running in Docker:
-
Check MongoDB logs:
docker logs mongodb
MongoDB connection settings in appsettings.json:
"DatabaseSettings": {
"ConnectionString": "mongodb://catalogdb:27017",
"DatabaseName": "CatalogDb",
"CollectionName": "Products",
"BrandsCollection": "Brands",
"TypesCollection": "Types"
}For local development (in appsettings.Development.json):
"DatabaseSettings": {
"ConnectionString": "mongodb://127.0.0.1:27017",
"DatabaseName": "CatalogDb",
"CollectionName": "Products",
"BrandsCollection": "Brands",
"TypesCollection": "Types"
}The application uses Docker Compose with two services:
- catalogdb: MongoDB instance
- catalog.api: .NET Web API application
To run the application in development mode:
- Build the containers:
docker compose build- Start the services:
docker compose -f docker-compose.yml -f docker-compose.override.yml up -d- Stop the services:
docker compose downThis project includes a custom Gemini CLI for AI-powered analysis and documentation generation.
- Get your Gemini API key from Google AI Studio
- Copy environment file:
cp tools/gemini-cli/.env.example .env
- Add your API key to
.env:GEMINI_API_KEY=your_gemini_api_key_here
# Analyze the entire project structure
npm run analyze
# Generate API documentation for services
npm run docs Catalog
npm run docs Basket
npm run docs Ordering
npm run docs Discount
# Generate test suggestions
npm run tests Catalog
# Optimize Dockerfiles
npm run optimize-docker
# Show help
node tools/gemini-cli/gemini-cli.js help- π Project Analysis: AI-powered architecture analysis
- π Documentation Generation: Automatic API documentation
- π§ͺ Test Suggestions: AI-generated test recommendations
- π³ Docker Optimization: Dockerfile analysis and suggestions
See tools/gemini-cli/CLI-README.md for detailed usage instructions.