# abrahdev/karter architecture

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

- Interactive diagram: https://gitdiagram.com/abrahdev/karter
- Repository: https://github.com/abrahdev/karter

## Overview

#### Purpose and Entry Points
Karter is an offline, privacy-first vehicle maintenance tracker. The primary product is a Flutter app launched from `mobile/lib/main.dart`, with native Android/iOS/Linux hosts under `mobile/android`, `mobile/ios`, and `mobile/linux`. A separate Docusaurus site publishes project and architecture documentation from `docs/`.

#### Application Layering
The mobile code follows a domain/data/presentation split:
- Domain entities, value objects, validation, errors, and repository contracts define business rules independently of UI/storage: `mobile/lib/domain/entities/vehicle.dart`, `mobile/lib/domain/value_objects/odometer.dart`, `mobile/lib/domain/repositories/vehicle_repository.dart`.
- Data implementations fulfill those contracts and own persistence/service integrations: `mobile/lib/data/repositories/vehicle_repository_impl.dart`, `mobile/lib/data/repositories/maintenance_log_repository_impl.dart`.
- Presentation pages, providers, and widgets render and coordinate user workflows: `mobile/lib/presentation/pages/home_page.dart`, `mobile/lib/presentation/providers/vehicle_providers.dart`.

#### Local Persistence and Core Records
The app stores data locally through its generated application database, preserving the no-account/no-telemetry boundary. The database supports vehicles, fuel logs, maintenance intervals/logs, and vehicle documents; repositories isolate database details from consumers. Core persistence paths are `mobile/lib/core/database/app_database.dart`, `mobile/lib/data/repositories/fuel_log_repository_impl.dart`, and `mobile/lib/data/repositories/vehicle_document_repository_impl.dart`.

#### User Workflows and State
The home/dashboard flow exposes per-vehicle operational data and navigates to forms/lists for fuel, maintenance, documents, and settings. Providers supply selected-vehicle and template-source state to the widget tree; pages should depend on domain/repository abstractions rather than directly on tables. Representative flow boundaries: `mobile/lib/presentation/pages/dashboard_page.dart`, `mobile/lib/presentation/pages/fuel_log_form_page.dart`, `mobile/lib/presentation/pages/maintenance_settings_page.dart`.

#### Maintenance Templates Pipeline
Versioned JSON vehicle templates provide seeded or resolved maintenance intervals by vehicle type, make, and model. Shared base templates are composed/resolved by mobile services, while Python tooling regenerates the repository index and template artifacts. Key contract/data paths: `templates/schemas/template-v1.json`, `templates/index.json`, `templates/data/_base/common-all.json`, `mobile/lib/data/services/template_resolver.dart`, `tools/generate_templates.py`.

#### Device Services and Outputs
Background processing and notifications support interval reminders; export services produce user-controlled data exports, including PDF export. These are local/device-facing integration boundaries rather than backend APIs: `mobile/lib/data/services/background_service.dart`, `mobile/lib/data/services/notification_service.dart`, `mobile/lib/data/services/export_service.dart`. No server-side application or account service is present in this repository.

#### Runtimes, Distribution, and Documentation
Flutter/Dart is the application runtime, built through Gradle/Kotlin on Android and Xcode/Swift on iOS; package dependencies are defined in `mobile/pubspec.yaml`. GitHub Actions provides CI, releases, documentation deployment, and template-index updates: `.github/workflows/ci.yml`, `.github/workflows/release.yml`, `.github/workflows/update-index.yml`. Documentation is a TypeScript/Docusaurus site configured at `docs/docusaurus.config.ts`, with versioned content under `docs/versioned_docs/`.

