# cache-jujan/brickxbrick_cap2 architecture

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

- Interactive diagram: https://gitdiagram.com/cache-jujan/brickxbrick_cap2
- Repository: https://github.com/cache-jujan/brickxbrick_cap2

## Overview

BrickXBrick is a construction-project coordination and expense-management application with web and mobile clients, a backend API, and blockchain-backed expense auditing. The principal workflow spans project and task management, field progress review, receipt capture and expense submission, then audit verification and tamper alerts. The tree and excerpts support these product areas, but do not expose most route internals or client API wiring, so those links are limited to documented mounts and sampled calls.

Main entry points: [`backend/src/server.js`](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/server.js) (Backend API), [`backend/src/lib/db.js`](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/db.js) (Application database), [`backend/src/routes/receipts.js`](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/receipts.js) (Receipt scanning), [`backend/src/routes/tasks.js`](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/tasks.js) (Tasks and progress)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Web and Mobile Clients"]
  node_web["Web application<br/>[App.jsx]"]
  node_mobile["Mobile application<br/>[_layout.tsx]"]
  node_webchain["Audit screens"]
end

subgraph group_work["Project Operations"]
  node_projects["Projects<br/>[projects.js]"]
  node_milestones["Milestones<br/>[milestones.js]"]
  node_tasks["Tasks and progress<br/>[tasks.js]"]
  node_tickets["Tickets<br/>[tickets.js]"]
end

subgraph group_expenses["Expense and Receipt"]
  node_expenses["Expense records<br/>[expenses.js]"]
  node_receipt["Receipt scanning<br/>[receipts.js]"]
  node_receiptstore["Receipt image storage<br/>[receiptStorage.js]"]
  node_vision["Receipt OCR client<br/>[visionClient.js]"]
end

