# benjamin-gutman/smartsafe_code_engr_coen_390 architecture

> Architecture diagram of the GitHub repository benjamin-gutman/smartsafe_code_engr_coen_390, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benjamin-gutman/smartsafe_code_engr_coen_390
- Repository: https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390

## Overview

SmartSafe combines an Android application, a database-backed WebSocket backend, and a Raspberry Pi hardware interface. The documented user-facing path is the Android app communicating with the backend; the separately launched hardware program handles device operations. The repository also includes barcode scanning and database models for users, inventory, and access/history. Connections are limited to README statements and source-index references; unsampled implementation details are not assumed.

Main entry points: [`HW_Interface/main.py`](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/main.py) (Hardware entry), [`Database_Files/DatabaseHelper.py`](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/DatabaseHelper.py) (Database operations), [`Database_Files/Models`](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/Database_Files/Models) (Domain models), [`HW_Interface/websocket/command_helper.py`](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/command_helper.py) (Command helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_android["Android app"]
end

subgraph group_backend["Backend and data"]
  node_dbws["Backend WebSocket<br/>[Websocket.py]"]
  node_dbhelper["Database operations<br/>[DatabaseHelper.py]"]
  node_database[("Database setup<br/>[Database.py]")]
  node_dbreader["Database reader<br/>[databasereader.py]"]
  node_models["Domain models"]
  node_schemas["Request schemas"]
  node_access["Access history<br/>[Access_History.py]"]
  node_inventory["Inventory history"]
end

subgraph group_hardware["Pi hardware"]
  node_hwmain["Hardware entry<br/>[main.py]"]
  node_loop["Event loop<br/>[loop.py]"]
  node_state["Safe state machine"]
  node_gpio["GPIO drivers<br/>[gpio.py]"]
  node_watchdog["Watchdog"]
  node_hwclient["WebSocket client<br/>[client.py]"]
  node_hwserver["Local command server<br/>[server.py]"]
  node_commands["Command helper<br/>[command_helper.py]"]
end

subgraph group_vision["Barcode scanning"]
  node_barcode["Barcode scanning<br/>[multi_barcode.py]"]
end

node_user(("SafeSafe user"))

node_user -->|"uses"| node_android
node_android -->|"connects to backend"| node_dbws
node_dbws -.->|"uses operations"| node_dbhelper
node_dbhelper -->|"uses"| node_database
node_dbhelper -->|"uses models"| node_models
node_dbhelper -->|"uses schemas"| node_schemas
node_models -.->|"includes"| node_access
node_models -.->|"includes"| node_inventory
node_hwmain -->|"uses"| node_loop
node_hwmain -->|"uses"| node_state
node_hwmain -->|"uses"| node_gpio
node_hwmain -->|"uses"| node_hwclient
node_hwmain -->|"uses"| node_hwserver
node_hwmain -->|"uses"| node_watchdog
node_hwmain -->|"uses"| node_commands
node_hwclient -->|"uses"| node_commands
node_hwserver -->|"uses"| node_commands

click node_android "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/SafeUI/app"
click node_dbws "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Websocket.py"
click node_dbhelper "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/DatabaseHelper.py"
click node_database "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Database.py"
click node_dbreader "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/databasereader.py"
click node_models "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/Database_Files/Models"
click node_schemas "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/Database_Files/Schemas"
click node_access "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Models/Access_History.py"
click node_inventory "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Models/Inventory_History.py"
click node_hwmain "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/main.py"
click node_loop "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/loop.py"
click node_state "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/safe_state_machine.py"
click node_gpio "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/hw_drivers/gpio.py"
click node_watchdog "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/watchdog_service.py"
click node_hwclient "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/client.py"
click node_hwserver "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/server.py"
click node_commands "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/command_helper.py"
click node_barcode "https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Camera_Environment/multi_barcode.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_android,node_user toneBlue
class node_dbws,node_dbhelper,node_database,node_dbreader,node_models,node_schemas,node_access,node_inventory toneAmber
class node_hwmain,node_loop,node_state,node_gpio,node_watchdog,node_hwclient,node_hwserver,node_commands toneMint
class node_barcode toneRose
```

## Components

### Android app

- [Android app](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/SafeUI/app): `SafeUI/app`

### Backend and data

- [Backend WebSocket](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Websocket.py): `Database_Files/Websocket.py`
- [Database operations](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/DatabaseHelper.py): `Database_Files/DatabaseHelper.py`
- [Database setup](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Database.py): `Database_Files/Database.py`
- [Database reader](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/databasereader.py): `Database_Files/databasereader.py`
- [Domain models](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/Database_Files/Models): `Database_Files/Models`
- [Request schemas](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/tree/main/Database_Files/Schemas): `Database_Files/Schemas`
- [Access history](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Models/Access_History.py): `Database_Files/Models/Access_History.py`
- [Inventory history](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Database_Files/Models/Inventory_History.py): `Database_Files/Models/Inventory_History.py`

### Pi hardware

- [Hardware entry](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/main.py): `HW_Interface/main.py`
- [Event loop](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/loop.py): `HW_Interface/loop.py`
- [Safe state machine](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/safe_state_machine.py): `HW_Interface/safe_state_machine.py`
- [GPIO drivers](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/hw_drivers/gpio.py): `HW_Interface/hw_drivers/gpio.py`
- [Watchdog](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/watchdog_service.py): `HW_Interface/watchdog_service.py`
- [WebSocket client](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/client.py): `HW_Interface/websocket/client.py`
- [Local command server](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/server.py): `HW_Interface/websocket/server.py`
- [Command helper](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/HW_Interface/websocket/command_helper.py): `HW_Interface/websocket/command_helper.py`

### Barcode scanning

- [Barcode scanning](https://github.com/benjamin-gutman/smartsafe_code_engr_coen_390/blob/main/Camera_Environment/multi_barcode.py): `Camera_Environment/multi_barcode.py`

### Other components

- **SafeSafe user**

## Connections

- SafeSafe user → Android app: uses
- Android app → Backend WebSocket: connects to backend
- Backend WebSocket → Database operations: uses operations
- Database operations → Database setup: uses (evidence: `Database_Files/DatabaseHelper.py`)
- Database operations → Domain models: uses models (evidence: `Database_Files/DatabaseHelper.py`)
- Database operations → Request schemas: uses schemas (evidence: `Database_Files/DatabaseHelper.py`)
- Domain models → Access history: includes
- Domain models → Inventory history: includes
- Hardware entry → Event loop: uses (evidence: `HW_Interface/main.py`)
- Hardware entry → Safe state machine: uses (evidence: `HW_Interface/main.py`)
- Hardware entry → GPIO drivers: uses (evidence: `HW_Interface/main.py`)
- Hardware entry → WebSocket client: uses (evidence: `HW_Interface/main.py`)
- Hardware entry → Local command server: uses (evidence: `HW_Interface/main.py`)
- Hardware entry → Watchdog: uses (evidence: `HW_Interface/main.py`)
- Hardware entry → Command helper: uses (evidence: `HW_Interface/main.py`)
- WebSocket client → Command helper: uses (evidence: `HW_Interface/websocket/client.py`)
- Local command server → Command helper: uses (evidence: `HW_Interface/websocket/server.py`)
