# usmankhalid172/hisabdo-mern-webapp architecture

> Architecture diagram of the GitHub repository usmankhalid172/hisabdo-mern-webapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/usmankhalid172/hisabdo-mern-webapp
- Repository: https://github.com/usmankhalid172/hisabdo-mern-webapp

## Overview

HisabDo is a merchant bookkeeping web application for managing customers, vendors, transactions, cash flow, reports, and account access. The main documented workflow is merchant sign-in or registration, session protection, then using the dashboard to manage business records and review results. The repository contains both a Day 31 snapshot and a root application; this map focuses on the root application. Source evidence is uneven: authentication behavior is documented, while several product pages and services are indexed but not excerpted, so uncertain page-to-API links are omitted.

Main entry points: [`src/lib/auth-token.ts`](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/auth-token.ts) (JWT verification), [`src/app/api/auth/login/route.ts`](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/auth/login/route.ts) (Authentication API), [`src/app/(auth)/login/page.tsx`](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(auth)/login/page.tsx) (Login and registration), [`src/middleware.ts`](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/middleware.ts) (Route protection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_login["Login and registration<br/>[page.tsx]"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_auth_context["Auth state<br/>[AuthContext.tsx]"]
  node_route_guard["Route protection<br/>[middleware.ts]"]
end

subgraph group_records["Business records"]
  node_customers["Customer records<br/>[page.tsx]"]
  node_customer_api["Customer API<br/>[route.ts]"]
  node_vendors["Vendor records<br/>[page.jsx]"]
  node_vendor_api["Vendor API<br/>[route.js]"]
  node_transactions["Transactions<br/>[page.tsx]"]
  node_transaction_api["Transaction API<br/>[route.ts]"]
  node_expenses["Expense tracking<br/>[page.tsx]"]
end

subgraph group_insights["Dashboard and insights"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_summary_api["Dashboard summary<br/>[route.js]"]
  node_reports["Reports<br/>[page.tsx]"]
  node_reports_api["Reports API<br/>[route.js]"]
end

subgraph group_platform["Shared services"]
  node_hisabdo_service["Business services<br/>[hisabdoService.ts]"]
  node_chatbot["AI assistant<br/>[chatbotService.ts]"]
  node_subscriptions["Subscriptions"]
  node_supabase[("Supabase data<br/>[server.ts]")]
  node_db_store[("Local data store<br/>[db-store.js]")]
  node_token_auth["JWT verification<br/>[auth-token.ts]"]
end

node_merchant(("Merchant"))

node_merchant -->|"starts session"| node_login
node_login -->|"submits credentials"| node_auth_api
node_auth_api -->|"issues tokens"| node_token_auth
node_auth_context -->|"uses client"| node_token_auth
node_merchant -->|"requests protected routes"| node_route_guard
node_route_guard -->|"redirects unauthenticated"| node_login
node_customer_api -->|"reads and writes"| node_supabase
node_transaction_api -->|"verifies session"| node_token_auth
node_summary_api -->|"checks token"| node_token_auth
node_reports_api -->|"reads records"| node_db_store
node_vendor_api -->|"reads and writes"| node_db_store
node_auth_api -->|"verifies credentials"| node_token_auth

click node_login "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(auth)/login/page.tsx"
click node_auth_api "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/auth/login/route.ts"
click node_auth_context "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/context/AuthContext.tsx"
click node_route_guard "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/middleware.ts"
click node_customers "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/customers/page.tsx"
click node_customer_api "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/customers/route.ts"
click node_vendors "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/vendors/page.jsx"
click node_vendor_api "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/vendors/route.js"
click node_transactions "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/transactions/page.tsx"
click node_transaction_api "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/transactions/route.ts"
click node_expenses "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/expenses/page.tsx"
click node_dashboard "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/dashboard/page.tsx"
click node_summary_api "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/dashboard/summary/route.js"
click node_reports "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/reports/page.tsx"
click node_reports_api "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/reports/route.js"
click node_hisabdo_service "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/services/hisabdoService.ts"
click node_chatbot "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/services/chatbotService.ts"
click node_subscriptions "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/services/subscriptionService.ts"
click node_supabase "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/supabase/server.ts"
click node_db_store "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/db-store.js"
click node_token_auth "https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/auth-token.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_login,node_auth_api,node_auth_context,node_route_guard toneBlue
class node_customers,node_customer_api,node_vendors,node_vendor_api,node_transactions,node_transaction_api,node_expenses toneAmber
class node_dashboard,node_summary_api,node_reports,node_reports_api toneMint
class node_hisabdo_service,node_chatbot,node_subscriptions,node_supabase,node_db_store,node_token_auth toneRose
class node_merchant toneIndigo
```

## Components

### Identity and access

- [Login and registration](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Authentication API](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Auth state](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Route protection](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/middleware.ts): `src/middleware.ts`

### Business records

- [Customer records](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/customers/page.tsx): `src/app/(dashboard)/customers/page.tsx`
- [Customer API](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/customers/route.ts): `src/app/api/customers/route.ts`
- [Vendor records](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/vendors/page.jsx): `src/app/(dashboard)/vendors/page.jsx`
- [Vendor API](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/vendors/route.js): `src/app/api/vendors/route.js`
- [Transactions](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/transactions/page.tsx): `src/app/(dashboard)/transactions/page.tsx`
- [Transaction API](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/transactions/route.ts): `src/app/api/transactions/route.ts`
- [Expense tracking](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/expenses/page.tsx): `src/app/(dashboard)/expenses/page.tsx`

### Dashboard and insights

- [Dashboard](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/dashboard/page.tsx): `src/app/(dashboard)/dashboard/page.tsx`
- [Dashboard summary](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/dashboard/summary/route.js): `src/app/api/dashboard/summary/route.js`
- [Reports](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/(dashboard)/reports/page.tsx): `src/app/(dashboard)/reports/page.tsx`
- [Reports API](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/app/api/reports/route.js): `src/app/api/reports/route.js`

### Shared services

- [Business services](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/services/hisabdoService.ts): `src/services/hisabdoService.ts`
- [AI assistant](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/services/chatbotService.ts): `src/services/chatbotService.ts`
- [Subscriptions](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/services/subscriptionService.ts): `src/services/subscriptionService.ts`
- [Supabase data](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Local data store](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/db-store.js): `src/lib/db-store.js`
- [JWT verification](https://github.com/usmankhalid172/hisabdo-mern-webapp/blob/main/src/lib/auth-token.ts): `src/lib/auth-token.ts`

### Other components

- **Merchant**

## Connections

- Merchant → Login and registration: starts session (evidence: `README.md`)
- Login and registration → Authentication API: submits credentials (evidence: `README.md`)
- Authentication API → JWT verification: issues tokens (evidence: `src/app/api/auth/login/route.ts`)
- Auth state → JWT verification: uses client (evidence: `src/context/AuthContext.tsx`)
- Merchant → Route protection: requests protected routes (evidence: `README.md`)
- Route protection → Login and registration: redirects unauthenticated (evidence: `README.md`)
- Customer API → Supabase data: reads and writes (evidence: `src/app/api/customers/route.ts`)
- Transaction API → JWT verification: verifies session (evidence: `src/app/api/transactions/route.ts`)
- Dashboard summary → JWT verification: checks token (evidence: `src/app/api/dashboard/summary/route.js`)
- Reports API → Local data store: reads records (evidence: `src/app/api/reports/route.js`)
- Vendor API → Local data store: reads and writes (evidence: `src/app/api/vendors/route.js`)
- Authentication API → JWT verification: verifies credentials (evidence: `src/app/api/auth/login/route.ts`)
