# daemonide/expensetracker-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/daemonide/expensetracker-frontend
- Repository: https://github.com/daemonide/expensetracker-frontend

## Overview

1. This repository is a single-page frontend application for an expense tracker. It is built with React + TypeScript and bundled with Vite, so the whole system runs in the browser and talks to a separate backend server.

2. The top-level application shell is centered around `main.tsx`, `App.tsx`, and `layout.tsx`. These files define how the app is mounted, how routing/layout are composed, and how the main authenticated UI is wrapped.

3. Routing is split by access level. `LoginPage` and `RegisterPage` are public entry points, while `PrivateRoute.tsx` guards the main application areas such as dashboard, expenses, categories, and account pages.

4. The feature layer is organized by domain under `src/pages`: `DashboardPage`, `ExpensesPage`, `CategoriesPage`, and `AccountPage`. This suggests a CRUD-oriented frontend where each page owns a distinct slice of user-facing functionality.

5. All server communication is centralized in `src/api`. There is a shared Axios client in `axios.ts`, with domain-specific modules for `auth`, `account`, `categories`, and `expenses`. The likely data flow is: page/component action → API module → Axios client → backend server → returned data to the page.

6. Authentication is a first-class boundary. `src/lib/auth-store.ts` likely persists the current session/token client-side, while `src/components/PrivateRoute.tsx` uses that state to decide whether a user can enter protected screens. Login/register pages feed into this auth state.

7. The UI is composed from reusable components in `src/components/ui`, which looks like a shadcn-style component set. These primitives are used by higher-level pieces like `app-sidebar.tsx`, tables, dialogs, inputs, selects, sheets, and tooltips.

8. Navigation and responsive layout are handled separately from page logic. `app-sidebar.tsx` plus sidebar/sheet primitives indicate a desktop sidebar with a mobile-friendly drawer fallback. `src/hooks/use-mobile.ts` supports that responsive boundary.

9. Cross-cutting presentation concerns are isolated in `theme-provider.tsx` and `src/index.css`. Theme handling is therefore app-wide rather than page-specific, and the CSS layer likely contains the global design tokens/reset.

10. `src/lib/utils.ts` and `src/lib/password.ts` hold shared helper logic. The presence of a password utility implies some client-side password handling/validation support, but the core security boundary still lives in the auth/API flow.

11. `src/types/pagination.ts` shows that list endpoints probably return paginated collections, which fits the expenses/categories management screens and the table-oriented UI components.

12. The external dependency boundary is important: this frontend is explicitly paired with the separate expense tracker server linked in the README. The architecture diagram should show the browser SPA on one side and the backend API as the authoritative data store/auth authority on the other.

