# lele97/carmaintenance architecture

> Architecture diagram of the GitHub repository lele97/carmaintenance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lele97/carmaintenance
- Repository: https://github.com/lele97/carmaintenance

## Overview

CarMaintenance records vehicle maintenance and presents a dashboard for browsing history, costs, and reminders. The server-rendered workflow routes browser requests through Express to maintenance handlers, validates submissions, persists MongoDB-backed records, and renders Pug pages or JSON. Production also supports a browser-local storage mode with CRUD, statistics, filtering, and export; that client-side branch is documented and represented by its JavaScript modules, though their internal call wiring was not sampled. The diagram focuses on relationships evidenced by excerpts or README; client-side connections are left unverified.

Main entry points: [`services/interventionService.js`](https://github.com/lele97/carmaintenance/blob/master/services/interventionService.js) (Intervention service), [`app.js`](https://github.com/lele97/carmaintenance/blob/master/app.js) (Express application), [`routes/index.js`](https://github.com/lele97/carmaintenance/blob/master/routes/index.js) (Dashboard route), [`routes/add.js`](https://github.com/lele97/carmaintenance/blob/master/routes/add.js) (Add route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_express["Express application<br/>[app.js]"]
  node_dashboard["Dashboard route<br/>[index.js]"]
  node_entry["Add route<br/>[add.js]"]
  node_edit["Update route<br/>[update.js]"]
  node_api["REST API<br/>[api.js]"]
  node_data["Data endpoints<br/>[data.js]"]
  node_delete["Delete route<br/>[delete.js]"]
  node_templates["Pug pages"]
end

subgraph group_domain["Maintenance domain"]
  node_validator["Payload validation<br/>[validator.js]"]
  node_service["Intervention service"]
  node_stats["Stats and reminders"]
  node_model["Intervention schema<br/>[Intervention.js]"]
end

subgraph group_storage["Persistence modes"]
  node_mode["Storage mode selector<br/>[storageMode.js]"]
  node_dbconfig["MongoDB connection<br/>[database.js]"]
  node_mongo[("MongoDB")]
end

subgraph group_client["Browser application"]
  node_dashboardjs["Dashboard interactions<br/>[dashboard.js]"]
  node_localstorage["Browser storage<br/>[storage.js]"]
  node_mileage["Mileage readings<br/>[mileageReadings.js]"]
end

node_driver(("Car owner"))
node_browser(("Browser"))

node_browser -->|"sends requests"| node_express
node_express -->|"routes requests"| node_dashboard
node_express -->|"routes requests"| node_entry
node_express -->|"routes requests"| node_edit
node_express -->|"routes requests"| node_api
node_express -->|"routes requests"| node_data
node_express -->|"routes requests"| node_delete
node_dashboard -->|"queries records"| node_service
node_dashboard -->|"calculates dashboard"| node_stats
node_dashboard -->|"renders dashboard"| node_templates
node_entry -->|"validates input"| node_validator
node_entry -->|"creates records"| node_service
node_entry -->|"renders form"| node_templates
node_edit -->|"validates input"| node_validator
node_edit -->|"reads and updates"| node_service
node_edit -->|"renders edit"| node_templates
node_api -->|"validates input"| node_validator
node_api -->|"manages records"| node_service
node_data -->|"queries records"| node_service
node_data -->|"exports statistics"| node_stats
node_delete -->|"deletes records"| node_service
node_service -->|"queries and writes"| node_model
node_service -->|"checks connection"| node_dbconfig
node_model -.->|"persists records"| node_mongo
node_dashboard -->|"selects mode"| node_mode
node_api -->|"reports mode"| node_mode
node_dbconfig -->|"connects"| node_mongo
node_browser -.->|"uses dashboard"| node_dashboardjs
node_dashboardjs -.->|"uses local CRUD"| node_localstorage
node_dashboardjs -.->|"uses readings"| node_mileage
node_localstorage -.->|"stores locally"| node_browser

click node_express "https://github.com/lele97/carmaintenance/blob/master/app.js"
click node_dashboard "https://github.com/lele97/carmaintenance/blob/master/routes/index.js"
click node_entry "https://github.com/lele97/carmaintenance/blob/master/routes/add.js"
click node_edit "https://github.com/lele97/carmaintenance/blob/master/routes/update.js"
click node_api "https://github.com/lele97/carmaintenance/blob/master/routes/api.js"
click node_data "https://github.com/lele97/carmaintenance/blob/master/routes/data.js"
click node_delete "https://github.com/lele97/carmaintenance/blob/master/routes/delete.js"
click node_templates "https://github.com/lele97/carmaintenance/tree/master/views"
click node_validator "https://github.com/lele97/carmaintenance/blob/master/utils/validator.js"
click node_service "https://github.com/lele97/carmaintenance/blob/master/services/interventionService.js"
click node_stats "https://github.com/lele97/carmaintenance/blob/master/services/interventionService.js"
click node_model "https://github.com/lele97/carmaintenance/blob/master/models/Intervention.js"
click node_mode "https://github.com/lele97/carmaintenance/blob/master/utils/storageMode.js"
click node_dbconfig "https://github.com/lele97/carmaintenance/blob/master/config/database.js"
click node_dashboardjs "https://github.com/lele97/carmaintenance/blob/master/public/javascripts/dashboard.js"
click node_localstorage "https://github.com/lele97/carmaintenance/blob/master/public/javascripts/storage.js"
click node_mileage "https://github.com/lele97/carmaintenance/blob/master/public/javascripts/mileageReadings.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_express,node_dashboard,node_entry,node_edit,node_api,node_data,node_delete,node_templates,node_browser toneBlue
class node_validator,node_service,node_stats,node_model toneAmber
class node_mode,node_dbconfig,node_mongo toneMint
class node_dashboardjs,node_localstorage,node_mileage toneRose
class node_driver toneIndigo
```

## Components

### Web interface

- [Express application](https://github.com/lele97/carmaintenance/blob/master/app.js): `app.js`
- [Dashboard route](https://github.com/lele97/carmaintenance/blob/master/routes/index.js): `routes/index.js`
- [Add route](https://github.com/lele97/carmaintenance/blob/master/routes/add.js): `routes/add.js`
- [Update route](https://github.com/lele97/carmaintenance/blob/master/routes/update.js): `routes/update.js`
- [REST API](https://github.com/lele97/carmaintenance/blob/master/routes/api.js): `routes/api.js`
- [Data endpoints](https://github.com/lele97/carmaintenance/blob/master/routes/data.js): `routes/data.js`
- [Delete route](https://github.com/lele97/carmaintenance/blob/master/routes/delete.js): `routes/delete.js`
- [Pug pages](https://github.com/lele97/carmaintenance/tree/master/views): `views`

### Maintenance domain

- [Payload validation](https://github.com/lele97/carmaintenance/blob/master/utils/validator.js): `utils/validator.js`
- [Intervention service](https://github.com/lele97/carmaintenance/blob/master/services/interventionService.js): `services/interventionService.js`
- [Stats and reminders](https://github.com/lele97/carmaintenance/blob/master/services/interventionService.js): `services/interventionService.js`
- [Intervention schema](https://github.com/lele97/carmaintenance/blob/master/models/Intervention.js): `models/Intervention.js`

### Persistence modes

- [Storage mode selector](https://github.com/lele97/carmaintenance/blob/master/utils/storageMode.js): `utils/storageMode.js`
- [MongoDB connection](https://github.com/lele97/carmaintenance/blob/master/config/database.js): `config/database.js`
- **MongoDB**

### Browser application

- [Dashboard interactions](https://github.com/lele97/carmaintenance/blob/master/public/javascripts/dashboard.js): `public/javascripts/dashboard.js`
- [Browser storage](https://github.com/lele97/carmaintenance/blob/master/public/javascripts/storage.js): `public/javascripts/storage.js`
- [Mileage readings](https://github.com/lele97/carmaintenance/blob/master/public/javascripts/mileageReadings.js): `public/javascripts/mileageReadings.js`

### Other components

- **Car owner**
- **Browser**

## Connections

- Browser → Express application: sends requests (evidence: `app.js`)
- Express application → Dashboard route: routes requests (evidence: `app.js`)
- Express application → Add route: routes requests (evidence: `app.js`)
- Express application → Update route: routes requests (evidence: `app.js`)
- Express application → REST API: routes requests (evidence: `app.js`)
- Express application → Data endpoints: routes requests (evidence: `app.js`)
- Express application → Delete route: routes requests (evidence: `app.js`)
- Dashboard route → Intervention service: queries records (evidence: `routes/index.js`)
- Dashboard route → Stats and reminders: calculates dashboard (evidence: `routes/index.js`)
- Dashboard route → Pug pages: renders dashboard (evidence: `routes/index.js`)
- Add route → Payload validation: validates input (evidence: `routes/add.js`)
- Add route → Intervention service: creates records (evidence: `routes/add.js`)
- Add route → Pug pages: renders form (evidence: `routes/add.js`)
- Update route → Payload validation: validates input (evidence: `routes/update.js`)
- Update route → Intervention service: reads and updates (evidence: `routes/update.js`)
- Update route → Pug pages: renders edit (evidence: `routes/update.js`)
- REST API → Payload validation: validates input (evidence: `routes/api.js`)
- REST API → Intervention service: manages records (evidence: `routes/api.js`)
- Data endpoints → Intervention service: queries records (evidence: `routes/data.js`)
- Data endpoints → Stats and reminders: exports statistics (evidence: `routes/data.js`)
- Delete route → Intervention service: deletes records (evidence: `routes/delete.js`)
- Intervention service → Intervention schema: queries and writes (evidence: `services/interventionService.js`)
- Intervention service → MongoDB connection: checks connection (evidence: `services/interventionService.js`)
- Intervention schema → MongoDB: persists records
- Dashboard route → Storage mode selector: selects mode (evidence: `routes/index.js`)
- REST API → Storage mode selector: reports mode (evidence: `routes/api.js`)
- MongoDB connection → MongoDB: connects (evidence: `config/database.js`)
- Browser → Dashboard interactions: uses dashboard
- Dashboard interactions → Browser storage: uses local CRUD
- Dashboard interactions → Mileage readings: uses readings
- Browser storage → Browser: stores locally
