# pragadheeshpandian1906/gate-security-system architecture

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

- Interactive diagram: https://gitdiagram.com/pragadheeshpandian1906/gate-security-system
- Repository: https://github.com/pragadheeshpandian1906/gate-security-system

## Overview

SmartGuard AI combines a role-based security dashboard, a main FastAPI service for identity and access decisions, and an independent IoT service that dispatches commands to an ESP32. The principal workflow is dashboard request → backend verification and access decision → IoT command → controller acknowledgement; reported state does not verify physical gate position. The README and source index establish the service boundaries and major capabilities, but many route and service implementations were not excerpted, so their internal links are omitted or marked unverified.

Main entry points: [`backend/app/main.py`](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/main.py) (API and routes), [`backend/app/services/access_decision_service.py`](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/access_decision_service.py) (Access decisions), [`frontend/src/pages/security/SecurityDashboard.tsx`](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/pages/security/SecurityDashboard.tsx) (Role dashboards), [`frontend/src/api/client.ts`](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/api/client.ts) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Security dashboard"]
  node_dashboard["Role dashboards"]
  node_authui["Session and roles<br/>[AuthContext.tsx]"]
  node_apiclient["HTTP client<br/>[client.ts]"]
end

subgraph group_backend["Main backend"]
  node_backendapi["API and routes<br/>[main.py]"]
  node_identity["Identity and accounts<br/>[account_service.py]"]
  node_verification["Face and vehicle checks<br/>[ai_verify.py]"]
  node_access["Access decisions"]
  node_policies["Schedules and watchlists"]
  node_visitor["Visitor passes<br/>[visitor_service.py]"]
  node_alerts["Alerts and reports<br/>[alerts.py]"]
  node_notifications["Notifications"]
  node_gatebridge["Gate service bridge<br/>[gate_service.py]"]
  node_dbsession["Database sessions<br/>[session.py]"]
  node_records[("Security records<br/>[access.py]")]
  node_storage["File storage<br/>[storage_service.py]"]
end

subgraph group_iot["IoT controller"]
  node_iotapi["Command and status API<br/>[routes.py]"]
  node_devicemanager["Device manager<br/>[device_manager.py]"]
end

node_browser(("Security staff"))
node_supabase[("Supabase services")]
node_esp32{{"ESP32 controller"}}

node_browser -->|"uses"| node_dashboard
node_dashboard -->|"requests data"| node_apiclient
node_dashboard -->|"reads session"| node_authui
node_authui -.->|"stores bearer token"| node_apiclient
node_apiclient -->|"HTTP requests"| node_backendapi
node_backendapi -->|"routes auth"| node_identity
node_backendapi -->|"routes verification"| node_verification
node_backendapi -->|"routes access"| node_access
node_backendapi -->|"routes visitors"| node_visitor
node_access -->|"checks policies"| node_policies
node_access -->|"requests gate action"| node_gatebridge
node_access -->|"raises alerts"| node_alerts
node_backendapi -->|"routes alerts"| node_alerts
node_notifications -.->|"emails via provider"| node_supabase
node_gatebridge -->|"HTTP commands"| node_iotapi
node_iotapi -->|"dispatches commands"| node_devicemanager
node_devicemanager -->|"WebSocket commands"| node_esp32
node_esp32 -->|"reports state"| node_devicemanager
node_dbsession -.->|"persists records"| node_records
node_dbsession -->|"PostgreSQL connection"| node_supabase
node_storage -->|"uploads files"| node_supabase

