# andrefan1406/stroy-hub architecture

> Architecture diagram of the GitHub repository andrefan1406/stroy-hub, 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/andrefan1406/stroy-hub
- Repository: https://github.com/andrefan1406/stroy-hub
- Video tour (about a minute): https://gitdiagram.com/andrefan1406/stroy-hub/video

## Overview

This is an internal construction-operations portal: employees submit specialized requests and use workforce, concrete, equipment, and project reports; administrators manage access and reporting data. The React router is the visible entry point, while an Express backend provides concrete request/report APIs, administrative checks, and an AI chat. The backend also synchronizes several operational datasets into SQLite. The README describes only Create React App setup, so product capabilities are inferred from the source tree and sampled comments; unsampled route and subsystem wiring is shown only where the excerpts establish it.

Main entry points: [`src/App.js`](https://github.com/andrefan1406/stroy-hub/blob/main/src/App.js) (App router), [`server/index.js`](https://github.com/andrefan1406/stroy-hub/blob/main/server/index.js) (Express API), [`server/db.js`](https://github.com/andrefan1406/stroy-hub/blob/main/server/db.js) (SQLite database), [`server/chatHandler.js`](https://github.com/andrefan1406/stroy-hub/blob/main/server/chatHandler.js) (Text-to-SQL chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Employee portal"]
  node_app["App router<br/>[App.js]"]
  node_requests["Request forms<br/>[RequestPage.js]"]
  node_concrete_request["Concrete requests"]
  node_special_requests["Specialist requests"]
end

subgraph group_ops["Operations reporting"]
  node_reports["Reports and dashboards"]
  node_concrete_views["Concrete reports"]
  node_people_views["People reports"]
  node_admin_views["Admin pages"]
  node_pending_table["Pending requests"]
end

subgraph group_backend["Backend services"]
  node_api["Express API<br/>[index.js]"]
  node_chat["Text-to-SQL chat<br/>[chatHandler.js]"]
  node_sql_guard["SQL safety<br/>[sqlGuard.js]"]
  node_sync_concrete["Concrete sync<br/>[syncConcrete.js]"]
  node_sync_people["People sync<br/>[syncPeople.js]"]
  node_sync_objects["Object sync<br/>[syncObjects.js]"]
  node_sync_defects["Defect sync<br/>[syncDefectActs.js]"]
end

subgraph group_data["Data and integrations"]
  node_sqlite[("SQLite database<br/>[db.js]")]
  node_ollama{{"Ollama Cloud"}}
  node_sheets["Google Sheets"]
end

node_employee(("Employee"))

node_employee -->|"uses"| node_app
node_app -->|"routes to"| node_requests
node_app -->|"routes to"| node_concrete_request
node_app -->|"routes to"| node_special_requests
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_concrete_views
node_app -->|"routes to"| node_people_views
node_app -->|"routes to"| node_admin_views
node_concrete_request -->|"displays"| node_pending_table
node_pending_table -->|"fetches pending"| node_api
node_pending_table -->|"posts hide"| node_api
node_api -->|"dispatches chat"| node_chat
node_chat -->|"validates SQL"| node_sql_guard
node_chat -->|"queries"| node_sqlite
node_chat -->|"requests model"| node_ollama
node_api -->|"initializes schema"| node_sqlite
node_api -->|"starts sync"| node_sync_concrete
node_api -->|"starts sync"| node_sync_people
node_api -->|"starts sync"| node_sync_objects
node_api -->|"starts sync"| node_sync_defects
node_sync_concrete -->|"stores records"| node_sqlite
node_sync_people -->|"stores records"| node_sqlite
node_sync_objects -->|"stores records"| node_sqlite
node_sync_defects -->|"stores records"| node_sqlite
node_sync_people -.->|"imports data"| node_sheets

click node_app "https://github.com/andrefan1406/stroy-hub/blob/main/src/App.js"
click node_requests "https://github.com/andrefan1406/stroy-hub/blob/main/src/RequestPage.js"
click node_concrete_request "https://github.com/andrefan1406/stroy-hub/blob/main/src/ConcreteRequestPage.js"
click node_special_requests "https://github.com/andrefan1406/stroy-hub/blob/main/src/ElectricansRequestPage.js"
click node_reports "https://github.com/andrefan1406/stroy-hub/blob/main/src/ReportsDashboardPage.js"
click node_concrete_views "https://github.com/andrefan1406/stroy-hub/blob/main/src/pages/ConcreteDashboardPage.jsx"
click node_people_views "https://github.com/andrefan1406/stroy-hub/blob/main/src/PeopleReportPage.js"
click node_admin_views "https://github.com/andrefan1406/stroy-hub/blob/main/src/pages/AdminDashboardPage.jsx"
click node_pending_table "https://github.com/andrefan1406/stroy-hub/blob/main/src/components/ConcretePendingRequestsTable.jsx"
click node_api "https://github.com/andrefan1406/stroy-hub/blob/main/server/index.js"
click node_chat "https://github.com/andrefan1406/stroy-hub/blob/main/server/chatHandler.js"
click node_sql_guard "https://github.com/andrefan1406/stroy-hub/blob/main/server/sqlGuard.js"
click node_sync_concrete "https://github.com/andrefan1406/stroy-hub/blob/main/server/syncConcrete.js"
click node_sync_people "https://github.com/andrefan1406/stroy-hub/blob/main/server/syncPeople.js"
click node_sync_objects "https://github.com/andrefan1406/stroy-hub/blob/main/server/syncObjects.js"
click node_sync_defects "https://github.com/andrefan1406/stroy-hub/blob/main/server/syncDefectActs.js"
click node_sqlite "https://github.com/andrefan1406/stroy-hub/blob/main/server/db.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_app,node_requests,node_concrete_request,node_special_requests toneBlue
class node_reports,node_concrete_views,node_people_views,node_admin_views,node_pending_table toneAmber
class node_api,node_chat,node_sql_guard,node_sync_concrete,node_sync_people,node_sync_objects,node_sync_defects toneMint
class node_sqlite,node_ollama,node_sheets toneRose
class node_employee toneIndigo
```

## Components

### Employee portal

- [App router](https://github.com/andrefan1406/stroy-hub/blob/main/src/App.js): `src/App.js`
- [Request forms](https://github.com/andrefan1406/stroy-hub/blob/main/src/RequestPage.js): `src/RequestPage.js`
- [Concrete requests](https://github.com/andrefan1406/stroy-hub/blob/main/src/ConcreteRequestPage.js): `src/ConcreteRequestPage.js`
- [Specialist requests](https://github.com/andrefan1406/stroy-hub/blob/main/src/ElectricansRequestPage.js): `src/ElectricansRequestPage.js`

### Operations reporting

- [Reports and dashboards](https://github.com/andrefan1406/stroy-hub/blob/main/src/ReportsDashboardPage.js): `src/ReportsDashboardPage.js`
- [Concrete reports](https://github.com/andrefan1406/stroy-hub/blob/main/src/pages/ConcreteDashboardPage.jsx): `src/pages/ConcreteDashboardPage.jsx`
- [People reports](https://github.com/andrefan1406/stroy-hub/blob/main/src/PeopleReportPage.js): `src/PeopleReportPage.js`
- [Admin pages](https://github.com/andrefan1406/stroy-hub/blob/main/src/pages/AdminDashboardPage.jsx): `src/pages/AdminDashboardPage.jsx`
- [Pending requests](https://github.com/andrefan1406/stroy-hub/blob/main/src/components/ConcretePendingRequestsTable.jsx): `src/components/ConcretePendingRequestsTable.jsx`

### Backend services

- [Express API](https://github.com/andrefan1406/stroy-hub/blob/main/server/index.js): `server/index.js`
- [Text-to-SQL chat](https://github.com/andrefan1406/stroy-hub/blob/main/server/chatHandler.js): `server/chatHandler.js`
- [SQL safety](https://github.com/andrefan1406/stroy-hub/blob/main/server/sqlGuard.js): `server/sqlGuard.js`
- [Concrete sync](https://github.com/andrefan1406/stroy-hub/blob/main/server/syncConcrete.js): `server/syncConcrete.js`
- [People sync](https://github.com/andrefan1406/stroy-hub/blob/main/server/syncPeople.js): `server/syncPeople.js`
- [Object sync](https://github.com/andrefan1406/stroy-hub/blob/main/server/syncObjects.js): `server/syncObjects.js`
- [Defect sync](https://github.com/andrefan1406/stroy-hub/blob/main/server/syncDefectActs.js): `server/syncDefectActs.js`

### Data and integrations

- [SQLite database](https://github.com/andrefan1406/stroy-hub/blob/main/server/db.js): `server/db.js`
- **Ollama Cloud**
- **Google Sheets**

### Other components

- **Employee**

## Connections

- Employee → App router: uses
- App router → Request forms: routes to
- App router → Concrete requests: routes to
- App router → Specialist requests: routes to
- App router → Reports and dashboards: routes to
- App router → Concrete reports: routes to
- App router → People reports: routes to
- App router → Admin pages: routes to
- Concrete requests → Pending requests: displays
- Pending requests → Express API: fetches pending
- Pending requests → Express API: posts hide
- Express API → Text-to-SQL chat: dispatches chat
- Text-to-SQL chat → SQL safety: validates SQL
- Text-to-SQL chat → SQLite database: queries
- Text-to-SQL chat → Ollama Cloud: requests model
- Express API → SQLite database: initializes schema
- Express API → Concrete sync: starts sync
- Express API → People sync: starts sync
- Express API → Object sync: starts sync
- Express API → Defect sync: starts sync
- Concrete sync → SQLite database: stores records
- People sync → SQLite database: stores records
- Object sync → SQLite database: stores records
- Defect sync → SQLite database: stores records
- People sync → Google Sheets: imports data
