# gajalakshmi0133/suhwa architecture

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

- Interactive diagram: https://gitdiagram.com/gajalakshmi0133/suhwa
- Repository: https://github.com/gajalakshmi0133/suhwa

## Overview

#### Purpose and Entry Points
Suhwa is a sign-language learning/detection system combining server-rendered web pages, browser-side camera interactions, ML inference/training utilities, and a relational user-data layer. The primary application entry point is `app.py`; deployment/runtime settings are centralized in `config.py`. HTML routes render templates from `templates/`, with frontend behavior and assets served from `static/`.

#### Web Application Layer
The Python application owns navigation and feature pages for authentication, dashboard/profile, learning content, sign detection, uploads, community/chat, and video calls. Page-level boundaries are visible in `templates/detect.html`, `templates/learn.html`, and `templates/video_call.html`. Shared presentation is rooted at `templates/layout.html`; browser workflows are implemented in `static/js/main.js`, `static/js/detect.js`, and `static/js/video_call.js`.

#### Sign Detection and Inference
`backend/sign_detection/` is the ML-serving boundary. It separates model acquisition/loading (`backend/sign_detection/model_loader.py`) from single-input prediction (`backend/sign_detection/predict.py`, `backend/sign_detection/predict_image.py`) and live camera inference (`backend/sign_detection/realtime_inference.py`). Sequence-oriented recognition has a separate decode/language layer via `backend/sign_detection/ctc_decode.py` and `backend/sign_detection/language_model.py`, allowing frame/landmark model output to become text-like labels.

#### Model Development Pipeline
Training is intentionally decoupled from request-time inference. Image classifiers are trained through `backend/sign_detection/train_image_model.py` and `backend/sign_detection/train_asl_image_model.py`; temporal/landmark models use `backend/sign_detection/train_sequence_model.py` and `backend/sign_detection/train_sequence_landmarks.py`. Alternative experimentation and model families are retained under `tools/`, including CNN, ViT, and YOLO workflows (`tools/train_asl_cnn.py`, `tools/vit_detect.py`, `tools/yolo_asl_alphabet.py`).

#### Data and Feature Boundaries
The repository contains both source image datasets and derived ML artifacts. Alphabet/digit image data is organized under `dataset/American_Sign_Language/`, while ISL material is under `dataset/ISL/`. Prepared array datasets (`dataset/prepared/X.npy`, `dataset/prepared/y.npy`) and many per-label sequence tensors in `dataset/sequences/` supply the sequence training path. Landmark extraction and dataset conversion are offline preprocessing responsibilities of `tools/extract_landmarks.py` and `tools/prepare_dataset.py`, not web-request responsibilities.

#### Identity, Persistence, and Security
Application-facing account and persistence concerns are isolated from detection code in `backend/utils/auth.py`, `backend/utils/db.py`, and `backend/utils/crypto.py`. SQL schema/bootstrap and migration workflows are represented by `schema.sql`, `init_database.py`, and `migrate_sample_data.py`. The checked-in SQL Server ODBC connection descriptor indicates Microsoft SQL Server is a material external infrastructure dependency; credentials/encryption guidance is maintained in `CREDENTIALS.TEMPLATE.md` and `ENCRYPTION_GUIDE.md`.

#### Runtime Composition
The system spans a Python backend/ML runtime (dependencies declared in `requirements.txt` and `pyproject.toml`) and a browser JavaScript runtime (`static/js/`, with Node package metadata in `package.json`). Static curriculum/reference content is file-backed, including `static/data/learning_content.json`, `static/data/tutorials.json`, and sign-reference imagery under `static/img/signs/`. This makes web content delivery, ML inference, and SQL-backed user state distinct operational boundaries.

