# pallab-js/fuelstation_nextjs architecture

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

- Interactive diagram: https://gitdiagram.com/pallab-js/fuelstation_nextjs
- Repository: https://github.com/pallab-js/fuelstation_nextjs

## Overview

FuelOps is a local-first dashboard for operating multiple fuel outlets. Staff sign in under a role and station scope, then use operational screens to record sales, shifts, stock movements, expenses, and credit activity; dashboard, alerts, station views, and reports present derived results. The documented runtime layers are routes, live-query hooks, repositories, domain logic, and browser IndexedDB. The graph preserves the README’s major product areas; some route and repository links are supported by the SOURCE INDEX rather than inspected source excerpts. Offline operation and JSON backup are documented capabilities.

Main entry points: [`src/lib/repo/ops.ts`](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/ops.ts) (Operation repositories), [`src/lib/repo/queries.ts`](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/queries.ts) (Read repositories), [`src/lib/db/dexie.ts`](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/db/dexie.ts) (IndexedDB), [`src/lib/db/seed.ts`](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/db/seed.ts) (Demo data seeding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_login["Sign-in<br/>[page.tsx]"]
  node_settings["Settings and backup<br/>[page.tsx]"]
end

subgraph group_operations["Station operations"]
  node_pos["POS sales<br/>[page.tsx]"]
  node_shifts["Shifts and cash<br/>[page.tsx]"]
  node_inventory["Tank inventory<br/>[page.tsx]"]
  node_credit["Credit ledger<br/>[page.tsx]"]
  node_expenses["Expenses<br/>[page.tsx]"]
end

subgraph group_insight["Monitoring and reporting"]
  node_dashboard["Network dashboard<br/>[page.tsx]"]
  node_stations["Station views<br/>[page.tsx]"]
  node_alerts["Alerts<br/>[page.tsx]"]
  node_reports["Reports and export<br/>[page.tsx]"]
end

subgraph group_services["Application services"]
  node_session["Role and scope<br/>[session-store.ts]"]
  node_live["Live-query hooks<br/>[use-live.ts]"]
  node_queries["Read repositories<br/>[queries.ts]"]
  node_ops["Operation repositories<br/>[ops.ts]"]
  node_alertrepo["Alert repository<br/>[alerts.ts]"]
  node_analytics["KPI and trend logic<br/>[analytics.ts]"]
  node_aging["Credit aging logic<br/>[aging.ts]"]
  node_tanklogic["Tank calculations<br/>[tanks.ts]"]
  node_domainalerts["Alert calculations<br/>[alerts.ts]"]
end

subgraph group_storage["Local data"]
  node_database[("IndexedDB<br/>[dexie.ts]")]
  node_seed["Demo data seeding<br/>[seed.ts]"]
end

node_staff(("Station staff"))

node_staff -->|"signs in"| node_login
node_login -->|"sets session"| node_session
node_staff -->|"records sales"| node_pos
node_staff -->|"closes shift"| node_shifts
node_staff -->|"records dip"| node_inventory
node_pos -->|"records transactions"| node_ops
node_shifts -->|"records reconciliation"| node_ops
node_inventory -->|"records stock movements"| node_ops
node_credit -->|"manages accounts"| node_ops
node_expenses -->|"records expenses"| node_ops
node_dashboard -->|"loads metrics"| node_queries
node_stations -->|"loads stations"| node_queries
node_reports -->|"loads report data"| node_queries
node_alerts -->|"loads alerts"| node_alertrepo
node_settings -->|"backs up data"| node_database
node_dashboard -->|"subscribes to updates"| node_live
node_queries -->|"reads records"| node_database
node_ops -->|"writes records"| node_database
node_ops -->|"checks credit balance"| node_aging
node_ops -->|"synchronizes alerts"| node_alertrepo
node_queries -->|"computes dashboard metrics"| node_analytics
node_queries -->|"computes aging"| node_aging
node_queries -->|"computes tank status"| node_tanklogic
node_alertrepo -.->|"stores alerts"| node_database
node_seed -.->|"seeds demo records"| node_database
node_seed -->|"uses alert logic"| node_domainalerts
node_seed -->|"uses tank logic"| node_tanklogic
node_database -.->|"feeds live queries"| node_live

click node_login "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/login/page.tsx"
click node_session "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/session/session-store.ts"
click node_dashboard "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/dashboard/page.tsx"
click node_pos "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/pos/page.tsx"
click node_shifts "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/shifts/page.tsx"
click node_inventory "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/inventory/page.tsx"
click node_credit "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/credit/page.tsx"
click node_expenses "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/expenses/page.tsx"
click node_stations "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/stations/page.tsx"
click node_alerts "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/alerts/page.tsx"
click node_reports "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/reports/page.tsx"
click node_settings "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/settings/page.tsx"
click node_live "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/hooks/use-live.ts"
click node_queries "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/queries.ts"
click node_ops "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/ops.ts"
click node_alertrepo "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/alerts.ts"
click node_analytics "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/analytics.ts"
click node_aging "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/aging.ts"
click node_tanklogic "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/tanks.ts"
click node_domainalerts "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/alerts.ts"
click node_database "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/db/dexie.ts"
click node_seed "https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/db/seed.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_settings toneBlue
class node_pos,node_shifts,node_inventory,node_credit,node_expenses toneAmber
class node_dashboard,node_stations,node_alerts,node_reports toneMint
class node_session,node_live,node_queries,node_ops,node_alertrepo,node_analytics,node_aging,node_tanklogic,node_domainalerts toneRose
class node_database,node_seed,node_staff toneIndigo
```

## Components

### App experience

- [Sign-in](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Settings and backup](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/settings/page.tsx): `src/app/(app)/settings/page.tsx`

### Station operations

- [POS sales](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/pos/page.tsx): `src/app/(app)/pos/page.tsx`
- [Shifts and cash](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/shifts/page.tsx): `src/app/(app)/shifts/page.tsx`
- [Tank inventory](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/inventory/page.tsx): `src/app/(app)/inventory/page.tsx`
- [Credit ledger](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/credit/page.tsx): `src/app/(app)/credit/page.tsx`
- [Expenses](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/expenses/page.tsx): `src/app/(app)/expenses/page.tsx`

### Monitoring and reporting

- [Network dashboard](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/dashboard/page.tsx): `src/app/(app)/dashboard/page.tsx`
- [Station views](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/stations/page.tsx): `src/app/(app)/stations/page.tsx`
- [Alerts](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/alerts/page.tsx): `src/app/(app)/alerts/page.tsx`
- [Reports and export](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/app/(app)/reports/page.tsx): `src/app/(app)/reports/page.tsx`

### Application services

- [Role and scope](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/session/session-store.ts): `src/lib/session/session-store.ts`
- [Live-query hooks](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/hooks/use-live.ts): `src/lib/hooks/use-live.ts`
- [Read repositories](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/queries.ts): `src/lib/repo/queries.ts`
- [Operation repositories](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/ops.ts): `src/lib/repo/ops.ts`
- [Alert repository](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/repo/alerts.ts): `src/lib/repo/alerts.ts`
- [KPI and trend logic](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/analytics.ts): `src/lib/domain/analytics.ts`
- [Credit aging logic](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/aging.ts): `src/lib/domain/aging.ts`
- [Tank calculations](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/tanks.ts): `src/lib/domain/tanks.ts`
- [Alert calculations](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/domain/alerts.ts): `src/lib/domain/alerts.ts`

### Local data

- [IndexedDB](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/db/dexie.ts): `src/lib/db/dexie.ts`
- [Demo data seeding](https://github.com/pallab-js/fuelstation_nextjs/blob/main/src/lib/db/seed.ts): `src/lib/db/seed.ts`

### Other components

- **Station staff**

## Connections

- Station staff → Sign-in: signs in (evidence: `README.md`)
- Sign-in → Role and scope: sets session (evidence: `src/app/login/page.tsx`)
- Station staff → POS sales: records sales (evidence: `README.md`)
- Station staff → Shifts and cash: closes shift (evidence: `README.md`)
- Station staff → Tank inventory: records dip (evidence: `README.md`)
- POS sales → Operation repositories: records transactions (evidence: `src/app/(app)/pos/page.tsx`)
- Shifts and cash → Operation repositories: records reconciliation (evidence: `src/app/(app)/shifts/page.tsx`)
- Tank inventory → Operation repositories: records stock movements (evidence: `src/app/(app)/inventory/page.tsx`)
- Credit ledger → Operation repositories: manages accounts (evidence: `src/app/(app)/credit/page.tsx`)
- Expenses → Operation repositories: records expenses (evidence: `src/app/(app)/expenses/page.tsx`)
- Network dashboard → Read repositories: loads metrics (evidence: `src/app/(app)/dashboard/page.tsx`)
- Station views → Read repositories: loads stations (evidence: `src/app/(app)/stations/page.tsx`)
- Reports and export → Read repositories: loads report data (evidence: `src/app/(app)/reports/page.tsx`)
- Alerts → Alert repository: loads alerts (evidence: `src/app/(app)/alerts/page.tsx`)
- Settings and backup → IndexedDB: backs up data (evidence: `src/app/(app)/settings/page.tsx`)
- Network dashboard → Live-query hooks: subscribes to updates (evidence: `src/app/(app)/dashboard/page.tsx`)
- Read repositories → IndexedDB: reads records (evidence: `src/lib/repo/queries.ts`)
- Operation repositories → IndexedDB: writes records (evidence: `src/lib/repo/ops.ts`)
- Operation repositories → Credit aging logic: checks credit balance (evidence: `src/lib/repo/ops.ts`)
- Operation repositories → Alert repository: synchronizes alerts (evidence: `src/lib/repo/ops.ts`)
- Read repositories → KPI and trend logic: computes dashboard metrics (evidence: `src/lib/repo/queries.ts`)
- Read repositories → Credit aging logic: computes aging (evidence: `src/lib/repo/queries.ts`)
- Read repositories → Tank calculations: computes tank status (evidence: `src/lib/repo/queries.ts`)
- Alert repository → IndexedDB: stores alerts
- Demo data seeding → IndexedDB: seeds demo records
- Demo data seeding → Alert calculations: uses alert logic (evidence: `src/lib/db/seed.ts`)
- Demo data seeding → Tank calculations: uses tank logic (evidence: `src/lib/db/seed.ts`)
- IndexedDB → Live-query hooks: feeds live queries
