43 lines
1.8 KiB
Markdown
43 lines
1.8 KiB
Markdown
# 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: `PascalCase` with meaningful suffixes (e.g., `UserCreateRequest`).
|
|
|
|
## 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 `AddSingleton` for long-lived services like database clients/wrappers and `AddScoped` for per-request logic.
|
|
- **Async/Await**: Use asynchronous operations for all I/O bound tasks (DB, HTTP).
|
|
- **Security**:
|
|
- Never hardcode secrets; use `IConfiguration` and environment variables.
|
|
- Use `Bcrypt.Net-Next` for password hashing.
|
|
- Ensure all sensitive endpoints are protected by `[Authorize]`.
|
|
- **API Documentation**: Always maintain Swagger/OpenAPI documentation. Swagger should be available at `/swagger` in development and potentially production environments.
|
|
- **Logging**: Use structured logging (standard `ILogger` or Serilog).
|
|
|
|
## Maintenance
|
|
|
|
- Update `DOCUMENTS.md` whenever you change a database schema or API request/response shape.
|
|
- Ensure `Dockerfile` and `k8s/` manifests are kept in sync with code changes.
|
|
- All microservices are unified under the `micro-services.sln` solution file.
|