Main entry points: [`app.py`](https://github.com/gajalakshmi0133/suhwa/blob/main/app.py) (Python application), [`backend/sign_detection/model_loader.py`](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/model_loader.py) (Model loader), [`tools/prepare_dataset.py`](https://github.com/gajalakshmi0133/suhwa/blob/main/tools/prepare_dataset.py) (Dataset preprocessing), [`backend/sign_detection/realtime_inference.py`](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/realtime_inference.py) (Live camera inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Python application<br/>web entry point<br/>[app.py]"]
  node_config["Runtime settings<br/>configuration<br/>[config.py]"]
  node_templates["Page templates<br/>server-rendered views"]
  node_browser_js["Browser workflows<br/>JavaScript client"]
  node_learning_content["Learning content<br/>static curriculum data"]
end

subgraph group_serving["Detection serving"]
  node_model_loader["Model loader<br/>ML model acquisition<br/>[model_loader.py]"]
  node_prediction["Image prediction<br/>single-input inference<br/>[predict.py]"]
  node_realtime["Live camera inference<br/>stream inference"]
  node_sequence_decode["Sequence decoding<br/>CTC and language layer<br/>[ctc_decode.py]"]
end

subgraph group_pipeline["ML data &amp; training"]
  node_image_data[("Sign image datasets<br/>source datasets")]
  node_prepared_data[("Prepared arrays<br/>training dataset<br/>[X.npy]")]
  node_sequence_data[("Sequence tensors<br/>temporal training data")]
  node_preprocessing["Dataset preprocessing<br/>offline conversion<br/>[prepare_dataset.py]"]
  node_train_image["Image model training<br/>offline trainer"]
  node_train_sequence["Sequence model training<br/>offline trainer"]
end

subgraph group_persistence["Identity &amp; persistence"]
  node_auth["Authentication<br/>identity service<br/>[auth.py]"]
  node_database_access["Database access<br/>persistence adapter<br/>[db.py]"]
  node_sql_server[("Microsoft SQL Server<br/>external relational database")]
  node_schema["Database schema<br/>SQL bootstrap<br/>[schema.sql]"]
end

node_config -->|"configures"| node_app
node_app -->|"renders"| node_templates
node_templates -->|"loads"| node_browser_js
node_app -->|"serves"| node_learning_content
node_browser_js -->|"camera and page requests"| node_app
node_app -->|"image detection"| node_prediction
node_app -->|"live detection"| node_realtime
node_model_loader -->|"supplies model"| node_prediction
node_model_loader -->|"supplies model"| node_realtime
node_realtime -->|"decodes sequences"| node_sequence_decode
node_preprocessing -->|"creates"| node_prepared_data
node_preprocessing -->|"creates"| node_sequence_data
node_image_data -->|"source images"| node_preprocessing
node_image_data -->|"trains from"| node_train_image
node_prepared_data -->|"trains from"| node_train_sequence
node_sequence_data -->|"trains from"| node_train_sequence
node_train_image -.->|"produces model artifacts"| node_model_loader
node_train_sequence -.->|"produces model artifacts"| node_model_loader
node_app -->|"authenticates users"| node_auth
node_app -->|"user data operations"| node_database_access
node_auth -->|"uses"| node_database_access
node_database_access -->|"ODBC connection"| node_sql_server
node_schema -.->|"defines"| node_sql_server

click node_app "https://github.com/gajalakshmi0133/suhwa/blob/main/app.py"
click node_config "https://github.com/gajalakshmi0133/suhwa/blob/main/config.py"
click node_learning_content "https://github.com/gajalakshmi0133/suhwa/blob/main/static/data/learning_content.json"
click node_model_loader "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/model_loader.py"
click node_prediction "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/predict.py"
click node_realtime "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/realtime_inference.py"
click node_sequence_decode "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/ctc_decode.py"
click node_prepared_data "https://github.com/gajalakshmi0133/suhwa/blob/main/dataset/prepared/X.npy"
click node_preprocessing "https://github.com/gajalakshmi0133/suhwa/blob/main/tools/prepare_dataset.py"
click node_train_image "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/train_image_model.py"
click node_train_sequence "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/train_sequence_model.py"
click node_auth "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/utils/auth.py"
click node_database_access "https://github.com/gajalakshmi0133/suhwa/blob/main/backend/utils/db.py"
click node_schema "https://github.com/gajalakshmi0133/suhwa/blob/main/schema.sql"

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_config,node_templates,node_browser_js,node_learning_content toneBlue
class node_model_loader,node_prediction,node_realtime,node_sequence_decode toneAmber
class node_image_data,node_prepared_data,node_sequence_data,node_preprocessing,node_train_image,node_train_sequence toneMint
class node_auth,node_database_access,node_sql_server,node_schema toneRose
```

## Components

### Web experience

- [Python application](https://github.com/gajalakshmi0133/suhwa/blob/main/app.py): web entry point · Owns routes and feature pages. · `app.py`
- [Runtime settings](https://github.com/gajalakshmi0133/suhwa/blob/main/config.py): configuration · `config.py`
- **Page templates**: server-rendered views · Shared layout and feature pages.
- **Browser workflows**: JavaScript client · Camera detection and video-call interactions.
- [Learning content](https://github.com/gajalakshmi0133/suhwa/blob/main/static/data/learning_content.json): static curriculum data · `static/data/learning_content.json`

### Detection serving

- [Model loader](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/model_loader.py): ML model acquisition · `backend/sign_detection/model_loader.py`
- [Image prediction](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/predict.py): single-input inference · `backend/sign_detection/predict.py`
- [Live camera inference](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/realtime_inference.py): stream inference · `backend/sign_detection/realtime_inference.py`
- [Sequence decoding](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/ctc_decode.py): CTC and language layer · Converts temporal model output into labels. · `backend/sign_detection/ctc_decode.py`

### ML data & training

- **Sign image datasets**: source datasets · ASL alphabet/digits and ISL material.
- [Prepared arrays](https://github.com/gajalakshmi0133/suhwa/blob/main/dataset/prepared/X.npy): training dataset · `dataset/prepared/X.npy`
- **Sequence tensors**: temporal training data
- [Dataset preprocessing](https://github.com/gajalakshmi0133/suhwa/blob/main/tools/prepare_dataset.py): offline conversion · Prepares arrays and extracts landmarks. · `tools/prepare_dataset.py`
- [Image model training](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/train_image_model.py): offline trainer · `backend/sign_detection/train_image_model.py`
- [Sequence model training](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/sign_detection/train_sequence_model.py): offline trainer · `backend/sign_detection/train_sequence_model.py`

### Identity & persistence

- [Authentication](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/utils/auth.py): identity service · `backend/utils/auth.py`
- [Database access](https://github.com/gajalakshmi0133/suhwa/blob/main/backend/utils/db.py): persistence adapter · `backend/utils/db.py`
- **Microsoft SQL Server**: external relational database · Stores application user state.
- [Database schema](https://github.com/gajalakshmi0133/suhwa/blob/main/schema.sql): SQL bootstrap · `schema.sql`

## Connections

- Runtime settings → Python application: configures
- Python application → Page templates: renders
- Page templates → Browser workflows: loads
- Python application → Learning content: serves
- Browser workflows → Python application: camera and page requests
- Python application → Image prediction: image detection
- Python application → Live camera inference: live detection
- Model loader → Image prediction: supplies model
- Model loader → Live camera inference: supplies model
- Live camera inference → Sequence decoding: decodes sequences
- Dataset preprocessing → Prepared arrays: creates
- Dataset preprocessing → Sequence tensors: creates
- Sign image datasets → Dataset preprocessing: source images
- Sign image datasets → Image model training: trains from
- Prepared arrays → Sequence model training: trains from
- Sequence tensors → Sequence model training: trains from
- Image model training → Model loader: produces model artifacts
- Sequence model training → Model loader: produces model artifacts
- Python application → Authentication: authenticates users
- Python application → Database access: user data operations
- Authentication → Database access: uses
- Database access → Microsoft SQL Server: ODBC connection
- Database schema → Microsoft SQL Server: defines
