How hargata/lubelog works
Project Type and Purpose
• This is a full-stack, web-based, self-hosted vehicle maintenance and fuel mileage tracker built with ASP.NET Core MVC.
• It serves HTML/JS/CSS to a browser, processes user actions in Controllers, applies domain logic, and persists data to a database (LiteDB or PostgreSQL).
• Key use-cases: user authentication (including OpenID Connect), CRUD over vehicle records (gas, service, reminders, etc.), reporting (charts), file uploads, import/export, and email notifications.
Architectural Layers and Components
a. Presentation Layer (Frontend)
• Browser clients load HTML views (Razor .cshtml) served by the ASP.NET app.
• Static assets under wwwroot: CSS, JS (jQuery, Bootstrap, Chart.js, Drawdown, SweetAlert2, Masonry, date-picker).
• Views are organized per area (Home, Login, Vehicle, Admin, API, Migration, Shared).
b. Web Application Layer (ASP.NET Core MVC)
• Program.cs + Startup configuration -> Middleware pipeline (middleware/Authen.cs for authentication).
• Controllers folder: one controller per function/area, delegating to Logic.
c. Business Logic Layer
• Logic folder: classes encapsulating domain rules and orchestration (e.g., VehicleLogic, UserLogic, OdometerLogic, LoginLogic).
• MapProfile: AutoMapper profiles for mapping between Models and database entities.
d. Data Access Layer (Repository Pattern)
• External/Interfaces: repositories interfaces (e.g., IVehicleDataAccess, I**RecordDataAccess).
• External/Implementations:
– LiteDB implementation classes (persist to embedded LiteDB).
– Postgres implementation classes (persist via Npgsql).
• Dependency Injection resolves interfaces to the chosen implementation at runtime.
e. Domain Models and View Models
• Models folder: domain entities, input/edit/view models for UI, config models (MailConfig, ServerConfig), API models, OperationResponse.
f. Infrastructure and Helpers
• Helper folder: utility classes for configuration, file handling, emailing (MailKit), reporting, translations, etc.
• Filter folder: MVC action filters (e.g., CollaboratorFilter).
g. External Services / Integrations
• SMTP server via MailKit for email reminders.
• Optional external OpenID Connect provider (Models/OIDC).
• Docker containers (Postgres, Traefik) or Windows standalone.
• Kubernetes Helm chart support.
h. Database
• Two supported backends: embedded LiteDB (file storage) or PostgreSQL (server).
• init.sql for schema initialization when using Postgres.
• Connection config in appsettings.json / appsettings.Development.json.
• Inside, show the Middleware pipeline.
• Controllers → Business Logic → Data Access interfaces → Data Access implementations.
• Static file server serving wwwroot assets.
3. Below Business Logic, show MapProfile (mapping) and Helper utilities.
• LiteDB file (local .db file)
• PostgreSQL server (container or external host)
5. Above/in parallel to DB, show External Services:
• SMTP Mail server
• (Optional) OpenID Connect provider (for external authentication)
6. At the bottom, include Infrastructure:
• Docker / Traefik reverse proxy
• Kubernetes (Helm)
• CI/CD workflow (.github/workflows build-and-push-image.yml)
Relationships and Data Flow
• Browser → Traefik (optional) → ASP.NET Middleware → Controllers.
• Controllers call Logic classes.
• Logic uses repository interfaces to fetch/persist data.
• Repository implementations write to LiteDB file or PostgreSQL.
• Logic may invoke Helper.MailHelper → SMTP.
• Logic may invoke MapProfile (AutoMapper) → Models / ViewModels.
• Controllers return Razor views or JSON (APIController).
Key Architectural Patterns
• MVC: clear separation of Models, Views, Controllers.
• Repository Pattern & Dependency Injection: decouple business logic from data storage.
• Middleware pipeline for cross-cutting concerns (authentication, error handling).
• AutoMapper for model mapping.
• Modular areas (Admin, API, Migration, Vehicle sub-areas).
Technologies and Frameworks
• ASP.NET Core MVC, Razor.
• LiteDB & Npgsql (PostgreSQL).
• Bootstrap (UI), Bootstrap-DatePicker, SweetAlert2, Chart.js, Drawdown, Masonry.
• MailKit (SMTP).
• Docker, Traefik, GitHub Actions, Helm (Kubernetes).
• CSV import via CsvHelper.