Skip to main content

Documentation 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.

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 dedicated 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

1

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:
EntityKey Fields
UserEmail, FullName, PasswordHash, RefreshToken, RefreshTokenExpiryTime
VehicleUserId, Make, Model, Year, Cylinders, EngineType, FuelType, Color
FuelLogVehicleId, FillUpDate, DistanceTraveledKm, VolumeLiters, TotalCostMxn, odometer/volume/currency flags, AppliedExchangeRate, IsFullTank, Notes
ExchangeRateDate (DateOnly), UsdToMxnRate
ErrorLogOriginLayer, MainObject, MethodName, ErrorMessage, ErrorDate, IncidentNumber, optional UserId
SystemResponseCode, MessageEs, MessageEn — catalog of controlled error codes and localized messages
All entities inherit from 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.
2

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 interfacesIFuelLogService, IVehicleService, IExchangeRateService, IDashboardService, and IJwtService are defined in Interfaces/Services/.
  • Service implementationsFuelLogService, VehicleService, ExchangeRateService, and DashboardService are implemented directly in AutoLog.Application/Services/, keeping business logic in the Application layer. Only JwtService lives in AutoLog.Infrastructure, as token signing is an infrastructure concern.
  • Repository interfacesIUserRepository, IVehicleRepository, IFuelLogRepository, and IExchangeRateRepository abstract all database access.
  • MediatR commands — Auth operations (RegisterUserCommand, LoginUserCommand, RefreshTokenCommand) use the MediatR CQRS pattern, keeping handler logic self-contained and independently testable.
3

AutoLog.Infrastructure — External Concerns

Implements everything that touches the outside world — the database, tokens, and third-party HTTP calls.
  • ApplicationDbContext — EF Core DbContext wired to PostgreSQL via Npgsql. Migration history lives in Data/Migrations/.
  • Repository implementations — Concrete classes (UserRepository, VehicleRepository, FuelLogRepository, ExchangeRateRepository) fulfill the interfaces declared in AutoLog.Application.
  • JwtService — Signs and validates JWTs, issues 15-minute access tokens and 7-day refresh tokens using a symmetric key injected from configuration.
  • DofIntegrationService — An HttpClient-based service that fetches live USD/MXN exchange rates from the Banco de México DOF (Diario Oficial de la Federación) API, satisfying IDofIntegrationService.
4

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.
  • ControllersAuthController, VehiclesController, FuelLogsController, ExchangeRatesController, ExternalRatesController, and DashboardController map HTTP verbs to application services.
  • Scalar API Reference — In Development mode, /scalar/v1 renders an interactive API explorer with the DeepSpace theme and a C# HttpClient code sample generator.
  • GlobalExceptionHandler middleware — A centralized IExceptionHandler implementation that converts domain exceptions and unhandled errors into RFC 7807 ProblemDetails responses, keeping controllers free of try/catch boilerplate.
  • CORS — The AllowAngularClient policy reads allowed origins from configuration (defaulting to http://localhost:4200 in development) so no origin is ever hardcoded.

Frontend Structure

AutoLog’s Angular 20 frontend uses standalone components exclusively — there are no NgModule 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 JWT Authorization: Bearer header to every outbound request and handles 401 responses by triggering a silent token refresh via RefreshTokenCommand.
    • shared/ui/ — Shared PrimeNG import bundles and reusable UI configuration used across features.
  • features/ — One subdirectory per application domain:
    • auth/login/ and register/ standalone components with PrimeNG form controls.
    • dashboard/ — Summary statistics and trend data derived from the IDashboardService response.
    • 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).

Project Directory Tree

AutoLog/
├── backend/
│   └── src/
│       ├── AutoLog.API/
│       │   ├── Controllers/
│       │   │   ├── AuthController.cs
│       │   │   ├── DashboardController.cs
│       │   │   ├── ExchangeRatesController.cs
│       │   │   ├── ExternalRatesController.cs
│       │   │   ├── FuelLogsController.cs
│       │   │   └── VehiclesController.cs
│       │   ├── Middlewares/
│       │   │   └── GlobalExceptionHandler.cs
│       │   ├── appsettings.json
│       │   └── Program.cs
│       ├── AutoLog.Application/
│       │   ├── DTOs/
│       │   │   ├── Auth/
│       │   │   ├── Dashboard/
│       │   │   ├── ExchangeRate/
│       │   │   ├── FuelLog/
│       │   │   └── Vehicles/
│       │   ├── Features/
│       │   │   └── Auth/
│       │   │       └── Commands/
│       │   │           ├── LoginUserCommand.cs
│       │   │           ├── RefreshTokenCommand.cs
│       │   │           └── RegisterUserCommand.cs
│       │   ├── Interfaces/
│       │   │   ├── Repositories/
│       │   │   │   ├── IExchangeRateRepository.cs
│       │   │   │   ├── IFuelLogRepository.cs
│       │   │   │   ├── IUserRepository.cs
│       │   │   │   └── IVehicleRepository.cs
│       │   │   └── Services/
│       │   │       ├── IDashboardService.cs
│       │   │       ├── IExchangeRateService.cs
│       │   │       ├── IFuelLogService.cs
│       │   │       ├── IJwtService.cs
│       │   │       └── IVehicleService.cs
│       │   └── Services/
│       │       ├── DashboardService.cs
│       │       ├── ExchangeRateService.cs
│       │       ├── FuelLogService.cs
│       │       └── VehicleService.cs
│       ├── AutoLog.Domain/
│       │   ├── Entities/
│       │   │   ├── BaseEntity.cs
│       │   │   ├── ErrorLog.cs
│       │   │   ├── ExchangeRate.cs
│       │   │   ├── FuelLog.cs
│       │   │   ├── SystemResponse.cs
│       │   │   ├── User.cs
│       │   │   └── Vehicle.cs
│       │   └── Exceptions/
│       │       └── CustomAppException.cs
│       └── AutoLog.Infrastructure/
│           ├── Authentication/
│           │   └── JwtService.cs
│           ├── Data/
│           │   ├── ApplicationDbContext.cs
│           │   └── Migrations/
│           ├── Integrations/
│           │   └── DOF/
│           │       ├── Interfaces/
│           │       │   └── IDofIntegrationService.cs
│           │       └── Services/
│           │           └── DofIntegrationService.cs
│           └── Repositories/
│               ├── ExchangeRateRepository.cs
│               ├── FuelLogRepository.cs
│               ├── UserRepository.cs
│               └── VehicleRepository.cs
└── frontend/
    └── src/
        └── app/
            ├── core/
            │   ├── guards/
            │   │   └── auth-guard.ts
            │   ├── interceptors/
            │   │   └── auth.interceptor.ts
            │   ├── models/
            │   ├── services/
            │   │   ├── auth.ts
            │   │   ├── dashboard.ts
            │   │   ├── exchange-rate.ts
            │   │   ├── fuel-log.ts
            │   │   └── vehicle.ts
            │   └── shared/ui/
            │       └── primeng-imports.ts
            ├── features/
            │   ├── auth/
            │   │   ├── login/
            │   │   └── register/
            │   ├── dashboard/
            │   │   └── dashboard/
            │   ├── exchange-rates/
            │   │   └── exchange-rate-list/
            │   ├── fuel-logs/
            │   │   └── fuel-log-list/
            │   └── vehicles/
            │       └── vehicle-list/
            └── layout/
                └── main-layout/

Build docs developers (and LLMs) love