# shwan26/latli architecture

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

- Interactive diagram: https://gitdiagram.com/shwan26/latli
- Repository: https://github.com/shwan26/latli

## Overview

This is a small-shop order-management web app, with customer, shop, cargo, and profile management alongside its central order workflow. Users create and edit orders, then review orders and dashboard summaries; related customer and shop records, photos, and cargo have separate feature areas. Supabase-backed data access and browser-local data support the app, with an import path for local data. The source index establishes many page-to-module references, but unsampled implementations limit certainty about some runtime calls; those links are omitted where needed.

Main entry points: [`lib/db/orders.ts`](https://github.com/shwan26/latli/blob/main/lib/db/orders.ts) (Order data), [`lib/db/shared.ts`](https://github.com/shwan26/latli/blob/main/lib/db/shared.ts) (Database access), [`app/lib/local-orders.ts`](https://github.com/shwan26/latli/blob/main/app/lib/local-orders.ts) (Local orders), [`app/orders/[id]/page.tsx`](https://github.com/shwan26/latli/blob/main/app/orders/%5Bid%5D/page.tsx) (Order detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Orders and insights"]
  node_order_entry["Order entry<br/>[page.tsx]"]
  node_order_detail["Order detail<br/>[page.tsx]"]
  node_order_list["Order list<br/>[page.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_order_data["Order data<br/>[orders.ts]"]
  node_local_orders["Local orders<br/>[local-orders.ts]"]
end

subgraph group_records["Business records"]
  node_customers["Customers<br/>[page.tsx]"]
  node_customer_detail["Customer detail<br/>[page.tsx]"]
  node_customer_data["Customer data<br/>[customers.ts]"]
  node_shops["Shops<br/>[page.tsx]"]
  node_shop_data["Shop data<br/>[shops.ts]"]
  node_cargo["Cargo tracking<br/>[page.tsx]"]
  node_cargo_data["Cargo data<br/>[cargo.ts]"]
  node_photo_data["Photo storage<br/>[photos.ts]"]
  node_ocr_api["Order extraction API<br/>[route.ts]"]
  node_ocr["Screenshot OCR<br/>[screenshot-ocr.ts]"]
end

subgraph group_platform["Data and account"]
  node_profile["Profile and plan<br/>[profile.ts]"]
  node_auth["Sign-in and registration<br/>[page.tsx]"]
  node_auth_callback["Auth callback<br/>[route.ts]"]
  node_database_access["Database access<br/>[shared.ts]"]
  node_supabase_client["Supabase client<br/>[client.ts]"]
  node_supabase[("Supabase")]
  node_local_import["Local-data import<br/>[import-local.ts]"]
end

subgraph group_experience["Shared experience"]
  node_i18n_provider["Language provider<br/>[provider.tsx]"]
  node_i18n_runtime["Translation runtime<br/>[runtime.ts]"]
  node_navigation["Bottom navigation"]
  node_ui["UI components"]
end

node_user(("Shop operator"))

node_user -->|"creates orders"| node_order_entry
node_user -->|"reviews orders"| node_order_list
node_user -->|"manages records"| node_customers
node_user -->|"manages shops"| node_shops
node_order_list -->|"loads orders"| node_order_data
node_order_detail -->|"reads and saves"| node_order_data
node_dashboard -->|"loads summaries"| node_order_data
node_customers -->|"loads and saves"| node_customer_data
node_customers -->|"loads orders"| node_order_data
node_customer_detail -->|"loads and saves"| node_customer_data
node_customer_detail -->|"loads orders"| node_order_data
node_shops -->|"manages shops"| node_shop_data
node_shops -->|"uses photo storage"| node_photo_data
node_order_detail -->|"loads shops"| node_shop_data
node_order_detail -->|"uses photo storage"| node_photo_data
node_cargo -->|"loads cargo"| node_cargo_data
node_ocr_api -->|"checks profile"| node_profile
node_order_entry -.->|"requests extraction"| node_ocr_api
node_order_entry -.->|"stores photos"| node_photo_data
node_order_data -->|"uses database helpers"| node_database_access
node_customer_data -->|"uses database helpers"| node_database_access
node_shop_data -->|"uses database helpers"| node_database_access
node_cargo_data -->|"uses database helpers"| node_database_access
node_photo_data -.->|"uses database helpers"| node_database_access
node_database_access -->|"creates client"| node_supabase_client
node_supabase_client -->|"queries data"| node_supabase
node_auth -->|"authenticates"| node_supabase_client
node_auth_callback -.->|"completes sign-in"| node_supabase
node_local_import -->|"imports local orders"| node_local_orders
node_order_list -->|"uses local orders"| node_local_orders
node_order_detail -->|"uses local orders"| node_local_orders
node_dashboard -->|"uses local orders"| node_local_orders
node_customers -->|"uses local orders"| node_local_orders
node_i18n_provider -->|"sets language"| node_i18n_runtime
node_navigation -->|"translates labels"| node_i18n_provider
node_order_list -->|"uses translations"| node_i18n_provider
node_dashboard -->|"uses translations"| node_i18n_provider
node_order_entry -->|"renders controls"| node_ui
node_navigation -->|"routes to features"| node_user

click node_order_entry "https://github.com/shwan26/latli/blob/main/app/orders/create/page.tsx"
click node_order_detail "https://github.com/shwan26/latli/blob/main/app/orders/%5Bid%5D/page.tsx"
click node_order_list "https://github.com/shwan26/latli/blob/main/app/orders/page.tsx"
click node_dashboard "https://github.com/shwan26/latli/blob/main/app/dashboard/page.tsx"
click node_order_data "https://github.com/shwan26/latli/blob/main/lib/db/orders.ts"
click node_local_orders "https://github.com/shwan26/latli/blob/main/app/lib/local-orders.ts"
click node_customers "https://github.com/shwan26/latli/blob/main/app/customers/page.tsx"
click node_customer_detail "https://github.com/shwan26/latli/blob/main/app/customers/%5Bkey%5D/page.tsx"
click node_customer_data "https://github.com/shwan26/latli/blob/main/lib/db/customers.ts"
click node_shops "https://github.com/shwan26/latli/blob/main/app/shops/page.tsx"
click node_shop_data "https://github.com/shwan26/latli/blob/main/lib/db/shops.ts"
click node_cargo "https://github.com/shwan26/latli/blob/main/app/cargo/page.tsx"
click node_cargo_data "https://github.com/shwan26/latli/blob/main/lib/db/cargo.ts"
click node_photo_data "https://github.com/shwan26/latli/blob/main/lib/db/photos.ts"
click node_ocr_api "https://github.com/shwan26/latli/blob/main/app/api/extract-order/route.ts"
click node_ocr "https://github.com/shwan26/latli/blob/main/app/lib/screenshot-ocr.ts"
click node_profile "https://github.com/shwan26/latli/blob/main/lib/profile.ts"
click node_auth "https://github.com/shwan26/latli/blob/main/app/login/page.tsx"
click node_auth_callback "https://github.com/shwan26/latli/blob/main/app/auth/callback/route.ts"
click node_database_access "https://github.com/shwan26/latli/blob/main/lib/db/shared.ts"
click node_supabase_client "https://github.com/shwan26/latli/blob/main/lib/supabase/client.ts"
click node_local_import "https://github.com/shwan26/latli/blob/main/lib/db/import-local.ts"
click node_i18n_provider "https://github.com/shwan26/latli/blob/main/lib/i18n/provider.tsx"
click node_i18n_runtime "https://github.com/shwan26/latli/blob/main/lib/i18n/runtime.ts"
click node_navigation "https://github.com/shwan26/latli/blob/main/components/bottom-navigation.tsx"
click node_ui "https://github.com/shwan26/latli/tree/main/components/ui"

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_order_entry,node_order_detail,node_order_list,node_dashboard,node_order_data,node_local_orders toneBlue
class node_customers,node_customer_detail,node_customer_data,node_shops,node_shop_data,node_cargo,node_cargo_data,node_photo_data,node_ocr_api,node_ocr toneAmber
class node_profile,node_auth,node_auth_callback,node_database_access,node_supabase_client,node_supabase,node_local_import toneMint
class node_i18n_provider,node_i18n_runtime,node_navigation,node_ui toneRose
class node_user toneIndigo
```

## Components

### Orders and insights

- [Order entry](https://github.com/shwan26/latli/blob/main/app/orders/create/page.tsx): `app/orders/create/page.tsx`
- [Order detail](https://github.com/shwan26/latli/blob/main/app/orders/%5Bid%5D/page.tsx): `app/orders/[id]/page.tsx`
- [Order list](https://github.com/shwan26/latli/blob/main/app/orders/page.tsx): `app/orders/page.tsx`
- [Dashboard](https://github.com/shwan26/latli/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Order data](https://github.com/shwan26/latli/blob/main/lib/db/orders.ts): `lib/db/orders.ts`
- [Local orders](https://github.com/shwan26/latli/blob/main/app/lib/local-orders.ts): `app/lib/local-orders.ts`

### Business records

- [Customers](https://github.com/shwan26/latli/blob/main/app/customers/page.tsx): `app/customers/page.tsx`
- [Customer detail](https://github.com/shwan26/latli/blob/main/app/customers/%5Bkey%5D/page.tsx): `app/customers/[key]/page.tsx`
- [Customer data](https://github.com/shwan26/latli/blob/main/lib/db/customers.ts): `lib/db/customers.ts`
- [Shops](https://github.com/shwan26/latli/blob/main/app/shops/page.tsx): `app/shops/page.tsx`
- [Shop data](https://github.com/shwan26/latli/blob/main/lib/db/shops.ts): `lib/db/shops.ts`
- [Cargo tracking](https://github.com/shwan26/latli/blob/main/app/cargo/page.tsx): `app/cargo/page.tsx`
- [Cargo data](https://github.com/shwan26/latli/blob/main/lib/db/cargo.ts): `lib/db/cargo.ts`
- [Photo storage](https://github.com/shwan26/latli/blob/main/lib/db/photos.ts): `lib/db/photos.ts`
- [Order extraction API](https://github.com/shwan26/latli/blob/main/app/api/extract-order/route.ts): `app/api/extract-order/route.ts`
- [Screenshot OCR](https://github.com/shwan26/latli/blob/main/app/lib/screenshot-ocr.ts): `app/lib/screenshot-ocr.ts`

### Data and account

- [Profile and plan](https://github.com/shwan26/latli/blob/main/lib/profile.ts): `lib/profile.ts`
- [Sign-in and registration](https://github.com/shwan26/latli/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Auth callback](https://github.com/shwan26/latli/blob/main/app/auth/callback/route.ts): `app/auth/callback/route.ts`
- [Database access](https://github.com/shwan26/latli/blob/main/lib/db/shared.ts): `lib/db/shared.ts`
- [Supabase client](https://github.com/shwan26/latli/blob/main/lib/supabase/client.ts): `lib/supabase/client.ts`
- **Supabase**
- [Local-data import](https://github.com/shwan26/latli/blob/main/lib/db/import-local.ts): `lib/db/import-local.ts`

### Shared experience

- [Language provider](https://github.com/shwan26/latli/blob/main/lib/i18n/provider.tsx): `lib/i18n/provider.tsx`
- [Translation runtime](https://github.com/shwan26/latli/blob/main/lib/i18n/runtime.ts): `lib/i18n/runtime.ts`
- [Bottom navigation](https://github.com/shwan26/latli/blob/main/components/bottom-navigation.tsx): `components/bottom-navigation.tsx`
- [UI components](https://github.com/shwan26/latli/tree/main/components/ui): `components/ui`

### Other components

- **Shop operator**

## Connections

- Shop operator → Order entry: creates orders
- Shop operator → Order list: reviews orders
- Shop operator → Customers: manages records
- Shop operator → Shops: manages shops
- Order list → Order data: loads orders (evidence: `app/orders/page.tsx`)
- Order detail → Order data: reads and saves (evidence: `app/orders/[id]/page.tsx`)
- Dashboard → Order data: loads summaries (evidence: `app/dashboard/page.tsx`)
- Customers → Customer data: loads and saves (evidence: `app/customers/page.tsx`)
- Customers → Order data: loads orders (evidence: `app/customers/page.tsx`)
- Customer detail → Customer data: loads and saves (evidence: `app/customers/[key]/page.tsx`)
- Customer detail → Order data: loads orders (evidence: `app/customers/[key]/page.tsx`)
- Shops → Shop data: manages shops (evidence: `app/shops/page.tsx`)
- Shops → Photo storage: uses photo storage (evidence: `app/shops/page.tsx`)
- Order detail → Shop data: loads shops (evidence: `app/orders/[id]/page.tsx`)
- Order detail → Photo storage: uses photo storage (evidence: `app/orders/[id]/page.tsx`)
- Cargo tracking → Cargo data: loads cargo (evidence: `app/cargo/page.tsx`)
- Order extraction API → Profile and plan: checks profile (evidence: `app/api/extract-order/route.ts`)
- Order entry → Order extraction API: requests extraction
- Order entry → Photo storage: stores photos (evidence: `app/orders/create/page.tsx`)
- Order data → Database access: uses database helpers (evidence: `lib/db/orders.ts`)
- Customer data → Database access: uses database helpers
- Shop data → Database access: uses database helpers
- Cargo data → Database access: uses database helpers (evidence: `app/cargo/page.tsx`)
- Photo storage → Database access: uses database helpers
- Database access → Supabase client: creates client (evidence: `lib/db/shared.ts`)
- Supabase client → Supabase: queries data
- Sign-in and registration → Supabase client: authenticates (evidence: `app/login/page.tsx`)
- Auth callback → Supabase: completes sign-in
- Local-data import → Local orders: imports local orders (evidence: `lib/db/import-local.ts`)
- Order list → Local orders: uses local orders (evidence: `app/orders/page.tsx`)
- Order detail → Local orders: uses local orders (evidence: `app/orders/[id]/page.tsx`)
- Dashboard → Local orders: uses local orders (evidence: `app/dashboard/page.tsx`)
- Customers → Local orders: uses local orders (evidence: `app/customers/page.tsx`)
- Language provider → Translation runtime: sets language (evidence: `lib/i18n/provider.tsx`)
- Bottom navigation → Language provider: translates labels (evidence: `components/bottom-navigation.tsx`)
- Order list → Language provider: uses translations (evidence: `app/orders/page.tsx`)
- Dashboard → Language provider: uses translations (evidence: `app/dashboard/page.tsx`)
- Order entry → UI components: renders controls (evidence: `app/orders/create/page.tsx`)
- Bottom navigation → Shop operator: routes to features (evidence: `components/bottom-navigation.tsx`)
