# alfaqih94/si-kasir architecture

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

- Interactive diagram: https://gitdiagram.com/alfaqih94/si-kasir
- Repository: https://github.com/alfaqih94/si-kasir

## Overview

Kedai Kopi POS is a branch-aware point-of-sale and administration app. Staff sign in, are routed by role, and cashiers build orders from available products; checkout uses a Firestore transaction for the sale and tracked stock. Admins manage products, branches, users, and stock, and review sales dashboards and reports. The sampled pages show direct Firebase access rather than a shared application service layer. Several page excerpts are partial, so uncertain calls between pages and the admin user-update route are not shown.

Main entry points: [`src/lib/firebase.js`](https://github.com/alfaqih94/si-kasir/blob/main/src/lib/firebase.js) (Firebase client), [`src/app/login/page.js`](https://github.com/alfaqih94/si-kasir/blob/main/src/app/login/page.js) (Sign in), [`src/app/admin/users/page.js`](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/users/page.js) (User management), [`src/context/AuthContext.js`](https://github.com/alfaqih94/si-kasir/blob/main/src/context/AuthContext.js) (Auth context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_login["Sign in<br/>[page.js]"]
  node_authcontext["Auth context<br/>[AuthContext.js]"]
  node_guard["Protected routes<br/>[ProtectedRoute.js]"]
end

subgraph group_sales["Point of sale"]
  node_cashier["Cashier POS<br/>[page.js]"]
  node_cashierreport["Cashier report<br/>[page.js]"]
  node_profile["Cashier profile<br/>[page.js]"]
end

subgraph group_admin["Administration"]
  node_dashboard["Admin dashboard<br/>[page.js]"]
  node_products["Product management<br/>[page.js]"]
  node_branches["Branch management<br/>[page.js]"]
  node_stockadmin["Stock management<br/>[page.js]"]
  node_users["User management<br/>[page.js]"]
  node_daily["Daily sales<br/>[page.js]"]
  node_reports["Sales reports<br/>[page.js]"]
  node_userupdate["Auth update API<br/>[route.js]"]
end

subgraph group_data["Firebase services"]
  node_firebase["Firebase client<br/>[firebase.js]"]
  node_firestore[("Firestore")]
  node_firebaseauth["Firebase Auth"]
  node_adminauth["Firebase Admin Auth"]
end

node_staff(("Staff"))

node_staff -->|"submits credentials"| node_login
node_login -->|"signs in"| node_authcontext
node_authcontext -->|"observes auth; loads profile"| node_firebase
node_login -->|"reads role"| node_firebase
node_firebase -->|"authenticates"| node_firebaseauth
node_firebase -->|"reads and writes"| node_firestore
node_login -->|"routes by role"| node_guard
node_staff -->|"uses POS"| node_cashier
node_cashier -->|"loads products; checks out"| node_firebase
node_cashierreport -->|"reads sales data"| node_firebase
node_profile -->|"accesses profile data"| node_firebase
node_dashboard -->|"reads sales data"| node_firebase
node_products -->|"manages products"| node_firebase
node_branches -->|"manages branches"| node_firebase
node_stockadmin -->|"reads and saves stock"| node_firebase
node_users -->|"manages user profiles"| node_firebase
node_users -->|"creates user accounts"| node_firebaseauth
node_daily -->|"reads daily sales data"| node_firebase
node_reports -->|"reads and deletes transactions"| node_firebase
node_userupdate -->|"updates credentials"| node_adminauth

click node_login "https://github.com/alfaqih94/si-kasir/blob/main/src/app/login/page.js"
click node_authcontext "https://github.com/alfaqih94/si-kasir/blob/main/src/context/AuthContext.js"
click node_guard "https://github.com/alfaqih94/si-kasir/blob/main/src/components/ProtectedRoute.js"
click node_cashier "https://github.com/alfaqih94/si-kasir/blob/main/src/app/kasir/page.js"
click node_cashierreport "https://github.com/alfaqih94/si-kasir/blob/main/src/app/kasir/report/page.js"
click node_profile "https://github.com/alfaqih94/si-kasir/blob/main/src/app/kasir/profile/page.js"
click node_dashboard "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/page.js"
click node_products "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/products/page.js"
click node_branches "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/stores/page.js"
click node_stockadmin "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/stocks/page.js"
click node_users "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/users/page.js"
click node_daily "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/daily/page.js"
click node_reports "https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/reports/page.js"
click node_userupdate "https://github.com/alfaqih94/si-kasir/blob/main/src/app/api/admin/users/update/route.js"
click node_firebase "https://github.com/alfaqih94/si-kasir/blob/main/src/lib/firebase.js"

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_authcontext,node_guard toneBlue
class node_cashier,node_cashierreport,node_profile toneAmber
class node_dashboard,node_products,node_branches,node_stockadmin,node_users,node_daily,node_reports,node_userupdate toneMint
class node_firebase,node_firestore,node_firebaseauth,node_adminauth toneRose
class node_staff toneIndigo
```

## Components

### Identity and access

- [Sign in](https://github.com/alfaqih94/si-kasir/blob/main/src/app/login/page.js): `src/app/login/page.js`
- [Auth context](https://github.com/alfaqih94/si-kasir/blob/main/src/context/AuthContext.js): `src/context/AuthContext.js`
- [Protected routes](https://github.com/alfaqih94/si-kasir/blob/main/src/components/ProtectedRoute.js): `src/components/ProtectedRoute.js`

### Point of sale

- [Cashier POS](https://github.com/alfaqih94/si-kasir/blob/main/src/app/kasir/page.js): `src/app/kasir/page.js`
- [Cashier report](https://github.com/alfaqih94/si-kasir/blob/main/src/app/kasir/report/page.js): `src/app/kasir/report/page.js`
- [Cashier profile](https://github.com/alfaqih94/si-kasir/blob/main/src/app/kasir/profile/page.js): `src/app/kasir/profile/page.js`

### Administration

- [Admin dashboard](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/page.js): `src/app/admin/page.js`
- [Product management](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/products/page.js): `src/app/admin/products/page.js`
- [Branch management](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/stores/page.js): `src/app/admin/stores/page.js`
- [Stock management](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/stocks/page.js): `src/app/admin/stocks/page.js`
- [User management](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/users/page.js): `src/app/admin/users/page.js`
- [Daily sales](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/daily/page.js): `src/app/admin/daily/page.js`
- [Sales reports](https://github.com/alfaqih94/si-kasir/blob/main/src/app/admin/reports/page.js): `src/app/admin/reports/page.js`
- [Auth update API](https://github.com/alfaqih94/si-kasir/blob/main/src/app/api/admin/users/update/route.js): `src/app/api/admin/users/update/route.js`

### Firebase services

- [Firebase client](https://github.com/alfaqih94/si-kasir/blob/main/src/lib/firebase.js): `src/lib/firebase.js`
- **Firestore**
- **Firebase Auth**
- **Firebase Admin Auth**

### Other components

- **Staff**

## Connections

- Staff → Sign in: submits credentials
- Sign in → Auth context: signs in
- Auth context → Firebase client: observes auth; loads profile
- Sign in → Firebase client: reads role
- Firebase client → Firebase Auth: authenticates
- Firebase client → Firestore: reads and writes
- Sign in → Protected routes: routes by role
- Staff → Cashier POS: uses POS
- Cashier POS → Firebase client: loads products; checks out
- Cashier report → Firebase client: reads sales data
- Cashier profile → Firebase client: accesses profile data
- Admin dashboard → Firebase client: reads sales data
- Product management → Firebase client: manages products
- Branch management → Firebase client: manages branches
- Stock management → Firebase client: reads and saves stock
- User management → Firebase client: manages user profiles
- User management → Firebase Auth: creates user accounts
- Daily sales → Firebase client: reads daily sales data
- Sales reports → Firebase client: reads and deletes transactions
- Auth update API → Firebase Admin Auth: updates credentials
