# rewire-neurotech/chills-tv architecture

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

- Interactive diagram: https://gitdiagram.com/rewire-neurotech/chills-tv
- Repository: https://github.com/rewire-neurotech/chills-tv

## Overview

ReWire ML App is a FastAPI application for personalized emotional-stimulus recommendations, with account and community features alongside its ML workflow. The documented core path is questionnaire answers through saved preprocessing and ONNX inference to ranked stimuli, presented in an HTML interface and logged. Sampled routes also show account, video, contribution, and data-export behavior backed by authentication and persistence. The broader feature inventory is based on the README and sampled excerpts; unsampled route wiring is not inferred.

Main entry points: [`app.py`](https://github.com/rewire-neurotech/chills-tv/blob/main/app.py) (FastAPI application), [`db.py`](https://github.com/rewire-neurotech/chills-tv/blob/main/db.py) (Application persistence), [`templates/index.html`](https://github.com/rewire-neurotech/chills-tv/blob/main/templates/index.html) (Questionnaire), [`preprocessor_minimal.joblib`](https://github.com/rewire-neurotech/chills-tv/blob/main/preprocessor_minimal.joblib) (Feature preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_recommendations["Recommendation flow"]
  node_questionnaire["Questionnaire<br/>[index.html]"]
  node_preprocessor["Feature preprocessing"]
  node_model["ONNX inference"]
  node_ranking["Stimulus ranking<br/>[app.py]"]
  node_stimuli["Stimulus catalog"]
end

subgraph group_web["Web experience"]
  node_recommendations_view["Recommendations UI<br/>[unified.html]"]
  node_backend["FastAPI application<br/>[app.py]"]
end

subgraph group_identity["Identity and data"]
  node_csv_logs["Prediction logs<br/>[logs.csv]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_persistence[("Application persistence<br/>[db.py]")]
  node_account["Account features<br/>[app.py]"]
end

subgraph group_community["Community features"]
  node_send_duo["Send and Duo<br/>[db.py]"]
  node_video_community["Video and contributions<br/>[app.py]"]
end

node_visitor(("Visitor"))

node_visitor -->|"answers"| node_questionnaire
node_questionnaire -->|"submits answers"| node_backend
node_backend -->|"transforms features"| node_preprocessor
node_preprocessor -->|"prepared inputs"| node_model
node_model -->|"scores stimuli"| node_ranking
node_ranking -->|"maps stimuli"| node_stimuli
node_backend -->|"renders"| node_recommendations_view
node_backend -->|"logs predictions"| node_csv_logs
node_backend -->|"uses authentication"| node_auth
node_auth -->|"reads and writes"| node_persistence
node_backend -->|"records events"| node_persistence
node_backend -->|"serves account actions"| node_account
node_backend -.->|"supports"| node_send_duo
node_backend -->|"serves video actions"| node_video_community
node_video_community -->|"records watches"| node_persistence

click node_questionnaire "https://github.com/rewire-neurotech/chills-tv/blob/main/templates/index.html"
click node_preprocessor "https://github.com/rewire-neurotech/chills-tv/blob/main/preprocessor_minimal.joblib"
click node_model "https://github.com/rewire-neurotech/chills-tv/blob/main/final_global_mlp.onnx"
click node_ranking "https://github.com/rewire-neurotech/chills-tv/blob/main/app.py"
click node_stimuli "https://github.com/rewire-neurotech/chills-tv/blob/main/stimuli_mapping.json"
click node_recommendations_view "https://github.com/rewire-neurotech/chills-tv/blob/main/templates/unified.html"
click node_backend "https://github.com/rewire-neurotech/chills-tv/blob/main/app.py"
click node_csv_logs "https://github.com/rewire-neurotech/chills-tv/blob/main/logs.csv"
click node_auth "https://github.com/rewire-neurotech/chills-tv/blob/main/auth.py"
click node_persistence "https://github.com/rewire-neurotech/chills-tv/blob/main/db.py"
click node_account "https://github.com/rewire-neurotech/chills-tv/blob/main/app.py"
click node_send_duo "https://github.com/rewire-neurotech/chills-tv/blob/main/db.py"
click node_video_community "https://github.com/rewire-neurotech/chills-tv/blob/main/app.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_questionnaire,node_preprocessor,node_model,node_ranking,node_stimuli toneBlue
class node_recommendations_view,node_backend toneAmber
class node_csv_logs,node_auth,node_persistence,node_account toneMint
class node_send_duo,node_video_community toneRose
class node_visitor toneIndigo
```

## Components

### Recommendation flow

- [Questionnaire](https://github.com/rewire-neurotech/chills-tv/blob/main/templates/index.html): `templates/index.html`
- [Feature preprocessing](https://github.com/rewire-neurotech/chills-tv/blob/main/preprocessor_minimal.joblib): `preprocessor_minimal.joblib`
- [ONNX inference](https://github.com/rewire-neurotech/chills-tv/blob/main/final_global_mlp.onnx): `final_global_mlp.onnx`
- [Stimulus ranking](https://github.com/rewire-neurotech/chills-tv/blob/main/app.py): `app.py`
- [Stimulus catalog](https://github.com/rewire-neurotech/chills-tv/blob/main/stimuli_mapping.json): `stimuli_mapping.json`

### Web experience

- [Recommendations UI](https://github.com/rewire-neurotech/chills-tv/blob/main/templates/unified.html): `templates/unified.html`
- [FastAPI application](https://github.com/rewire-neurotech/chills-tv/blob/main/app.py): `app.py`

### Identity and data

- [Prediction logs](https://github.com/rewire-neurotech/chills-tv/blob/main/logs.csv): `logs.csv`
- [Authentication](https://github.com/rewire-neurotech/chills-tv/blob/main/auth.py): `auth.py`
- [Application persistence](https://github.com/rewire-neurotech/chills-tv/blob/main/db.py): `db.py`
- [Account features](https://github.com/rewire-neurotech/chills-tv/blob/main/app.py): `app.py`

### Community features

- [Send and Duo](https://github.com/rewire-neurotech/chills-tv/blob/main/db.py): `db.py`
- [Video and contributions](https://github.com/rewire-neurotech/chills-tv/blob/main/app.py): `app.py`

### Other components

- **Visitor**

## Connections

- Visitor → Questionnaire: answers (evidence: `README.md`)
- Questionnaire → FastAPI application: submits answers (evidence: `README.md`)
- FastAPI application → Feature preprocessing: transforms features (evidence: `README.md`)
- Feature preprocessing → ONNX inference: prepared inputs (evidence: `README.md`)
- ONNX inference → Stimulus ranking: scores stimuli (evidence: `README.md`)
- Stimulus ranking → Stimulus catalog: maps stimuli (evidence: `README.md`)
- FastAPI application → Recommendations UI: renders (evidence: `app.py`)
- FastAPI application → Prediction logs: logs predictions (evidence: `README.md`)
- FastAPI application → Authentication: uses authentication (evidence: `app.py`)
- Authentication → Application persistence: reads and writes (evidence: `auth.py`)
- FastAPI application → Application persistence: records events (evidence: `app.py`)
- FastAPI application → Account features: serves account actions (evidence: `app.py`)
- FastAPI application → Send and Duo: supports (evidence: `app.py`)
- FastAPI application → Video and contributions: serves video actions (evidence: `app.py`)
- Video and contributions → Application persistence: records watches (evidence: `app.py`)
