# brs2026/autoexpense architecture

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

- Interactive diagram: https://gitdiagram.com/brs2026/autoexpense
- Repository: https://github.com/brs2026/autoexpense

## Overview

#### Purpose and Runtime
This is a Next.js App Router application for managing financial transactions, dashboard summaries, reports, users, and settings. It runs as a React/TypeScript web application, with Next.js server routing and Supabase integration. Progressive-web-app assets are present in `public/sw.js` and `public/workbox-4754cb34.js`.

#### Application Entry and Route Structure
The root application boundary is `src/app/layout.tsx`; `src/app/page.tsx` is the base route and `src/app/login/page.tsx` provides the login route. Protected or main-product pages are grouped under `src/app/(app)/layout.tsx`, which scopes the dashboard-oriented application shell without affecting URL paths.

#### Authenticated Application Shell
The app-area layout is supported by reusable navigation and page framing components:
- `src/components/layout/app-shell.tsx`
- `src/components/layout/bottom-nav.tsx`
- `src/components/layout/page-header.tsx`

These establish the shared control boundary between global navigation/layout and individual business pages, including mobile-oriented navigation implied by the bottom-nav component.

#### Financial Transaction Domain
Transaction management is the primary domain flow. The transaction landing page is `src/app/(app)/transactions/page.tsx`; income and expense are modeled as parallel route families. Each supports listing/detail, creation, and editing through route parameters:
- `src/app/(app)/transactions/income/[id]/page.tsx`
- `src/app/(app)/transactions/income/add/page.tsx`
- `src/app/(app)/transactions/expense/edit/[id]/page.tsx`

The `[id]` routes form the record-identity boundary for viewing or mutating a specific transaction. Category presentation is centralized in `src/lib/category-icons.ts`.

#### Dashboard, Reporting, and Administration
The operational views are separated into top-level app routes:
- `src/app/(app)/dashboard/page.tsx`
- `src/app/(app)/reports/page.tsx`
- `src/app/(app)/users/page.tsx`
- `src/app/(app)/settings/page.tsx`

Dashboard has its own local layout at `src/app/(app)/dashboard/layout.tsx`, indicating dashboard-specific framing or behavior distinct from other app pages. Users are the only exposed server API surface in the tree, via `src/app/api/users/create/route.ts`.

#### Data and Service Boundary
Supabase is the external backend/data service. Its access modes are explicitly separated:
- `src/lib/supabase/browser-client.ts` for browser-side access
- `src/lib/supabase/client.ts` for general/shared client setup
- `src/lib/supabase/server-admin.ts` for privileged server-side operations

Server-admin access should remain confined to server execution paths such as route handlers, especially user provisioning at `src/app/api/users/create/route.ts`; it must not cross into client-rendered components.

#### UI, Localization, and Offline Delivery
The presentation layer uses shared UI primitives under `src/components/ui`, while global styling begins at `src/app/globals.css`. Language state is managed through `src/context/language-context.tsx`, with English and Bengali message catalogs in `src/messages/en.json` and `src/messages/bn.json`. PWA metadata is supplied by `src/app/manifest.ts`, and the service-worker artifacts in `public/` enable offline/cache behavior at the browser boundary.