Main entry points: [`mobile/lib/presentation/pages/home_page.dart`](https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/home_page.dart) (Pages, providers & widgets), [`tools/generate_templates.py`](https://github.com/abrahdev/karter/blob/main/tools/generate_templates.py) (Template generator), [`mobile/lib/domain/repositories/vehicle_repository.dart`](https://github.com/abrahdev/karter/blob/main/mobile/lib/domain/repositories/vehicle_repository.dart) (Domain contracts & rules), [`mobile/lib/data/services/template_resolver.dart`](https://github.com/abrahdev/karter/blob/main/mobile/lib/data/services/template_resolver.dart) (Template resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Flutter Mobile App"]
  node_app_entry["Flutter entry point<br/>app bootstrap<br/>[main.dart]"]
  node_presentation["Pages, providers &amp; widgets<br/>presentation layer<br/>[home_page.dart]"]
  node_dashboard["Vehicle dashboard<br/>workflow page"]
  node_fuel_form["Fuel log workflow<br/>workflow page"]
  node_maintenance_settings["Maintenance settings<br/>workflow page"]
  node_providers["Vehicle state providers<br/>state management"]
  node_domain{{"Domain contracts &amp; rules<br/>domain layer"}}
  node_data_repositories["Repository implementations<br/>data layer"]
  node_local_database[("Local application database<br/>persistence<br/>[app_database.dart]")]
  node_template_resolver["Template resolver<br/>mobile service"]
  node_device_services["Background, notification &amp; export<br/>device services"]
  node_native_hosts["Android, iOS &amp; Linux hosts<br/>native runtimes"]
end

subgraph group_templates["Maintenance Templates"]
  node_template_schema["Template schema<br/>JSON contract<br/>[template-v1.json]"]
  node_template_index["Template index<br/>template catalog<br/>[index.json]"]
  node_base_templates["Base maintenance templates<br/>versioned JSON data<br/>[common-all.json]"]
  node_template_generator["Template generator<br/>Python tooling"]
end

subgraph group_delivery["Automation &amp; Docs"]
  node_github_actions["GitHub Actions<br/>CI &amp; release automation<br/>[ci.yml]"]
  node_documentation_site["Docusaurus documentation<br/>TypeScript site"]
end

node_app_entry -->|"starts UI"| node_presentation
node_presentation -->|"renders"| node_dashboard
node_presentation -->|"navigates to"| node_fuel_form
node_presentation -->|"navigates to"| node_maintenance_settings
node_presentation -->|"reads state"| node_providers
node_providers -->|"uses contracts"| node_domain
node_presentation -->|"depends on"| node_domain
node_data_repositories -->|"implements"| node_domain
node_data_repositories -->|"persists locally"| node_local_database
node_template_resolver -->|"composes"| node_base_templates
node_template_resolver -->|"resolves from"| node_template_index
node_template_resolver -->|"provides intervals"| node_domain
node_device_services -->|"reads local records"| node_local_database
node_app_entry -->|"runs on"| node_native_hosts
node_template_generator -->|"validates against"| node_template_schema
node_template_generator -->|"processes"| node_base_templates
node_template_generator -->|"regenerates"| node_template_index
node_github_actions -->|"updates index"| node_template_generator
node_github_actions -->|"deploys"| node_documentation_site

click node_app_entry "https://github.com/abrahdev/karter/blob/main/mobile/lib/main.dart"
click node_presentation "https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/home_page.dart"
click node_dashboard "https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/dashboard_page.dart"
click node_fuel_form "https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/fuel_log_form_page.dart"
click node_maintenance_settings "https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/maintenance_settings_page.dart"
click node_providers "https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/providers/vehicle_providers.dart"
click node_domain "https://github.com/abrahdev/karter/blob/main/mobile/lib/domain/repositories/vehicle_repository.dart"
click node_data_repositories "https://github.com/abrahdev/karter/blob/main/mobile/lib/data/repositories/vehicle_repository_impl.dart"
click node_local_database "https://github.com/abrahdev/karter/blob/main/mobile/lib/core/database/app_database.dart"
click node_template_resolver "https://github.com/abrahdev/karter/blob/main/mobile/lib/data/services/template_resolver.dart"
click node_device_services "https://github.com/abrahdev/karter/blob/main/mobile/lib/data/services/background_service.dart"
click node_native_hosts "https://github.com/abrahdev/karter/tree/main/mobile/android"
click node_template_schema "https://github.com/abrahdev/karter/blob/main/templates/schemas/template-v1.json"
click node_template_index "https://github.com/abrahdev/karter/blob/main/templates/index.json"
click node_base_templates "https://github.com/abrahdev/karter/blob/main/templates/data/_base/common-all.json"
click node_template_generator "https://github.com/abrahdev/karter/blob/main/tools/generate_templates.py"
click node_github_actions "https://github.com/abrahdev/karter/blob/main/.github/workflows/ci.yml"
click node_documentation_site "https://github.com/abrahdev/karter/blob/main/docs/docusaurus.config.ts"

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_app_entry,node_presentation,node_dashboard,node_fuel_form,node_maintenance_settings,node_providers,node_domain,node_data_repositories,node_local_database,node_template_resolver,node_device_services,node_native_hosts toneBlue
class node_template_schema,node_template_index,node_base_templates,node_template_generator toneAmber
class node_github_actions,node_documentation_site toneMint
```

## Components

### Flutter Mobile App

- [Flutter entry point](https://github.com/abrahdev/karter/blob/main/mobile/lib/main.dart): app bootstrap · `mobile/lib/main.dart`
- [Pages, providers & widgets](https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/home_page.dart): presentation layer · Coordinates dashboard, forms, lists, and selected-vehicle state. · `mobile/lib/presentation/pages/home_page.dart`
- [Vehicle dashboard](https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/dashboard_page.dart): workflow page · `mobile/lib/presentation/pages/dashboard_page.dart`
- [Fuel log workflow](https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/fuel_log_form_page.dart): workflow page · `mobile/lib/presentation/pages/fuel_log_form_page.dart`
- [Maintenance settings](https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/pages/maintenance_settings_page.dart): workflow page · `mobile/lib/presentation/pages/maintenance_settings_page.dart`
- [Vehicle state providers](https://github.com/abrahdev/karter/blob/main/mobile/lib/presentation/providers/vehicle_providers.dart): state management · `mobile/lib/presentation/providers/vehicle_providers.dart`
- [Domain contracts & rules](https://github.com/abrahdev/karter/blob/main/mobile/lib/domain/repositories/vehicle_repository.dart): domain layer · Entities, value objects, validation, errors, and repository contracts. · `mobile/lib/domain/repositories/vehicle_repository.dart`
- [Repository implementations](https://github.com/abrahdev/karter/blob/main/mobile/lib/data/repositories/vehicle_repository_impl.dart): data layer · Implements domain contracts and isolates storage details. · `mobile/lib/data/repositories/vehicle_repository_impl.dart`
- [Local application database](https://github.com/abrahdev/karter/blob/main/mobile/lib/core/database/app_database.dart): persistence · Offline records for vehicles, fuel, maintenance, and documents. · `mobile/lib/core/database/app_database.dart`
- [Template resolver](https://github.com/abrahdev/karter/blob/main/mobile/lib/data/services/template_resolver.dart): mobile service · Composes and resolves maintenance intervals for vehicles. · `mobile/lib/data/services/template_resolver.dart`
- [Background, notification & export](https://github.com/abrahdev/karter/blob/main/mobile/lib/data/services/background_service.dart): device services · Runs local reminders and user-controlled exports including PDF. · `mobile/lib/data/services/background_service.dart`
- [Android, iOS & Linux hosts](https://github.com/abrahdev/karter/tree/main/mobile/android): native runtimes · Flutter platform hosts built with Gradle/Kotlin and Xcode/Swift. · `mobile/android`

### Maintenance Templates

- [Template schema](https://github.com/abrahdev/karter/blob/main/templates/schemas/template-v1.json): JSON contract · `templates/schemas/template-v1.json`
- [Template index](https://github.com/abrahdev/karter/blob/main/templates/index.json): template catalog · `templates/index.json`
- [Base maintenance templates](https://github.com/abrahdev/karter/blob/main/templates/data/_base/common-all.json): versioned JSON data · `templates/data/_base/common-all.json`
- [Template generator](https://github.com/abrahdev/karter/blob/main/tools/generate_templates.py): Python tooling · Regenerates template artifacts and repository index. · `tools/generate_templates.py`

### Automation & Docs

- [GitHub Actions](https://github.com/abrahdev/karter/blob/main/.github/workflows/ci.yml): CI & release automation · Runs CI, releases, docs deployment, and template-index updates. · `.github/workflows/ci.yml`
- [Docusaurus documentation](https://github.com/abrahdev/karter/blob/main/docs/docusaurus.config.ts): TypeScript site · Publishes project and architecture documentation. · `docs/docusaurus.config.ts`

## Connections

- Flutter entry point → Pages, providers & widgets: starts UI
- Pages, providers & widgets → Vehicle dashboard: renders
- Pages, providers & widgets → Fuel log workflow: navigates to
- Pages, providers & widgets → Maintenance settings: navigates to
- Pages, providers & widgets → Vehicle state providers: reads state
- Vehicle state providers → Domain contracts & rules: uses contracts
- Pages, providers & widgets → Domain contracts & rules: depends on
- Repository implementations → Domain contracts & rules: implements
- Repository implementations → Local application database: persists locally
- Template resolver → Base maintenance templates: composes
- Template resolver → Template index: resolves from
- Template resolver → Domain contracts & rules: provides intervals
- Background, notification & export → Local application database: reads local records
- Flutter entry point → Android, iOS & Linux hosts: runs on
- Template generator → Template schema: validates against
- Template generator → Base maintenance templates: processes
- Template generator → Template index: regenerates
- GitHub Actions → Template generator: updates index
- GitHub Actions → Docusaurus documentation: deploys
