# devbobby/gurdianshild-main architecture

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

- Interactive diagram: https://gitdiagram.com/devbobby/gurdianshild-main
- Repository: https://github.com/devbobby/gurdianshild-main

## Overview

GuardianShield records financial transactions in an authenticated, tamper-evident ledger, then audits them asynchronously into a hash chain and S3 backups. Verification compares the chain, live transactions, and backup state; detected tampering creates incidents and locks the ledger, while authorized repair restores history from S3. Users and administrators operate these flows through the React client and Express APIs, with optional real-time event updates. Several controller and frontend details are unsampled, so the graph keeps those links only where documented or indexed evidence supports them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/App.jsx) (React application), [`backend/algorithams/verifyHashchain.js`](https://github.com/devbobby/gurdianshild-main/blob/main/backend/algorithams/verifyHashchain.js) (Chain verification), [`backend/app.js`](https://github.com/devbobby/gurdianshild-main/blob/main/backend/app.js) (Express app), [`backend/workers/auditWorker.js`](https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/auditWorker.js) (Audit worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["React application<br/>[App.jsx]"]
  node_authstate["Authentication state<br/>[AuthContext.jsx]"]
  node_socketstate["Socket state<br/>[SocketContext.jsx]"]
  node_dashboard["Ledger views<br/>[DashboardPage.jsx]"]
  node_securityview["Security view<br/>[SecurityPage.jsx]"]
  node_incidentview["Incident view<br/>[IncidentsPage.jsx]"]
  node_repairview["Repair view<br/>[RepairPage.jsx]"]
  node_adminview["Admin view<br/>[AdminPage.jsx]"]
end

subgraph group_api["API and access"]
  node_server["Express app<br/>[app.js]"]
  node_auth["Auth handlers<br/>[authController.js]"]
  node_transactions["Transaction handlers"]
  node_security["Security handlers"]
  node_incidentctl["Incident handlers"]
  node_repairctl["Repair handlers"]
  node_adminctl["Admin handlers<br/>[adminController.js]"]
end

subgraph group_ledger["Ledger audit"]
  node_database[("PostgreSQL<br/>[prisma.js]")]
  node_txservice["Transaction service"]
  node_outbox["Outbox scheduler<br/>[outboxSchedule.js]"]
  node_auditworker["Audit worker<br/>[auditWorker.js]"]
  node_hash["Hash generation<br/>[generateHash.js]"]
  node_s3[("S3 backups")]
  node_s3service["Backup service<br/>[s3BackupService.js]"]
end

subgraph group_integrity["Verification and incidents"]
  node_verification["Chain verification<br/>[verifyHashchain.js]"]
  node_verifyworker["Verification worker"]
  node_incidentrepo["Incident repository"]
end

subgraph group_ops["Repair and events"]
  node_repairqueue["Repair queue<br/>[repairQueue.js]"]
  node_repairworker["Repair worker<br/>[repairWorker.js]"]
  node_repairservice["Repair service<br/>[repairService.js]"]
  node_eventbus["Ledger event bus<br/>[ledgerEventBus.js]"]
  node_sockets["Socket server<br/>[socketServer.js]"]
end

node_user(("User or admin"))
node_redis[("Redis<br/>[redis.js]")]

node_user -->|"uses"| node_web
node_web -->|"provides auth"| node_authstate
node_web -->|"routes to"| node_dashboard
node_web -->|"routes to"| node_securityview
node_web -->|"routes to"| node_incidentview
node_web -->|"routes to"| node_repairview
node_web -->|"routes to"| node_adminview
node_web -->|"provides sockets"| node_socketstate
node_web -.->|"calls API"| node_server
node_server -->|"routes to"| node_auth
node_server -->|"routes to"| node_transactions
node_server -->|"routes to"| node_security
node_server -->|"routes to"| node_incidentctl
node_server -->|"routes to"| node_repairctl
node_server -->|"routes to"| node_adminctl
node_transactions -->|"delegates"| node_txservice
node_txservice -->|"writes transaction"| node_database
node_txservice -.->|"queues audit event"| node_outbox
node_outbox -.->|"dispatches event"| node_auditworker
node_auditworker -.->|"hashes records"| node_hash
node_auditworker -->|"writes audit chain"| node_database
node_auditworker -->|"stores backup"| node_s3service
node_s3service -->|"writes backup"| node_s3
node_security -.->|"verifies ledger"| node_verification
node_verifyworker -->|"runs verification"| node_verification
node_verification -->|"recomputes hashes"| node_hash
node_verification -->|"reads chain"| node_database
node_verification -->|"checks backup"| node_s3
node_verification -.->|"creates incidents"| node_incidentrepo
node_incidentctl -->|"delegates"| node_incidentrepo
node_adminctl -->|"verifies user chain"| node_verification
node_repairctl -->|"enqueues repair"| node_repairqueue
node_adminctl -->|"enqueues repair"| node_repairqueue
node_repairqueue -.->|"dispatches job"| node_repairworker
node_repairworker -->|"runs repair"| node_repairservice
node_repairservice -->|"reads backups"| node_s3
node_repairservice -->|"restores ledger"| node_database
node_repairservice -->|"validates incident"| node_incidentrepo
node_verification -->|"emits events"| node_eventbus
node_auditworker -.->|"emits events"| node_eventbus
node_eventbus -->|"broadcasts events"| node_sockets
node_eventbus -->|"persists events"| node_database
node_repairservice -->|"emits events"| node_eventbus
node_sockets -.->|"streams updates"| node_socketstate

click node_web "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/App.jsx"
click node_authstate "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/context/AuthContext.jsx"
click node_socketstate "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/context/SocketContext.jsx"
click node_dashboard "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_securityview "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/SecurityPage.jsx"
click node_incidentview "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/IncidentsPage.jsx"
click node_repairview "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/RepairPage.jsx"
click node_adminview "https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/AdminPage.jsx"
click node_server "https://github.com/devbobby/gurdianshild-main/blob/main/backend/app.js"
click node_auth "https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/authController.js"
click node_transactions "https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/transactionController.js"
click node_security "https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/securityController.js"
click node_incidentctl "https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/incidentController.js"
click node_repairctl "https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/repairController.js"
click node_adminctl "https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/adminController.js"
click node_database "https://github.com/devbobby/gurdianshild-main/blob/main/backend/config/prisma.js"
click node_txservice "https://github.com/devbobby/gurdianshild-main/blob/main/backend/services/transactionService.js"
click node_outbox "https://github.com/devbobby/gurdianshild-main/blob/main/backend/crone-jobs/outboxSchedule.js"
click node_auditworker "https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/auditWorker.js"
click node_hash "https://github.com/devbobby/gurdianshild-main/blob/main/backend/algorithams/generateHash.js"
click node_s3 "https://github.com/devbobby/gurdianshild-main/blob/main/backend/repositories/s3BackupRepository.js"
click node_s3service "https://github.com/devbobby/gurdianshild-main/blob/main/backend/services/s3BackupService.js"
click node_verification "https://github.com/devbobby/gurdianshild-main/blob/main/backend/algorithams/verifyHashchain.js"
click node_verifyworker "https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/verificationWorker.js"
click node_incidentrepo "https://github.com/devbobby/gurdianshild-main/blob/main/backend/repositories/incidentRepository.js"
click node_repairqueue "https://github.com/devbobby/gurdianshild-main/blob/main/backend/queues/repairQueue.js"
click node_repairworker "https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/repairWorker.js"
click node_repairservice "https://github.com/devbobby/gurdianshild-main/blob/main/backend/services/repairService.js"
click node_eventbus "https://github.com/devbobby/gurdianshild-main/blob/main/backend/events/ledgerEventBus.js"
click node_sockets "https://github.com/devbobby/gurdianshild-main/blob/main/backend/realtime/socketServer.js"
click node_redis "https://github.com/devbobby/gurdianshild-main/blob/main/backend/config/redis.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_web,node_authstate,node_socketstate,node_dashboard,node_securityview,node_incidentview,node_repairview,node_adminview,node_user toneBlue
class node_server,node_auth,node_transactions,node_security,node_incidentctl,node_repairctl,node_adminctl,node_redis toneAmber
class node_database,node_txservice,node_outbox,node_auditworker,node_hash,node_s3,node_s3service toneMint
class node_verification,node_verifyworker,node_incidentrepo toneRose
class node_repairqueue,node_repairworker,node_repairservice,node_eventbus,node_sockets toneIndigo
```

## Components

### Web client

- [React application](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Authentication state](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Socket state](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/context/SocketContext.jsx): `frontend/src/context/SocketContext.jsx`
- [Ledger views](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [Security view](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/SecurityPage.jsx): `frontend/src/pages/SecurityPage.jsx`
- [Incident view](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/IncidentsPage.jsx): `frontend/src/pages/IncidentsPage.jsx`
- [Repair view](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/RepairPage.jsx): `frontend/src/pages/RepairPage.jsx`
- [Admin view](https://github.com/devbobby/gurdianshild-main/blob/main/frontend/src/pages/AdminPage.jsx): `frontend/src/pages/AdminPage.jsx`

### API and access

- [Express app](https://github.com/devbobby/gurdianshild-main/blob/main/backend/app.js): `backend/app.js`
- [Auth handlers](https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Transaction handlers](https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/transactionController.js): `backend/controllers/transactionController.js`
- [Security handlers](https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/securityController.js): `backend/controllers/securityController.js`
- [Incident handlers](https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/incidentController.js): `backend/controllers/incidentController.js`
- [Repair handlers](https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/repairController.js): `backend/controllers/repairController.js`
- [Admin handlers](https://github.com/devbobby/gurdianshild-main/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`

### Ledger audit

- [PostgreSQL](https://github.com/devbobby/gurdianshild-main/blob/main/backend/config/prisma.js): `backend/config/prisma.js`
- [Transaction service](https://github.com/devbobby/gurdianshild-main/blob/main/backend/services/transactionService.js): `backend/services/transactionService.js`
- [Outbox scheduler](https://github.com/devbobby/gurdianshild-main/blob/main/backend/crone-jobs/outboxSchedule.js): `backend/crone-jobs/outboxSchedule.js`
- [Audit worker](https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/auditWorker.js): `backend/workers/auditWorker.js`
- [Hash generation](https://github.com/devbobby/gurdianshild-main/blob/main/backend/algorithams/generateHash.js): `backend/algorithams/generateHash.js`
- [S3 backups](https://github.com/devbobby/gurdianshild-main/blob/main/backend/repositories/s3BackupRepository.js): `backend/repositories/s3BackupRepository.js`
- [Backup service](https://github.com/devbobby/gurdianshild-main/blob/main/backend/services/s3BackupService.js): `backend/services/s3BackupService.js`

### Verification and incidents

- [Chain verification](https://github.com/devbobby/gurdianshild-main/blob/main/backend/algorithams/verifyHashchain.js): `backend/algorithams/verifyHashchain.js`
- [Verification worker](https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/verificationWorker.js): `backend/workers/verificationWorker.js`
- [Incident repository](https://github.com/devbobby/gurdianshild-main/blob/main/backend/repositories/incidentRepository.js): `backend/repositories/incidentRepository.js`

### Repair and events

- [Repair queue](https://github.com/devbobby/gurdianshild-main/blob/main/backend/queues/repairQueue.js): `backend/queues/repairQueue.js`
- [Repair worker](https://github.com/devbobby/gurdianshild-main/blob/main/backend/workers/repairWorker.js): `backend/workers/repairWorker.js`
- [Repair service](https://github.com/devbobby/gurdianshild-main/blob/main/backend/services/repairService.js): `backend/services/repairService.js`
- [Ledger event bus](https://github.com/devbobby/gurdianshild-main/blob/main/backend/events/ledgerEventBus.js): `backend/events/ledgerEventBus.js`
- [Socket server](https://github.com/devbobby/gurdianshild-main/blob/main/backend/realtime/socketServer.js): `backend/realtime/socketServer.js`

### Other components

- **User or admin**
- [Redis](https://github.com/devbobby/gurdianshild-main/blob/main/backend/config/redis.js): `backend/config/redis.js`

## Connections

- User or admin → React application: uses
- React application → Authentication state: provides auth (evidence: `frontend/src/App.jsx`)
- React application → Ledger views: routes to (evidence: `frontend/src/App.jsx`)
- React application → Security view: routes to (evidence: `frontend/src/App.jsx`)
- React application → Incident view: routes to (evidence: `frontend/src/App.jsx`)
- React application → Repair view: routes to (evidence: `frontend/src/App.jsx`)
- React application → Admin view: routes to (evidence: `frontend/src/App.jsx`)
- React application → Socket state: provides sockets (evidence: `frontend/src/App.jsx`)
- React application → Express app: calls API
- Express app → Auth handlers: routes to (evidence: `backend/app.js`)
- Express app → Transaction handlers: routes to (evidence: `backend/app.js`)
- Express app → Security handlers: routes to (evidence: `backend/app.js`)
- Express app → Incident handlers: routes to (evidence: `backend/app.js`)
- Express app → Repair handlers: routes to (evidence: `backend/app.js`)
- Express app → Admin handlers: routes to (evidence: `backend/app.js`)
- Transaction handlers → Transaction service: delegates (evidence: `backend/controllers/transactionController.js`)
- Transaction service → PostgreSQL: writes transaction (evidence: `backend/services/transactionService.js`)
- Transaction service → Outbox scheduler: queues audit event
- Outbox scheduler → Audit worker: dispatches event
- Audit worker → Hash generation: hashes records (evidence: `backend/workers/auditWorker.js`)
- Audit worker → PostgreSQL: writes audit chain (evidence: `backend/workers/auditWorker.js`)
- Audit worker → Backup service: stores backup (evidence: `backend/workers/auditWorker.js`)
- Backup service → S3 backups: writes backup (evidence: `backend/services/s3BackupService.js`)
- Security handlers → Chain verification: verifies ledger
- Verification worker → Chain verification: runs verification (evidence: `backend/workers/verificationWorker.js`)
- Chain verification → Hash generation: recomputes hashes (evidence: `backend/algorithams/verifyHashchain.js`)
- Chain verification → PostgreSQL: reads chain (evidence: `backend/algorithams/verifyHashchain.js`)
- Chain verification → S3 backups: checks backup (evidence: `backend/algorithams/verifyHashchain.js`)
- Chain verification → Incident repository: creates incidents
- Incident handlers → Incident repository: delegates (evidence: `backend/controllers/incidentController.js`)
- Admin handlers → Chain verification: verifies user chain (evidence: `backend/controllers/adminController.js`)
- Repair handlers → Repair queue: enqueues repair (evidence: `backend/controllers/repairController.js`)
- Admin handlers → Repair queue: enqueues repair (evidence: `backend/controllers/adminController.js`)
- Repair queue → Repair worker: dispatches job
- Repair worker → Repair service: runs repair (evidence: `backend/workers/repairWorker.js`)
- Repair service → S3 backups: reads backups (evidence: `backend/services/repairService.js`)
- Repair service → PostgreSQL: restores ledger (evidence: `backend/services/repairService.js`)
- Repair service → Incident repository: validates incident (evidence: `backend/services/repairService.js`)
- Chain verification → Ledger event bus: emits events (evidence: `backend/algorithams/verifyHashchain.js`)
- Audit worker → Ledger event bus: emits events (evidence: `backend/workers/auditWorker.js`)
- Ledger event bus → Socket server: broadcasts events (evidence: `backend/realtime/socketServer.js`)
- Ledger event bus → PostgreSQL: persists events (evidence: `backend/events/ledgerEventBus.js`)
- Repair service → Ledger event bus: emits events (evidence: `backend/services/repairService.js`)
- Socket server → Socket state: streams updates
