AutoLog follows a Modular Monolith architecture grounded in Domain-Driven Design (DDD). The backend is divided into four discrete C# projects that enforce a strict inward-facing dependency rule: outer layers depend on inner layers, never the reverse. The Angular 20 frontend mirrors this discipline with a feature-based directory structure where shared concerns live in a dedicatedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JReyna217/AutoLog/llms.txt
Use this file to discover all available pages before exploring further.
core/ module. The result is a codebase that is easy to navigate, straightforward to test in isolation, and ready to be split into microservices if the need arises.
Backend Layer Breakdown
AutoLog.Domain — The Core
The innermost layer. It has zero dependencies on any other AutoLog project or third-party framework. Everything here is plain C# that describes the business reality of the application.Entities:
All entities inherit from
| Entity | Key Fields |
|---|---|
User | Email, FullName, PasswordHash, RefreshToken, RefreshTokenExpiryTime |
Vehicle | UserId, Make, Model, Year, Cylinders, EngineType, FuelType, Color |
FuelLog | VehicleId, FillUpDate, DistanceTraveledKm, VolumeLiters, TotalCostMxn, odometer/volume/currency flags, AppliedExchangeRate, IsFullTank, Notes |
ExchangeRate | Date (DateOnly), UsdToMxnRate |
ErrorLog | OriginLayer, MainObject, MethodName, ErrorMessage, ErrorDate, IncidentNumber, optional UserId |
SystemResponse | Code, MessageEs, MessageEn — catalog of controlled error codes and localized messages |
BaseEntity, which provides a standard integer primary key, CreatedAt, UpdatedAt, and a soft-delete IsDeleted flag. The layer also contains domain exceptions (CustomAppException) used to signal business-rule violations up through the call stack without leaking infrastructure concerns.AutoLog.Application — Use Cases and Contracts
The orchestration layer. It references
AutoLog.Domain and defines everything the application can do, but contains no framework code.- DTOs — Separate request/response objects for Auth, Dashboard, ExchangeRate, FuelLog, and Vehicles, decoupling API contracts from entity shapes.
- Service interfaces —
IFuelLogService,IVehicleService,IExchangeRateService,IDashboardService, andIJwtServiceare defined inInterfaces/Services/. - Service implementations —
FuelLogService,VehicleService,ExchangeRateService, andDashboardServiceare implemented directly inAutoLog.Application/Services/, keeping business logic in the Application layer. OnlyJwtServicelives inAutoLog.Infrastructure, as token signing is an infrastructure concern. - Repository interfaces —
IUserRepository,IVehicleRepository,IFuelLogRepository, andIExchangeRateRepositoryabstract all database access. - MediatR commands — Auth operations (
RegisterUserCommand,LoginUserCommand,RefreshTokenCommand) use the MediatR CQRS pattern, keeping handler logic self-contained and independently testable.
AutoLog.Infrastructure — External Concerns
Implements everything that touches the outside world — the database, tokens, and third-party HTTP calls.
ApplicationDbContext— EF CoreDbContextwired to PostgreSQL via Npgsql. Migration history lives inData/Migrations/.- Repository implementations — Concrete classes (
UserRepository,VehicleRepository,FuelLogRepository,ExchangeRateRepository) fulfill the interfaces declared inAutoLog.Application. JwtService— Signs and validates JWTs, issues 15-minute access tokens and 7-day refresh tokens using a symmetric key injected from configuration.DofIntegrationService— AnHttpClient-based service that fetches live USD/MXN exchange rates from the Banco de México DOF (Diario Oficial de la Federación) API, satisfyingIDofIntegrationService.
AutoLog.API — Delivery Layer
The outermost layer; the only project that runs as an executable. It wires everything together in
Program.cs and exposes HTTP endpoints.- Controllers —
AuthController,VehiclesController,FuelLogsController,ExchangeRatesController,ExternalRatesController, andDashboardControllermap HTTP verbs to application services. - Scalar API Reference — In Development mode,
/scalar/v1renders an interactive API explorer with the DeepSpace theme and a C#HttpClientcode sample generator. GlobalExceptionHandlermiddleware — A centralizedIExceptionHandlerimplementation that converts domain exceptions and unhandled errors into RFC 7807ProblemDetailsresponses, keeping controllers free of try/catch boilerplate.- CORS — The
AllowAngularClientpolicy reads allowed origins from configuration (defaulting tohttp://localhost:4200in development) so no origin is ever hardcoded.
Frontend Structure
AutoLog’s Angular 20 frontend uses standalone components exclusively — there are noNgModule declarations. The src/app/ directory is organized by concern:
-
core/— Application-wide singletons and cross-cutting infrastructure:services/— Injectable services for Auth, Vehicles, FuelLogs, ExchangeRates, and Dashboard that wrap the HTTP calls to the backend API.models/— TypeScript interfaces mirroring the backend DTOs.guards/— Route guard (authGuard) that redirects unauthenticated users to the login page.interceptors/— An HTTP interceptor (authInterceptor) that attaches the JWTAuthorization: Bearerheader to every outbound request and handles 401 responses by triggering a silent token refresh viaRefreshTokenCommand.shared/ui/— Shared PrimeNG import bundles and reusable UI configuration used across features.
-
features/— One subdirectory per application domain:auth/—login/andregister/standalone components with PrimeNG form controls.dashboard/— Summary statistics and trend data derived from theIDashboardServiceresponse.fuel-logs/—fuel-log-list/with an inline form for adding new fill-up records.exchange-rates/—exchange-rate-list/that surfaces the historical rate catalog and the DOF live-fetch action.vehicles/—vehicle-list/for registering and managing vehicles.
-
layout/—main-layout/provides the application shell: a persistent top nav and a sidebar that auto-collapses on mobile viewports for a fully responsive experience.
Key Design Decisions
MediatR CQRS for Auth
Authentication commands (
RegisterUserCommand, LoginUserCommand, RefreshTokenCommand) are dispatched through MediatR. Each handler is a self-contained unit with its own dependencies, making auth logic easy to unit-test and simple to extend with pipeline behaviors (e.g., validation, logging) without touching the controllers.Repository Pattern
All database access flows through interfaces defined in
AutoLog.Application. Controllers and services never reference ApplicationDbContext directly, ensuring that the persistence implementation can be swapped or mocked without cascading changes across the codebase.Short-lived JWT + Refresh Tokens
Access tokens expire after 15 minutes (
JwtSettings:ExpiryMinutes). Refresh tokens are valid for 7 days (JwtSettings:RefreshExpiryDays) and are stored on the User entity. The Angular interceptor handles silent renewal transparently, so users are never interrupted mid-session.DOF Exchange Rate Integration
The
DofIntegrationService fetches live USD/MXN exchange rates from the Banco de México DOF API. Rates are persisted in the ExchangeRate table so that historical fill-ups always reflect the rate that was in effect on that date, even if the live rate changes later.Normalized Storage (km + MXN)
Regardless of the units entered (miles or km, gallons or liters, USD or MXN), all values are converted to kilometers and Mexican pesos before being written to the database. Original input values and conversion flags are preserved in separate columns so the UI can display data in the user’s preferred units while analytics always work on a consistent base.
Environment-injected Secrets
No secrets exist in the repository.
appsettings.json ships with empty strings for DefaultConnection and JwtSettings:Secret. In development, the .NET Secret Manager fills these in. In production Docker containers, they are injected as environment variables using the double-underscore key-path convention (ConnectionStrings__DefaultConnection).