# camthink-ai/aitoolstack architecture

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

- Interactive diagram: https://gitdiagram.com/camthink-ai/aitoolstack
- Repository: https://github.com/camthink-ai/aitoolstack

## Overview

AI Tool Stack is an edge-vision workflow product for collecting device imagery, organizing and annotating datasets, training and testing YOLO models, then quantizing and packaging them for NE301 deployment. The UI also manages model versions, devices, MQTT brokers and certificates. The graph follows documented product stages and source-indexed backend dispatch; several detailed UI-to-endpoint and device behaviors are not shown in the excerpts, so those links are documented at product level rather than inferred from module names.

Main entry points: [`backend/api/routes.py`](https://github.com/camthink-ai/aitoolstack/blob/main/backend/api/routes.py) (API routes), [`backend/services/mqtt_service.py`](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_service.py) (Device image intake), [`frontend/src/App.tsx`](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/App.tsx) (Application shell), [`backend/services/mqtt_config_service.py`](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_config_service.py) (MQTT configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web application"]
  node_app["Application shell<br/>[App.tsx]"]
  node_projects["Project selection"]
  node_annotation["Annotation workbench"]
  node_training_ui["Training controls<br/>[TrainingPanel.tsx]"]
  node_models_ui["Model space<br/>[ModelSpace.tsx]"]
  node_devices_ui["Device manager<br/>[DeviceManager.tsx]"]
  node_settings_ui["System settings<br/>[SystemSettings.tsx]"]
end

subgraph group_workflow["AI model workflow"]
  node_training["Training service"]
  node_dataset_import["Dataset import<br/>[dataset_import.py]"]
  node_yolo_export["YOLO export<br/>[yolo_export.py]"]
  node_ne301["NE301 packaging<br/>[ne301_export.py]"]
  node_quantization["TFLite quantization<br/>[tflite_quant.py]"]
end

subgraph group_devices["Device connectivity"]
  node_mqtt["Device image intake<br/>[mqtt_service.py]"]
  node_builtin_broker["Built-in MQTT broker<br/>[mqtt_broker.py]"]
  node_mqtt_config["MQTT configuration"]
  node_external_broker["External brokers"]
  node_ws["WebSocket updates"]
end

subgraph group_platform["Backend platform"]
  node_api["API routes<br/>[routes.py]"]
  node_db[("Application database<br/>[database.py]")]
  node_security["API security<br/>[security_utils.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_user(("User"))
node_device(("NE101 / NE301"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_projects
node_app -->|"renders"| node_annotation
node_app -->|"renders"| node_training_ui
node_app -->|"renders"| node_models_ui
node_app -->|"renders"| node_devices_ui
node_app -->|"renders"| node_settings_ui
node_projects -.->|"selects project"| node_annotation
node_annotation -.->|"sends annotations"| node_api
node_training_ui -.->|"requests training"| node_api
node_models_ui -.->|"manages models"| node_api
node_devices_ui -.->|"manages devices"| node_api
node_settings_ui -.->|"configures brokers"| node_api
node_api -->|"reads and writes"| node_db
node_api -->|"dispatches training"| node_training
node_api -->|"imports datasets"| node_dataset_import
node_api -->|"exports datasets"| node_yolo_export
node_api -->|"packages models"| node_ne301
node_api -->|"configures intake"| node_mqtt
node_api -->|"manages settings"| node_mqtt_config
node_api -->|"manages brokers"| node_external_broker
node_api -->|"checks access"| node_security
node_training -->|"persists records"| node_db
node_mqtt -->|"stores device data"| node_db
node_mqtt -->|"broadcasts updates"| node_ws
node_mqtt -->|"uses broker"| node_builtin_broker
node_mqtt -->|"loads settings"| node_mqtt_config
node_mqtt -->|"supports external"| node_external_broker
node_builtin_broker -->|"loads settings"| node_mqtt_config
node_mqtt_config -->|"persists configuration"| node_db
node_device -->|"uploads imagery"| node_mqtt
node_mqtt -.->|"feeds projects"| node_api
node_ne301 -.->|"supports quantization"| node_quantization
node_api -.->|"uses settings"| node_config
node_security -->|"reads settings"| node_config

click node_app "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/App.tsx"
click node_projects "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/ProjectSelector.tsx"
click node_annotation "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/AnnotationWorkbench.tsx"
click node_training_ui "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/TrainingPanel.tsx"
click node_models_ui "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/ModelSpace.tsx"
click node_devices_ui "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/DeviceManager.tsx"
click node_settings_ui "https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/SystemSettings.tsx"
click node_api "https://github.com/camthink-ai/aitoolstack/blob/main/backend/api/routes.py"
click node_db "https://github.com/camthink-ai/aitoolstack/blob/main/backend/models/database.py"
click node_training "https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/training_service.py"
click node_dataset_import "https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/dataset_import.py"
click node_yolo_export "https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/yolo_export.py"
click node_ne301 "https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/ne301_export.py"
click node_quantization "https://github.com/camthink-ai/aitoolstack/blob/main/backend/quantization/tflite_quant.py"
click node_mqtt "https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_service.py"
click node_builtin_broker "https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_broker.py"
click node_mqtt_config "https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_config_service.py"
click node_external_broker "https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/external_broker_service.py"
click node_ws "https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/websocket_manager.py"
click node_security "https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/security_utils.py"
click node_config "https://github.com/camthink-ai/aitoolstack/blob/main/backend/config.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_app,node_projects,node_annotation,node_training_ui,node_models_ui,node_devices_ui,node_settings_ui,node_user toneBlue
class node_training,node_dataset_import,node_yolo_export,node_ne301,node_quantization toneAmber
class node_mqtt,node_builtin_broker,node_mqtt_config,node_external_broker,node_ws toneMint
class node_api,node_db,node_security,node_config toneRose
class node_device toneIndigo
```

## Components

### Web application

- [Application shell](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Project selection](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/ProjectSelector.tsx): `frontend/src/components/ProjectSelector.tsx`
- [Annotation workbench](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/AnnotationWorkbench.tsx): `frontend/src/components/AnnotationWorkbench.tsx`
- [Training controls](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/TrainingPanel.tsx): `frontend/src/components/TrainingPanel.tsx`
- [Model space](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/ModelSpace.tsx): `frontend/src/components/ModelSpace.tsx`
- [Device manager](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/DeviceManager.tsx): `frontend/src/components/DeviceManager.tsx`
- [System settings](https://github.com/camthink-ai/aitoolstack/blob/main/frontend/src/components/SystemSettings.tsx): `frontend/src/components/SystemSettings.tsx`

### AI model workflow

- [Training service](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/training_service.py): `backend/services/training_service.py`
- [Dataset import](https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/dataset_import.py): `backend/utils/dataset_import.py`
- [YOLO export](https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/yolo_export.py): `backend/utils/yolo_export.py`
- [NE301 packaging](https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/ne301_export.py): `backend/utils/ne301_export.py`
- [TFLite quantization](https://github.com/camthink-ai/aitoolstack/blob/main/backend/quantization/tflite_quant.py): `backend/quantization/tflite_quant.py`

### Device connectivity

- [Device image intake](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_service.py): `backend/services/mqtt_service.py`
- [Built-in MQTT broker](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_broker.py): `backend/services/mqtt_broker.py`
- [MQTT configuration](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/mqtt_config_service.py): `backend/services/mqtt_config_service.py`
- [External brokers](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/external_broker_service.py): `backend/services/external_broker_service.py`
- [WebSocket updates](https://github.com/camthink-ai/aitoolstack/blob/main/backend/services/websocket_manager.py): `backend/services/websocket_manager.py`

### Backend platform

- [API routes](https://github.com/camthink-ai/aitoolstack/blob/main/backend/api/routes.py): `backend/api/routes.py`
- [Application database](https://github.com/camthink-ai/aitoolstack/blob/main/backend/models/database.py): `backend/models/database.py`
- [API security](https://github.com/camthink-ai/aitoolstack/blob/main/backend/utils/security_utils.py): `backend/utils/security_utils.py`
- [Runtime configuration](https://github.com/camthink-ai/aitoolstack/blob/main/backend/config.py): `backend/config.py`

### Other components

- **User**
- **NE101 / NE301**

## Connections

- User → Application shell: uses (evidence: `README.md`)
- Application shell → Project selection: renders (evidence: `frontend/src/App.tsx`)
- Application shell → Annotation workbench: renders (evidence: `frontend/src/App.tsx`)
- Application shell → Training controls: renders (evidence: `frontend/src/App.tsx`)
- Application shell → Model space: renders (evidence: `frontend/src/App.tsx`)
- Application shell → Device manager: renders (evidence: `frontend/src/App.tsx`)
- Application shell → System settings: renders (evidence: `frontend/src/App.tsx`)
- Project selection → Annotation workbench: selects project (evidence: `README.md`)
- Annotation workbench → API routes: sends annotations (evidence: `README.md`)
- Training controls → API routes: requests training (evidence: `README.md`)
- Model space → API routes: manages models (evidence: `README.md`)
- Device manager → API routes: manages devices (evidence: `README.md`)
- System settings → API routes: configures brokers (evidence: `README.md`)
- API routes → Application database: reads and writes (evidence: `backend/api/routes.py`)
- API routes → Training service: dispatches training (evidence: `backend/api/routes.py`)
- API routes → Dataset import: imports datasets (evidence: `backend/api/routes.py`)
- API routes → YOLO export: exports datasets (evidence: `backend/api/routes.py`)
- API routes → NE301 packaging: packages models (evidence: `backend/api/routes.py`)
- API routes → Device image intake: configures intake (evidence: `backend/api/routes.py`)
- API routes → MQTT configuration: manages settings (evidence: `backend/api/routes.py`)
- API routes → External brokers: manages brokers (evidence: `backend/api/routes.py`)
- API routes → API security: checks access (evidence: `backend/api/routes.py`)
- Training service → Application database: persists records (evidence: `backend/services/training_service.py`)
- Device image intake → Application database: stores device data (evidence: `backend/services/mqtt_service.py`)
- Device image intake → WebSocket updates: broadcasts updates (evidence: `backend/services/mqtt_service.py`)
- Device image intake → Built-in MQTT broker: uses broker (evidence: `backend/services/mqtt_service.py`)
- Device image intake → MQTT configuration: loads settings (evidence: `backend/services/mqtt_service.py`)
- Device image intake → External brokers: supports external (evidence: `backend/services/mqtt_service.py`)
- Built-in MQTT broker → MQTT configuration: loads settings (evidence: `backend/services/mqtt_broker.py`)
- MQTT configuration → Application database: persists configuration (evidence: `backend/services/mqtt_config_service.py`)
- NE101 / NE301 → Device image intake: uploads imagery (evidence: `README.md`)
- Device image intake → API routes: feeds projects (evidence: `README.md`)
- NE301 packaging → TFLite quantization: supports quantization (evidence: `README.md`)
- API routes → Runtime configuration: uses settings (evidence: `backend/api/routes.py`)
- API security → Runtime configuration: reads settings (evidence: `backend/utils/security_utils.py`)
