1.8 KiB
1.8 KiB
Microservices Development - GEMINI.md
This directory contains the .NET 8 microservices for the backend.
Core Mandates
- Framework: ASP.NET Core 8.0+.
- Database: MongoDB (via
MongoDB.Driver). - Authentication: JWT (Bearer token).
- Communication: REST APIs (HTTP).
- Naming Conventions:
- Namespace:
[ServiceName]Api(e.g.,AuthApi). - Project:
[ServiceName]Api.csproj. - Classes/Methods:
PascalCase. - DTOs/Models:
PascalCasewith meaningful suffixes (e.g.,UserCreateRequest).
- Namespace:
Project Structure
Each microservice follows a standard layout:
Controllers/: API endpoint definitions.Models/: Database entities and DTOs.Services/: Business logic and data access (e.g.,UserService.cs).Properties/: Configuration and launch settings.k8s/: Kubernetes manifests for the service.DOCUMENTS.md: Crucial for tracking API and document shapes.
Best Practices
- Dependency Injection: Use
AddSingletonfor long-lived services like database clients/wrappers andAddScopedfor per-request logic. - Async/Await: Use asynchronous operations for all I/O bound tasks (DB, HTTP).
- Security:
- Never hardcode secrets; use
IConfigurationand environment variables. - Use
Bcrypt.Net-Nextfor password hashing. - Ensure all sensitive endpoints are protected by
[Authorize].
- Never hardcode secrets; use
- API Documentation: Always maintain Swagger/OpenAPI documentation. Swagger should be available at
/swaggerin development and potentially production environments. - Logging: Use structured logging (standard
ILoggeror Serilog).
Maintenance
- Update
DOCUMENTS.mdwhenever you change a database schema or API request/response shape. - Ensure
Dockerfileandk8s/manifests are kept in sync with code changes. - All microservices are unified under the
micro-services.slnsolution file.