Main entry points: [`src/app/layout.tsx`](https://github.com/brs2026/autoexpense/blob/main/src/app/layout.tsx) (Root application), [`src/app/(app)/layout.tsx`](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/layout.tsx) (Protected app shell), [`src/app/(app)/transactions/page.tsx`](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/page.tsx) (Transactions), [`src/app/(app)/transactions/income/[id]/page.tsx`](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/income/%5Bid%5D/page.tsx) (Income records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_shell["App shell<br/>layout component<br/>[app-shell.tsx]"]
  node_navigation["Navigation and header<br/>layout components<br/>[bottom-nav.tsx]"]
  node_category_icons["Category presentation<br/>domain UI mapping<br/>[category-icons.ts]"]
  node_language["Language state<br/>localization context"]
end

subgraph group_routes["Next.js routes"]
  node_root["Root application<br/>Next.js root layout<br/>[layout.tsx]"]
  node_home["Home and login<br/>public routes<br/>[page.tsx]"]
  node_login["Login<br/>auth page<br/>[page.tsx]"]
  node_app_layout["Protected app shell<br/>route-group layout<br/>[layout.tsx]"]
  node_dashboard["Dashboard<br/>app route<br/>[page.tsx]"]
  node_dashboard_layout["Dashboard framing<br/>local layout<br/>[layout.tsx]"]
  node_transactions["Transactions<br/>primary domain route<br/>[page.tsx]"]
  node_income_flow["Income records<br/>transaction routes<br/>[page.tsx]"]
  node_expense_flow["Expense editing<br/>transaction route<br/>[page.tsx]"]
  node_operations["Reports, users, settings<br/>app routes<br/>[page.tsx]"]
  node_user_api{{"User provisioning API<br/>route handler<br/>[route.ts]"}}
end

subgraph group_services["Data and delivery"]
  node_supabase_browser[("Browser Supabase client<br/>client data access<br/>[browser-client.ts]")]
  node_supabase_shared[("Shared Supabase client<br/>client setup<br/>[client.ts]")]
  node_supabase_admin[("Supabase admin client<br/>privileged server access<br/>[server-admin.ts]")]
  node_pwa["PWA offline delivery<br/>manifest and service worker<br/>[manifest.ts]"]
end

node_root -->|"serves"| node_home
node_root -->|"serves"| node_login
node_root -->|"mounts"| node_app_layout
node_root -->|"provides"| node_language
node_app_layout -->|"uses"| node_shell
node_shell -->|"composes"| node_navigation
node_app_layout -->|"hosts"| node_dashboard
node_dashboard_layout -->|"frames"| node_dashboard
node_app_layout -->|"hosts"| node_transactions
node_transactions -->|"routes to"| node_income_flow
node_transactions -->|"routes to"| node_expense_flow
node_income_flow -->|"renders categories"| node_category_icons
node_app_layout -->|"hosts"| node_operations
node_income_flow -->|"reads and writes"| node_supabase_browser
node_expense_flow -->|"updates"| node_supabase_browser
node_dashboard -->|"loads summaries"| node_supabase_shared
node_operations -->|"accesses data"| node_supabase_browser
node_user_api -->|"provisions with"| node_supabase_admin
node_root -->|"publishes"| node_pwa

click node_root "https://github.com/brs2026/autoexpense/blob/main/src/app/layout.tsx"
click node_home "https://github.com/brs2026/autoexpense/blob/main/src/app/page.tsx"
click node_login "https://github.com/brs2026/autoexpense/blob/main/src/app/login/page.tsx"
click node_app_layout "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/layout.tsx"
click node_shell "https://github.com/brs2026/autoexpense/blob/main/src/components/layout/app-shell.tsx"
click node_navigation "https://github.com/brs2026/autoexpense/blob/main/src/components/layout/bottom-nav.tsx"
click node_dashboard "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/dashboard/page.tsx"
click node_dashboard_layout "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/dashboard/layout.tsx"
click node_transactions "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/page.tsx"
click node_income_flow "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/income/%5Bid%5D/page.tsx"
click node_expense_flow "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/expense/edit/%5Bid%5D/page.tsx"
click node_category_icons "https://github.com/brs2026/autoexpense/blob/main/src/lib/category-icons.ts"
click node_operations "https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/reports/page.tsx"
click node_user_api "https://github.com/brs2026/autoexpense/blob/main/src/app/api/users/create/route.ts"
click node_supabase_browser "https://github.com/brs2026/autoexpense/blob/main/src/lib/supabase/browser-client.ts"
click node_supabase_shared "https://github.com/brs2026/autoexpense/blob/main/src/lib/supabase/client.ts"
click node_supabase_admin "https://github.com/brs2026/autoexpense/blob/main/src/lib/supabase/server-admin.ts"
click node_language "https://github.com/brs2026/autoexpense/blob/main/src/context/language-context.tsx"
click node_pwa "https://github.com/brs2026/autoexpense/blob/main/src/app/manifest.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_shell,node_navigation,node_category_icons,node_language toneBlue
class node_root,node_home,node_login,node_app_layout,node_dashboard,node_dashboard_layout,node_transactions,node_income_flow,node_expense_flow,node_operations,node_user_api toneAmber
class node_supabase_browser,node_supabase_shared,node_supabase_admin,node_pwa toneMint
```

## Components

### Client experience

- [App shell](https://github.com/brs2026/autoexpense/blob/main/src/components/layout/app-shell.tsx): layout component · `src/components/layout/app-shell.tsx`
- [Navigation and header](https://github.com/brs2026/autoexpense/blob/main/src/components/layout/bottom-nav.tsx): layout components · Bottom navigation and shared page framing. · `src/components/layout/bottom-nav.tsx`
- [Category presentation](https://github.com/brs2026/autoexpense/blob/main/src/lib/category-icons.ts): domain UI mapping · `src/lib/category-icons.ts`
- [Language state](https://github.com/brs2026/autoexpense/blob/main/src/context/language-context.tsx): localization context · Selects English or Bengali messages. · `src/context/language-context.tsx`

### Next.js routes

- [Root application](https://github.com/brs2026/autoexpense/blob/main/src/app/layout.tsx): Next.js root layout · `src/app/layout.tsx`
- [Home and login](https://github.com/brs2026/autoexpense/blob/main/src/app/page.tsx): public routes · `src/app/page.tsx`
- [Login](https://github.com/brs2026/autoexpense/blob/main/src/app/login/page.tsx): auth page · `src/app/login/page.tsx`
- [Protected app shell](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/layout.tsx): route-group layout · Scopes the main product without changing URLs. · `src/app/(app)/layout.tsx`
- [Dashboard](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/dashboard/page.tsx): app route · `src/app/(app)/dashboard/page.tsx`
- [Dashboard framing](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/dashboard/layout.tsx): local layout · `src/app/(app)/dashboard/layout.tsx`
- [Transactions](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/page.tsx): primary domain route · `src/app/(app)/transactions/page.tsx`
- [Income records](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/income/%5Bid%5D/page.tsx): transaction routes · Listing, creation, and record detail flow. · `src/app/(app)/transactions/income/[id]/page.tsx`
- [Expense editing](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/transactions/expense/edit/%5Bid%5D/page.tsx): transaction route · Mutates an identified expense record. · `src/app/(app)/transactions/expense/edit/[id]/page.tsx`
- [Reports, users, settings](https://github.com/brs2026/autoexpense/blob/main/src/app/(app)/reports/page.tsx): app routes · Operational and administrative views. · `src/app/(app)/reports/page.tsx`
- [User provisioning API](https://github.com/brs2026/autoexpense/blob/main/src/app/api/users/create/route.ts): route handler · Server-only user creation endpoint. · `src/app/api/users/create/route.ts`

### Data and delivery

- [Browser Supabase client](https://github.com/brs2026/autoexpense/blob/main/src/lib/supabase/browser-client.ts): client data access · `src/lib/supabase/browser-client.ts`
- [Shared Supabase client](https://github.com/brs2026/autoexpense/blob/main/src/lib/supabase/client.ts): client setup · `src/lib/supabase/client.ts`
- [Supabase admin client](https://github.com/brs2026/autoexpense/blob/main/src/lib/supabase/server-admin.ts): privileged server access · Restricted to server execution paths. · `src/lib/supabase/server-admin.ts`
- [PWA offline delivery](https://github.com/brs2026/autoexpense/blob/main/src/app/manifest.ts): manifest and service worker · Browser caching and install metadata. · `src/app/manifest.ts`

## Connections

- Root application → Home and login: serves
- Root application → Login: serves
- Root application → Protected app shell: mounts
- Root application → Language state: provides
- Protected app shell → App shell: uses
- App shell → Navigation and header: composes
- Protected app shell → Dashboard: hosts
- Dashboard framing → Dashboard: frames
- Protected app shell → Transactions: hosts
- Transactions → Income records: routes to
- Transactions → Expense editing: routes to
- Income records → Category presentation: renders categories
- Protected app shell → Reports, users, settings: hosts
- Income records → Browser Supabase client: reads and writes
- Expense editing → Browser Supabase client: updates
- Dashboard → Shared Supabase client: loads summaries
- Reports, users, settings → Browser Supabase client: accesses data
- User provisioning API → Supabase admin client: provisions with
- Root application → PWA offline delivery: publishes