click node_dashboard "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/pages/security/SecurityDashboard.tsx"
click node_authui "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/context/AuthContext.tsx"
click node_apiclient "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/api/client.ts"
click node_backendapi "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/main.py"
click node_identity "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/account_service.py"
click node_verification "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/api/routes/ai_verify.py"
click node_access "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/access_decision_service.py"
click node_policies "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/schedule_service.py"
click node_visitor "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/visitor_service.py"
click node_alerts "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/api/routes/alerts.py"
click node_notifications "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/notification_service.py"
click node_gatebridge "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/gate_service.py"
click node_dbsession "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/db/session.py"
click node_records "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/models/access.py"
click node_storage "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/storage_service.py"
click node_iotapi "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/iot-service/app/api/routes.py"
click node_devicemanager "https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/iot-service/app/services/device_manager.py"

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_dashboard,node_authui,node_apiclient toneBlue
class node_backendapi,node_identity,node_verification,node_access,node_policies,node_visitor,node_alerts,node_notifications,node_gatebridge,node_dbsession,node_records,node_storage,node_supabase toneAmber
class node_iotapi,node_devicemanager toneMint
class node_browser,node_esp32 toneIndigo
```

## Components

### Security dashboard

- [Role dashboards](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/pages/security/SecurityDashboard.tsx): `frontend/src/pages/security/SecurityDashboard.tsx`
- [Session and roles](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [HTTP client](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Main backend

- [API and routes](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/main.py): `backend/app/main.py`
- [Identity and accounts](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/account_service.py): `backend/app/services/account_service.py`
- [Face and vehicle checks](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/api/routes/ai_verify.py): `backend/app/api/routes/ai_verify.py`
- [Access decisions](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/access_decision_service.py): `backend/app/services/access_decision_service.py`
- [Schedules and watchlists](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/schedule_service.py): `backend/app/services/schedule_service.py`
- [Visitor passes](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/visitor_service.py): `backend/app/services/visitor_service.py`
- [Alerts and reports](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/api/routes/alerts.py): `backend/app/api/routes/alerts.py`
- [Notifications](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/notification_service.py): `backend/app/services/notification_service.py`
- [Gate service bridge](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/gate_service.py): `backend/app/services/gate_service.py`
- [Database sessions](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Security records](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/models/access.py): `backend/app/models/access.py`
- [File storage](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/backend/app/services/storage_service.py): `backend/app/services/storage_service.py`

### IoT controller

- [Command and status API](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/iot-service/app/api/routes.py): `iot-service/app/api/routes.py`
- [Device manager](https://github.com/pragadheeshpandian1906/gate-security-system/blob/main/iot-service/app/services/device_manager.py): `iot-service/app/services/device_manager.py`

### Other components

- **Security staff**
- **Supabase services**
- **ESP32 controller**

## Connections

- Security staff → Role dashboards: uses (evidence: `README.md`)
- Role dashboards → HTTP client: requests data (evidence: `frontend/src/pages/security/SecurityDashboard.tsx`)
- Role dashboards → Session and roles: reads session (evidence: `frontend/src/pages/security/SecurityDashboard.tsx`)
- Session and roles → HTTP client: stores bearer token
- HTTP client → API and routes: HTTP requests (evidence: `README.md`)
- API and routes → Identity and accounts: routes auth (evidence: `backend/app/main.py`)
- API and routes → Face and vehicle checks: routes verification (evidence: `backend/app/main.py`)
- API and routes → Access decisions: routes access (evidence: `backend/app/main.py`)
- API and routes → Visitor passes: routes visitors (evidence: `backend/app/main.py`)
- Access decisions → Schedules and watchlists: checks policies (evidence: `backend/app/services/access_decision_service.py`)
- Access decisions → Gate service bridge: requests gate action (evidence: `backend/app/services/access_decision_service.py`)
- Access decisions → Alerts and reports: raises alerts (evidence: `backend/app/services/access_decision_service.py`)
- API and routes → Alerts and reports: routes alerts (evidence: `backend/app/main.py`)
- Notifications → Supabase services: emails via provider
- Gate service bridge → Command and status API: HTTP commands (evidence: `README.md`)
- Command and status API → Device manager: dispatches commands (evidence: `iot-service/app/api/routes.py`)
- Device manager → ESP32 controller: WebSocket commands (evidence: `README.md`)
- ESP32 controller → Device manager: reports state (evidence: `README.md`)
- Database sessions → Security records: persists records
- Database sessions → Supabase services: PostgreSQL connection (evidence: `README.md`)
- File storage → Supabase services: uploads files (evidence: `backend/app/services/storage_service.py`)