Main entry points: [`src/layout.tsx`](https://github.com/daemonide/expensetracker-frontend/blob/main/src/layout.tsx) (Layout), [`src/App.tsx`](https://github.com/daemonide/expensetracker-frontend/blob/main/src/App.tsx) (App), [`src/components/ui`](https://github.com/daemonide/expensetracker-frontend/tree/main/src/components/ui) (UI primitives), [`src/pages/ExpensesPage.tsx`](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/ExpensesPage.tsx) (Expenses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_main["main.tsx<br/>entrypoint<br/>[main.tsx]"]
  node_app["App<br/>router root<br/>[App.tsx]"]
  node_layout["Layout<br/>[layout.tsx]"]
  node_theme["Theme<br/>provider<br/>[theme-provider.tsx]"]
end

subgraph group_auth["Auth boundary"]
  node_login["Login<br/>public page<br/>[LoginPage.tsx]"]
  node_register["Register<br/>public page<br/>[RegisterPage.tsx]"]
  node_private{{"PrivateRoute<br/>route guard<br/>[PrivateRoute.tsx]"}}
end

subgraph group_features["Feature pages"]
  node_dashboard["Dashboard<br/>feature page<br/>[DashboardPage.tsx]"]
  node_expenses["Expenses<br/>feature page<br/>[ExpensesPage.tsx]"]
  node_categories["Categories<br/>feature page<br/>[CategoriesPage.tsx]"]
  node_account["Account<br/>feature page<br/>[AccountPage.tsx]"]
end

subgraph group_api["API layer"]
  node_client["Axios client<br/>http client<br/>[axios.ts]"]
  node_apiauth["Auth API<br/>api module<br/>[auth.ts]"]
  node_apiaccount["Account API<br/>api module<br/>[account.ts]"]
  node_apicategories["Categories API<br/>api module<br/>[categories.ts]"]
  node_apiexpenses["Expenses API<br/>api module<br/>[expenses.ts]"]
end

subgraph group_ui["UI kit"]
  node_sidebar["App sidebar<br/>navigation shell<br/>[app-sidebar.tsx]"]
  node_uibundle["UI primitives<br/>component kit"]
end

subgraph group_shared["Shared logic"]
  node_authstore[("Auth store<br/>session state<br/>[auth-store.ts]")]
  node_mobile(("useMobile<br/>responsive hook<br/>[use-mobile.ts]"))
  node_utils["Utils<br/>helpers<br/>[utils.ts]"]
  node_password["Password util<br/>helpers<br/>[password.ts]"]
  node_pagination["Pagination type<br/>types<br/>[pagination.ts]"]
end

node_backend[("Backend API<br/>external service")]

node_main -->|"mounts"| node_app
node_app -->|"wraps"| node_theme
node_app -->|"composes"| node_layout
node_app -->|"routes"| node_login
node_app -->|"routes"| node_register
node_app -->|"guards"| node_private
node_private -->|"checks"| node_authstore
node_layout -->|"uses"| node_sidebar
node_sidebar -->|"adapts"| node_mobile
node_layout -->|"contains"| node_dashboard
node_layout -->|"contains"| node_expenses
node_layout -->|"contains"| node_categories
node_layout -->|"contains"| node_account
node_login -->|"calls"| node_apiauth
node_register -->|"calls"| node_apiauth
node_dashboard -->|"reads"| node_apiexpenses
node_expenses -->|"crud"| node_apiexpenses
node_expenses -->|"enriches"| node_apicategories
node_categories -->|"crud"| node_apicategories
node_account -->|"updates"| node_apiaccount
node_apiauth -->|"uses"| node_client
node_apiaccount -->|"uses"| node_client
node_apicategories -->|"uses"| node_client
node_apiexpenses -->|"uses"| node_client
node_client -->|"requests"| node_backend
node_authstore -.->|"supports"| node_apiauth
node_layout -->|"renders"| node_uibundle
node_login -->|"renders"| node_uibundle
node_register -->|"renders"| node_uibundle
node_dashboard -->|"renders"| node_uibundle
node_expenses -->|"renders"| node_uibundle
node_categories -->|"renders"| node_uibundle
node_account -->|"renders"| node_uibundle
node_layout -.->|"shares"| node_utils
node_login -.->|"validates"| node_password
node_register -.->|"validates"| node_password
node_expenses -.->|"types"| node_pagination
node_categories -.->|"types"| node_pagination

click node_main "https://github.com/daemonide/expensetracker-frontend/blob/main/src/main.tsx"
click node_app "https://github.com/daemonide/expensetracker-frontend/blob/main/src/App.tsx"
click node_layout "https://github.com/daemonide/expensetracker-frontend/blob/main/src/layout.tsx"
click node_theme "https://github.com/daemonide/expensetracker-frontend/blob/main/src/components/theme-provider.tsx"
click node_login "https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/LoginPage.tsx"
click node_register "https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/RegisterPage.tsx"
click node_private "https://github.com/daemonide/expensetracker-frontend/blob/main/src/components/PrivateRoute.tsx"
click node_authstore "https://github.com/daemonide/expensetracker-frontend/blob/main/src/lib/auth-store.ts"
click node_dashboard "https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/DashboardPage.tsx"
click node_expenses "https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/ExpensesPage.tsx"
click node_categories "https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/CategoriesPage.tsx"
click node_account "https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/AccountPage.tsx"
click node_client "https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/axios.ts"
click node_apiauth "https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/auth.ts"
click node_apiaccount "https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/account.ts"
click node_apicategories "https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/categories.ts"
click node_apiexpenses "https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/expenses.ts"
click node_sidebar "https://github.com/daemonide/expensetracker-frontend/blob/main/src/components/app-sidebar.tsx"
click node_uibundle "https://github.com/daemonide/expensetracker-frontend/tree/main/src/components/ui"
click node_mobile "https://github.com/daemonide/expensetracker-frontend/blob/main/src/hooks/use-mobile.ts"
click node_utils "https://github.com/daemonide/expensetracker-frontend/blob/main/src/lib/utils.ts"
click node_password "https://github.com/daemonide/expensetracker-frontend/blob/main/src/lib/password.ts"
click node_pagination "https://github.com/daemonide/expensetracker-frontend/blob/main/src/types/pagination.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_main,node_app,node_layout,node_theme toneBlue
class node_login,node_register,node_private toneAmber
class node_dashboard,node_expenses,node_categories,node_account toneMint
class node_client,node_apiauth,node_apiaccount,node_apicategories,node_apiexpenses toneRose
class node_sidebar,node_uibundle toneIndigo
class node_authstore,node_mobile,node_utils,node_password,node_pagination toneTeal
class node_backend toneNeutral
```

## Components

### App shell

Bootstraps, routing, and global providers

- [main.tsx](https://github.com/daemonide/expensetracker-frontend/blob/main/src/main.tsx): entrypoint · Browser entry that mounts the React app · `src/main.tsx`
- [App](https://github.com/daemonide/expensetracker-frontend/blob/main/src/App.tsx): router root · Top-level route composition and app wiring · `src/App.tsx`
- [Layout](https://github.com/daemonide/expensetracker-frontend/blob/main/src/layout.tsx): app layout · Authenticated shell and page framing · `src/layout.tsx`
- [Theme](https://github.com/daemonide/expensetracker-frontend/blob/main/src/components/theme-provider.tsx): provider · Application-wide theme provider · `src/components/theme-provider.tsx`

### Auth boundary

Public entry points and protected access control

- [Login](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/LoginPage.tsx): public page · Public sign-in screen · `src/pages/LoginPage.tsx`
- [Register](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/RegisterPage.tsx): public page · Public account creation screen · `src/pages/RegisterPage.tsx`
- [PrivateRoute](https://github.com/daemonide/expensetracker-frontend/blob/main/src/components/PrivateRoute.tsx): route guard · Protects authenticated application routes · `src/components/PrivateRoute.tsx`

### Feature pages

Top-level user screens by domain

- [Dashboard](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/DashboardPage.tsx): feature page · Overview and summary screen · `src/pages/DashboardPage.tsx`
- [Expenses](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/ExpensesPage.tsx): feature page · Expense CRUD and list view · `src/pages/ExpensesPage.tsx`
- [Categories](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/CategoriesPage.tsx): feature page · Category management screen · `src/pages/CategoriesPage.tsx`
- [Account](https://github.com/daemonide/expensetracker-frontend/blob/main/src/pages/AccountPage.tsx): feature page · User account settings screen · `src/pages/AccountPage.tsx`

### API layer

Centralized server communication

- [Axios client](https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/axios.ts): http client · Shared request wrapper and backend connection · `src/api/axios.ts`
- [Auth API](https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/auth.ts): api module · Authentication requests · `src/api/auth.ts`
- [Account API](https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/account.ts): api module · Account profile requests · `src/api/account.ts`
- [Categories API](https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/categories.ts): api module · Category endpoints · `src/api/categories.ts`
- [Expenses API](https://github.com/daemonide/expensetracker-frontend/blob/main/src/api/expenses.ts): api module · Expense endpoints · `src/api/expenses.ts`

### UI kit

Reusable presentation primitives

- [App sidebar](https://github.com/daemonide/expensetracker-frontend/blob/main/src/components/app-sidebar.tsx): navigation shell · Primary navigation and responsive drawer behavior · `src/components/app-sidebar.tsx`
- [UI primitives](https://github.com/daemonide/expensetracker-frontend/tree/main/src/components/ui): component kit · Reusable shadcn-style inputs, tables, dialogs, sheets, and related controls · `src/components/ui`

### Shared logic

Cross-cutting client helpers and state

- [Auth store](https://github.com/daemonide/expensetracker-frontend/blob/main/src/lib/auth-store.ts): session state · Client-side auth/session persistence · `src/lib/auth-store.ts`
- [useMobile](https://github.com/daemonide/expensetracker-frontend/blob/main/src/hooks/use-mobile.ts): responsive hook · Viewport breakpoint helper · `src/hooks/use-mobile.ts`
- [Utils](https://github.com/daemonide/expensetracker-frontend/blob/main/src/lib/utils.ts): helpers · Shared utility functions · `src/lib/utils.ts`
- [Password util](https://github.com/daemonide/expensetracker-frontend/blob/main/src/lib/password.ts): helpers · Client-side password helper logic · `src/lib/password.ts`
- [Pagination type](https://github.com/daemonide/expensetracker-frontend/blob/main/src/types/pagination.ts): types · Shared paginated collection shape · `src/types/pagination.ts`

### Other components

- **Backend API**: external service · Separate expense tracker server that owns data and auth

## Connections

- main.tsx → App: mounts · Bootstraps the React application
- App → Theme: wraps · Applies global theme context
- App → Layout: composes · Builds the main application shell
- App → Login: routes · Public authentication entry point
- App → Register: routes · Public account creation entry point
- App → PrivateRoute: guards · Protects the authenticated section
- PrivateRoute → Auth store: checks · Reads client session state
- Layout → App sidebar: uses · Provides navigation chrome
- App sidebar → useMobile: adapts · Switches between sidebar and drawer behavior
- Layout → Dashboard: contains · Default authenticated landing page
- Layout → Expenses: contains · Expense management page
- Layout → Categories: contains · Category management page
- Layout → Account: contains · Account settings page
- Login → Auth API: calls · Submits credentials to the auth API
- Register → Auth API: calls · Creates a new account through the auth API
- Dashboard → Expenses API: reads · Loads expense data for summary views
- Expenses → Expenses API: crud · Manages expense records
- Expenses → Categories API: enriches · Uses categories for selection and display
- Categories → Categories API: crud · Manages category records
- Account → Account API: updates · Reads and updates account data
- Auth API → Axios client: uses · Shares the common HTTP client
- Account API → Axios client: uses · Shares the common HTTP client
- Categories API → Axios client: uses · Shares the common HTTP client
- Expenses API → Axios client: uses · Shares the common HTTP client
- Axios client → Backend API: requests · Sends API calls to the separate server
- Auth store → Auth API: supports · Stores session state established by auth flows
- Layout → UI primitives: renders · Uses shared UI primitives for shell composition
- Login → UI primitives: renders · Builds forms from shared UI components
- Register → UI primitives: renders · Builds forms from shared UI components
- Dashboard → UI primitives: renders · Uses cards, tables, and other primitives
- Expenses → UI primitives: renders · Uses tables, dialogs, and form controls
- Categories → UI primitives: renders · Uses tables and form controls
- Account → UI primitives: renders · Uses form and profile controls
- Layout → Utils: shares · Uses common helpers across the app
- Login → Password util: validates · Supports password handling and validation
- Register → Password util: validates · Supports password handling and validation
- Expenses → Pagination type: types · Consumes paginated list shapes
- Categories → Pagination type: types · Consumes paginated list shapes