subgraph group_platform["Backend Platform"]
  node_api["Backend API<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_accounts["User administration<br/>[adminUsers.js]"]
  node_sync["Offline sync<br/>[sync.js]"]
  node_notifications["Notifications<br/>[notifications.js]"]
  node_database[("Application database<br/>[db.js]")]
end

subgraph group_audit["Blockchain Audit"]
  node_chainroute["Blockchain API<br/>[blockchain.js]"]
  node_chainservice["Blockchain service"]
  node_chainwriter["Blockchain writer<br/>[blockchainWrite.js]"]
end

node_users(("Project users"))

node_users -->|"use web"| node_web
node_users -->|"use mobile"| node_mobile
node_web -->|"request API"| node_api
node_mobile -->|"request API"| node_api
node_api -->|"mounts routes"| node_auth
node_api -->|"mounts routes"| node_accounts
node_api -->|"mounts routes"| node_projects
node_api -->|"mounts routes"| node_milestones
node_api -->|"mounts routes"| node_tasks
node_api -->|"mounts routes"| node_tickets
node_api -->|"mounts routes"| node_expenses
node_api -->|"mounts routes"| node_receipt
node_api -->|"mounts routes"| node_sync
node_api -->|"mounts routes"| node_chainroute
node_api -->|"queries"| node_database
node_tasks -->|"reads and writes"| node_database
node_tasks -->|"recalculates progress"| node_milestones
node_mobile -->|"fetches assigned tasks"| node_tasks
node_receipt -->|"stores receipt"| node_receiptstore
node_receipt -->|"extracts receipt data"| node_vision
node_receipt -->|"persists scan data"| node_database
node_expenses -->|"validates receipt URL"| node_receiptstore
node_expenses -->|"stores expenses"| node_database
node_chainroute -->|"verifies expenses"| node_chainservice
node_chainservice -->|"submits hashes"| node_chainwriter
node_chainroute -->|"reads audit records"| node_database
node_webchain -.->|"renders within"| node_web
node_api -->|"serves routes"| node_notifications

click node_web "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/frontend/src/App.jsx"
click node_mobile "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/mobile/app/_layout.tsx"
click node_api "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/server.js"
click node_auth "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/auth.js"
click node_accounts "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/adminUsers.js"
click node_projects "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/projects.js"
click node_milestones "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/milestones.js"
click node_tasks "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/tasks.js"
click node_tickets "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/tickets.js"
click node_expenses "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/expenses.js"
click node_receipt "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/receipts.js"
click node_receiptstore "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/receiptStorage.js"
click node_vision "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/visionClient.js"
click node_sync "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/sync.js"
click node_notifications "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/notifications.js"
click node_database "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/db.js"
click node_chainroute "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/blockchain.js"
click node_chainservice "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/blockchainService.js"
click node_chainwriter "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/blockchain/lib/blockchainWrite.js"
click node_webchain "https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/frontend/src/pages/Blockchain/VerifyExpensePage.jsx"

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_web,node_mobile,node_webchain,node_users toneBlue
class node_projects,node_milestones,node_tasks,node_tickets toneAmber
class node_expenses,node_receipt,node_receiptstore,node_vision toneMint
class node_api,node_auth,node_accounts,node_sync,node_notifications,node_database toneRose
class node_chainroute,node_chainservice,node_chainwriter toneIndigo
```

## Components

### Web and Mobile Clients

- [Web application](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Mobile application](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/mobile/app/_layout.tsx): `mobile/app/_layout.tsx`
- [Audit screens](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/frontend/src/pages/Blockchain/VerifyExpensePage.jsx): `frontend/src/pages/Blockchain/VerifyExpensePage.jsx`

### Project Operations

- [Projects](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/projects.js): `backend/src/routes/projects.js`
- [Milestones](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/milestones.js): `backend/src/routes/milestones.js`
- [Tasks and progress](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/tasks.js): `backend/src/routes/tasks.js`
- [Tickets](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/tickets.js): `backend/src/routes/tickets.js`

### Expense and Receipt

- [Expense records](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/expenses.js): `backend/src/routes/expenses.js`
- [Receipt scanning](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/receipts.js): `backend/src/routes/receipts.js`
- [Receipt image storage](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/receiptStorage.js): `backend/src/lib/receiptStorage.js`
- [Receipt OCR client](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/visionClient.js): `backend/src/lib/visionClient.js`

### Backend Platform

- [Backend API](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/server.js): `backend/src/server.js`
- [Authentication](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [User administration](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/adminUsers.js): `backend/src/routes/adminUsers.js`
- [Offline sync](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/sync.js): `backend/src/routes/sync.js`
- [Notifications](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/notifications.js): `backend/src/routes/notifications.js`
- [Application database](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/db.js): `backend/src/lib/db.js`

### Blockchain Audit

- [Blockchain API](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/routes/blockchain.js): `backend/src/routes/blockchain.js`
- [Blockchain service](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/backend/src/lib/blockchainService.js): `backend/src/lib/blockchainService.js`
- [Blockchain writer](https://github.com/cache-jujan/brickxbrick_cap2/blob/develop/blockchain/lib/blockchainWrite.js): `blockchain/lib/blockchainWrite.js`

### Other components

- **Project users**

## Connections

- Project users → Web application: use web
- Project users → Mobile application: use mobile
- Web application → Backend API: request API
- Mobile application → Backend API: request API
- Backend API → Authentication: mounts routes
- Backend API → User administration: mounts routes
- Backend API → Projects: mounts routes
- Backend API → Milestones: mounts routes
- Backend API → Tasks and progress: mounts routes
- Backend API → Tickets: mounts routes
- Backend API → Expense records: mounts routes
- Backend API → Receipt scanning: mounts routes
- Backend API → Offline sync: mounts routes
- Backend API → Blockchain API: mounts routes
- Backend API → Application database: queries
- Tasks and progress → Application database: reads and writes
- Tasks and progress → Milestones: recalculates progress
- Mobile application → Tasks and progress: fetches assigned tasks
- Receipt scanning → Receipt image storage: stores receipt
- Receipt scanning → Receipt OCR client: extracts receipt data
- Receipt scanning → Application database: persists scan data
- Expense records → Receipt image storage: validates receipt URL
- Expense records → Application database: stores expenses
- Blockchain API → Blockchain service: verifies expenses
- Blockchain service → Blockchain writer: submits hashes
- Blockchain API → Application database: reads audit records
- Audit screens → Web application: renders within
- Backend API → Notifications: serves routes
