# nasjabhr/nasja architecture

> Architecture diagram of the GitHub repository nasjabhr/nasja, 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/nasjabhr/nasja
- Repository: https://github.com/nasjabhr/nasja

## Overview

Nasjah Atelier is a fabric-shop ERP with a public storefront. Customers browse the catalog and submit orders; staff use authenticated operational screens to manage orders, inventory, expenses, budgets, and store settings. The browser data service sends reads and writes to the backend API, which accesses the database. The graph follows the sampled routing, data-service, and API evidence; some listed capabilities and backend details were not inspected beyond the provided excerpts.

Main entry points: [`src/components/Layout.tsx`](https://github.com/nasjabhr/nasja/blob/main/src/components/Layout.tsx) (ERP layout), [`src/lib/dataService.ts`](https://github.com/nasjabhr/nasja/blob/main/src/lib/dataService.ts) (Browser data service), [`src/App.tsx`](https://github.com/nasjabhr/nasja/blob/main/src/App.tsx) (Route application), [`src/pages/Store.tsx`](https://github.com/nasjabhr/nasja/blob/main/src/pages/Store.tsx) (Public storefront)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_app["Route application<br/>[App.tsx]"]
  node_layout["ERP layout<br/>[Layout.tsx]"]
  node_protection["Route protection<br/>[ProtectedRoute.tsx]"]
end

subgraph group_commerce["Storefront and sales"]
  node_storefront["Public storefront<br/>[Store.tsx]"]
  node_orders["Order management<br/>[Orders.tsx]"]
end

subgraph group_operations["Shop operations"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_inventory["Inventory<br/>[Inventory.tsx]"]
  node_expenses["Expenses<br/>[Expenses.tsx]"]
  node_budget["Budget<br/>[Budget.tsx]"]
  node_store_settings["Store settings<br/>[StoreSettings.tsx]"]
  node_settings["Account settings<br/>[Settings.tsx]"]
  node_ai_analysis["AI analysis service"]
end

subgraph group_platform["Data and access"]
  node_login["Staff login<br/>[Login.tsx]"]
  node_setup["Initial setup<br/>[Setup.tsx]"]
  node_data_service["Browser data service<br/>[dataService.ts]"]
  node_api["Backend API<br/>[index.ts]"]
  node_database[("Supabase database")]
  node_supabase_auth["Supabase auth"]
end

node_customer(("Customer"))
node_staff(("Shop staff"))

node_customer -->|"browses"| node_storefront
node_staff -->|"opens"| node_app
node_app -->|"routes to"| node_storefront
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_setup
node_app -->|"guards"| node_protection
node_protection -->|"wraps"| node_layout
node_layout -->|"renders"| node_dashboard
node_layout -->|"renders"| node_orders
node_layout -->|"renders"| node_inventory
node_layout -->|"renders"| node_expenses
node_layout -->|"routes to"| node_budget
node_layout -->|"renders"| node_store_settings
node_layout -->|"renders"| node_settings
node_storefront -->|"submits orders"| node_data_service
node_orders -->|"persists changes"| node_data_service
node_dashboard -->|"reads data"| node_data_service
node_inventory -->|"reads data"| node_data_service
node_expenses -->|"reads data"| node_data_service
node_budget -->|"reads data"| node_data_service
node_store_settings -->|"saves settings"| node_data_service
node_data_service -->|"calls API"| node_api
node_api -->|"reads and writes"| node_database
node_login -->|"authenticates"| node_supabase_auth
node_data_service -->|"gets token"| node_supabase_auth
node_customer -->|"places order"| node_storefront
node_ai_analysis -.->|"supports analysis"| node_dashboard

click node_app "https://github.com/nasjabhr/nasja/blob/main/src/App.tsx"
click node_layout "https://github.com/nasjabhr/nasja/blob/main/src/components/Layout.tsx"
click node_protection "https://github.com/nasjabhr/nasja/blob/main/src/components/ProtectedRoute.tsx"
click node_storefront "https://github.com/nasjabhr/nasja/blob/main/src/pages/Store.tsx"
click node_orders "https://github.com/nasjabhr/nasja/blob/main/src/pages/Orders.tsx"
click node_login "https://github.com/nasjabhr/nasja/blob/main/src/pages/Login.tsx"
click node_dashboard "https://github.com/nasjabhr/nasja/blob/main/src/pages/Dashboard.tsx"
click node_inventory "https://github.com/nasjabhr/nasja/blob/main/src/pages/Inventory.tsx"
click node_expenses "https://github.com/nasjabhr/nasja/blob/main/src/pages/Expenses.tsx"
click node_budget "https://github.com/nasjabhr/nasja/blob/main/src/pages/Budget.tsx"
click node_store_settings "https://github.com/nasjabhr/nasja/blob/main/src/pages/StoreSettings.tsx"
click node_settings "https://github.com/nasjabhr/nasja/blob/main/src/pages/Settings.tsx"
click node_setup "https://github.com/nasjabhr/nasja/blob/main/src/pages/Setup.tsx"
click node_data_service "https://github.com/nasjabhr/nasja/blob/main/src/lib/dataService.ts"
click node_api "https://github.com/nasjabhr/nasja/blob/main/api/index.ts"
click node_ai_analysis "https://github.com/nasjabhr/nasja/blob/main/src/lib/aiAnalysisService.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_layout,node_protection toneBlue
class node_storefront,node_orders toneAmber
class node_dashboard,node_inventory,node_expenses,node_budget,node_store_settings,node_settings,node_ai_analysis toneMint
class node_login,node_setup,node_data_service,node_api,node_database,node_supabase_auth toneRose
class node_customer,node_staff toneIndigo
```

## Components

### Application shell

- [Route application](https://github.com/nasjabhr/nasja/blob/main/src/App.tsx): `src/App.tsx`
- [ERP layout](https://github.com/nasjabhr/nasja/blob/main/src/components/Layout.tsx): `src/components/Layout.tsx`
- [Route protection](https://github.com/nasjabhr/nasja/blob/main/src/components/ProtectedRoute.tsx): `src/components/ProtectedRoute.tsx`

### Storefront and sales

- [Public storefront](https://github.com/nasjabhr/nasja/blob/main/src/pages/Store.tsx): `src/pages/Store.tsx`
- [Order management](https://github.com/nasjabhr/nasja/blob/main/src/pages/Orders.tsx): `src/pages/Orders.tsx`

### Shop operations

- [Dashboard](https://github.com/nasjabhr/nasja/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Inventory](https://github.com/nasjabhr/nasja/blob/main/src/pages/Inventory.tsx): `src/pages/Inventory.tsx`
- [Expenses](https://github.com/nasjabhr/nasja/blob/main/src/pages/Expenses.tsx): `src/pages/Expenses.tsx`
- [Budget](https://github.com/nasjabhr/nasja/blob/main/src/pages/Budget.tsx): `src/pages/Budget.tsx`
- [Store settings](https://github.com/nasjabhr/nasja/blob/main/src/pages/StoreSettings.tsx): `src/pages/StoreSettings.tsx`
- [Account settings](https://github.com/nasjabhr/nasja/blob/main/src/pages/Settings.tsx): `src/pages/Settings.tsx`
- [AI analysis service](https://github.com/nasjabhr/nasja/blob/main/src/lib/aiAnalysisService.ts): `src/lib/aiAnalysisService.ts`

### Data and access

- [Staff login](https://github.com/nasjabhr/nasja/blob/main/src/pages/Login.tsx): `src/pages/Login.tsx`
- [Initial setup](https://github.com/nasjabhr/nasja/blob/main/src/pages/Setup.tsx): `src/pages/Setup.tsx`
- [Browser data service](https://github.com/nasjabhr/nasja/blob/main/src/lib/dataService.ts): `src/lib/dataService.ts`
- [Backend API](https://github.com/nasjabhr/nasja/blob/main/api/index.ts): `api/index.ts`
- **Supabase database**
- **Supabase auth**

### Other components

- **Customer**
- **Shop staff**

## Connections

- Customer → Public storefront: browses
- Shop staff → Route application: opens (evidence: `src/App.tsx`)
- Route application → Public storefront: routes to (evidence: `src/App.tsx`)
- Route application → Staff login: routes to (evidence: `src/App.tsx`)
- Route application → Initial setup: routes to (evidence: `src/App.tsx`)
- Route application → Route protection: guards (evidence: `src/App.tsx`)
- Route protection → ERP layout: wraps (evidence: `src/App.tsx`)
- ERP layout → Dashboard: renders (evidence: `src/App.tsx`)
- ERP layout → Order management: renders (evidence: `src/App.tsx`)
- ERP layout → Inventory: renders (evidence: `src/App.tsx`)
- ERP layout → Expenses: renders (evidence: `src/App.tsx`)
- ERP layout → Budget: routes to (evidence: `src/App.tsx`)
- ERP layout → Store settings: renders (evidence: `src/App.tsx`)
- ERP layout → Account settings: renders (evidence: `src/App.tsx`)
- Public storefront → Browser data service: submits orders (evidence: `src/lib/dataService.ts`)
- Order management → Browser data service: persists changes (evidence: `src/pages/Orders.tsx`)
- Dashboard → Browser data service: reads data (evidence: `src/pages/Dashboard.tsx`)
- Inventory → Browser data service: reads data (evidence: `src/pages/Inventory.tsx`)
- Expenses → Browser data service: reads data (evidence: `src/pages/Expenses.tsx`)
- Budget → Browser data service: reads data (evidence: `src/pages/Budget.tsx`)
- Store settings → Browser data service: saves settings (evidence: `src/pages/StoreSettings.tsx`)
- Browser data service → Backend API: calls API (evidence: `src/lib/dataService.ts`)
- Backend API → Supabase database: reads and writes (evidence: `api/index.ts`)
- Staff login → Supabase auth: authenticates (evidence: `src/pages/Login.tsx`)
- Browser data service → Supabase auth: gets token (evidence: `src/lib/dataService.ts`)
- Customer → Public storefront: places order (evidence: `src/pages/Store.tsx`)
- AI analysis service → Dashboard: supports analysis
