# mkaiyr/ai-auto architecture

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

- Interactive diagram: https://gitdiagram.com/mkaiyr/ai-auto
- Repository: https://github.com/mkaiyr/ai-auto

## Overview

AI Auto is a car-ownership web app, with a Capacitor mobile shell. The main workflow is landing page or direct entry → authentication for private routes → car, service-history, expense, or assistant features. Account data repositories use Supabase; the product also documents car details, maintenance history, expense summaries, reminders, and AI guidance. Some feature implementations were not sampled, so their internal calls are omitted rather than inferred.

Main entry points: [`src/App.tsx`](https://github.com/mkaiyr/ai-auto/blob/main/src/App.tsx) (App routing), [`src/app/AppShell.tsx`](https://github.com/mkaiyr/ai-auto/blob/main/src/app/AppShell.tsx) (Account shell), [`src/app/repositories.ts`](https://github.com/mkaiyr/ai-auto/blob/main/src/app/repositories.ts) (Repository selection), [`src/auth/AuthProvider.tsx`](https://github.com/mkaiyr/ai-auto/blob/main/src/auth/AuthProvider.tsx) (Session and auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and account"]
  node_app["App routing<br/>[App.tsx]"]
  node_router["History router<br/>[router.tsx]"]
  node_authui["Sign-in screens<br/>[AuthPage.tsx]"]
  node_auth["Session and auth<br/>[AuthProvider.tsx]"]
  node_landing["Landing content<br/>[content.ts]"]
end

subgraph group_ownership["Car ownership"]
  node_shell["Account shell<br/>[AppShell.tsx]"]
  node_carui["Car pages and form<br/>[CarPage.tsx]"]
  node_carstate["Car state<br/>[useCar.ts]"]
  node_catalog["Vehicle catalog<br/>[generations.ts]"]
  node_serviceui["History and service forms<br/>[ServiceForm.tsx]"]
  node_servicehook["Service records"]
  node_expenses["Expense summaries<br/>[ExpensesPage.tsx]"]
  node_reminders["Maintenance reminders<br/>[SoonPage.tsx]"]
end

subgraph group_assistant["AI assistant"]
  node_assistantpage["Assistant page<br/>[AssistantPage.tsx]"]
  node_assistantchat["Chat interfaces<br/>[AssistantChat.tsx]"]
  node_mobilechat["Mobile chat"]
end

subgraph group_data["Data services"]
  node_repositories["Repository selection<br/>[repositories.ts]"]
  node_carremote["Car data access<br/>[carRemote.ts]"]
  node_serviceremote["Service data access<br/>[serviceRemote.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_supabase_service[("Supabase data and auth")]
end

node_driver(("Driver"))

node_driver -->|"opens"| node_app
node_app -->|"tracks routes"| node_router
node_app -->|"shows sign-in"| node_authui
node_app -->|"checks session"| node_auth
node_app -->|"opens cabinet"| node_shell
node_app -->|"opens assistant"| node_assistantpage
node_app -.->|"renders landing"| node_landing
node_authui -->|"submits credentials"| node_auth
node_auth -->|"authenticates"| node_supabase
node_shell -->|"renders"| node_carui
node_shell -->|"renders"| node_expenses
node_shell -->|"renders assistant section"| node_assistantpage
node_carui -.->|"uses car state"| node_carstate
node_carui -.->|"selects vehicle"| node_catalog
node_shell -->|"renders history"| node_serviceui
node_serviceui -->|"uses records"| node_servicehook
node_assistantpage -->|"selects chat"| node_assistantchat
node_assistantpage -->|"selects mobile chat"| node_mobilechat
node_carstate -->|"loads car data"| node_repositories
node_servicehook -->|"loads service data"| node_repositories
node_repositories -->|"creates remote repository"| node_carremote
node_repositories -->|"creates remote repository"| node_serviceremote
node_repositories -->|"gets client"| node_supabase
node_supabase -.->|"connects to"| node_supabase_service
node_auth -.->|"uses auth service"| node_supabase_service
node_expenses -.->|"summarizes records"| node_servicehook
node_reminders -.->|"offers reminders"| node_driver

click node_app "https://github.com/mkaiyr/ai-auto/blob/main/src/App.tsx"
click node_router "https://github.com/mkaiyr/ai-auto/blob/main/src/router.tsx"
click node_authui "https://github.com/mkaiyr/ai-auto/blob/main/src/auth/AuthPage.tsx"
click node_auth "https://github.com/mkaiyr/ai-auto/blob/main/src/auth/AuthProvider.tsx"
click node_landing "https://github.com/mkaiyr/ai-auto/blob/main/src/data/content.ts"
click node_shell "https://github.com/mkaiyr/ai-auto/blob/main/src/app/AppShell.tsx"
click node_carui "https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/CarPage.tsx"
click node_carstate "https://github.com/mkaiyr/ai-auto/blob/main/src/app/car/useCar.ts"
click node_catalog "https://github.com/mkaiyr/ai-auto/blob/main/src/app/car/catalog/generations.ts"
click node_serviceui "https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/ServiceForm.tsx"
click node_servicehook "https://github.com/mkaiyr/ai-auto/blob/main/src/app/service/useServiceRecords.ts"
click node_expenses "https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/ExpensesPage.tsx"
click node_reminders "https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/SoonPage.tsx"
click node_assistantpage "https://github.com/mkaiyr/ai-auto/blob/main/src/ai/AssistantPage.tsx"
click node_assistantchat "https://github.com/mkaiyr/ai-auto/blob/main/src/ai/AssistantChat.tsx"
click node_mobilechat "https://github.com/mkaiyr/ai-auto/blob/main/src/ai/AssistantChatMobile.tsx"
click node_repositories "https://github.com/mkaiyr/ai-auto/blob/main/src/app/repositories.ts"
click node_carremote "https://github.com/mkaiyr/ai-auto/blob/main/src/app/car/carRemote.ts"
click node_serviceremote "https://github.com/mkaiyr/ai-auto/blob/main/src/app/service/serviceRemote.ts"
click node_supabase "https://github.com/mkaiyr/ai-auto/blob/main/src/lib/supabase.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,node_router,node_authui,node_auth,node_landing toneBlue
class node_shell,node_carui,node_carstate,node_catalog,node_serviceui,node_servicehook,node_expenses,node_reminders toneAmber
class node_assistantpage,node_assistantchat,node_mobilechat toneMint
class node_repositories,node_carremote,node_serviceremote,node_supabase,node_supabase_service toneRose
class node_driver toneIndigo
```

## Components

### Entry and account

- [App routing](https://github.com/mkaiyr/ai-auto/blob/main/src/App.tsx): `src/App.tsx`
- [History router](https://github.com/mkaiyr/ai-auto/blob/main/src/router.tsx): `src/router.tsx`
- [Sign-in screens](https://github.com/mkaiyr/ai-auto/blob/main/src/auth/AuthPage.tsx): `src/auth/AuthPage.tsx`
- [Session and auth](https://github.com/mkaiyr/ai-auto/blob/main/src/auth/AuthProvider.tsx): `src/auth/AuthProvider.tsx`
- [Landing content](https://github.com/mkaiyr/ai-auto/blob/main/src/data/content.ts): `src/data/content.ts`

### Car ownership

- [Account shell](https://github.com/mkaiyr/ai-auto/blob/main/src/app/AppShell.tsx): `src/app/AppShell.tsx`
- [Car pages and form](https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/CarPage.tsx): `src/app/pages/CarPage.tsx`
- [Car state](https://github.com/mkaiyr/ai-auto/blob/main/src/app/car/useCar.ts): `src/app/car/useCar.ts`
- [Vehicle catalog](https://github.com/mkaiyr/ai-auto/blob/main/src/app/car/catalog/generations.ts): `src/app/car/catalog/generations.ts`
- [History and service forms](https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/ServiceForm.tsx): `src/app/pages/ServiceForm.tsx`
- [Service records](https://github.com/mkaiyr/ai-auto/blob/main/src/app/service/useServiceRecords.ts): `src/app/service/useServiceRecords.ts`
- [Expense summaries](https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/ExpensesPage.tsx): `src/app/pages/ExpensesPage.tsx`
- [Maintenance reminders](https://github.com/mkaiyr/ai-auto/blob/main/src/app/pages/SoonPage.tsx): `src/app/pages/SoonPage.tsx`

### AI assistant

- [Assistant page](https://github.com/mkaiyr/ai-auto/blob/main/src/ai/AssistantPage.tsx): `src/ai/AssistantPage.tsx`
- [Chat interfaces](https://github.com/mkaiyr/ai-auto/blob/main/src/ai/AssistantChat.tsx): `src/ai/AssistantChat.tsx`
- [Mobile chat](https://github.com/mkaiyr/ai-auto/blob/main/src/ai/AssistantChatMobile.tsx): `src/ai/AssistantChatMobile.tsx`

### Data services

- [Repository selection](https://github.com/mkaiyr/ai-auto/blob/main/src/app/repositories.ts): `src/app/repositories.ts`
- [Car data access](https://github.com/mkaiyr/ai-auto/blob/main/src/app/car/carRemote.ts): `src/app/car/carRemote.ts`
- [Service data access](https://github.com/mkaiyr/ai-auto/blob/main/src/app/service/serviceRemote.ts): `src/app/service/serviceRemote.ts`
- [Supabase client](https://github.com/mkaiyr/ai-auto/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- **Supabase data and auth**

### Other components

- **Driver**

## Connections

- Driver → App routing: opens (evidence: `src/App.tsx`)
- App routing → History router: tracks routes (evidence: `src/App.tsx`)
- App routing → Sign-in screens: shows sign-in (evidence: `src/App.tsx`)
- App routing → Session and auth: checks session (evidence: `src/App.tsx`)
- App routing → Account shell: opens cabinet (evidence: `src/App.tsx`)
- App routing → Assistant page: opens assistant (evidence: `src/App.tsx`)
- App routing → Landing content: renders landing
- Sign-in screens → Session and auth: submits credentials (evidence: `src/auth/AuthPage.tsx`)
- Session and auth → Supabase client: authenticates (evidence: `src/auth/AuthProvider.tsx`)
- Account shell → Car pages and form: renders (evidence: `src/app/AppShell.tsx`)
- Account shell → Expense summaries: renders (evidence: `src/app/AppShell.tsx`)
- Account shell → Assistant page: renders assistant section (evidence: `src/app/AppShell.tsx`)
- Car pages and form → Car state: uses car state
- Car pages and form → Vehicle catalog: selects vehicle
- Account shell → History and service forms: renders history (evidence: `src/app/AppShell.tsx`)
- History and service forms → Service records: uses records (evidence: `src/app/pages/ServiceForm.tsx`)
- Assistant page → Chat interfaces: selects chat (evidence: `src/ai/AssistantPage.tsx`)
- Assistant page → Mobile chat: selects mobile chat (evidence: `src/ai/AssistantPage.tsx`)
- Car state → Repository selection: loads car data (evidence: `src/app/car/useCar.ts`)
- Service records → Repository selection: loads service data (evidence: `src/app/service/useServiceRecords.ts`)
- Repository selection → Car data access: creates remote repository (evidence: `src/app/repositories.ts`)
- Repository selection → Service data access: creates remote repository (evidence: `src/app/repositories.ts`)
- Repository selection → Supabase client: gets client (evidence: `src/app/repositories.ts`)
- Supabase client → Supabase data and auth: connects to
- Session and auth → Supabase data and auth: uses auth service
- Expense summaries → Service records: summarizes records
- Maintenance reminders → Driver: offers reminders
