# ut5ab07/cinerl architecture

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

- Interactive diagram: https://gitdiagram.com/ut5ab07/cinerl
- Repository: https://github.com/ut5ab07/cinerl

## Overview

CineRL combines an educational MovieLens research workflow with an inference-only Flask recommendation app. Users choose an ID, genre, and satisfaction level; routes pass that input to the recommender, which selects a genre using the saved tabular Q-table and returns unrated movies ordered by training popularity. Routes also persist sessions for History and Insights views. The README documents data preparation, tabular and fitted Q-learning, and model evaluation; notebook internals were not sampled, so those branches show documented capabilities without inferred call-level links.

Main entry points: [`web/routes.py`](https://github.com/ut5ab07/cinerl/blob/main/web/routes.py) (API and pages), [`web/recommender.py`](https://github.com/ut5ab07/cinerl/blob/main/web/recommender.py) (Recommendation inference), [`web/history.py`](https://github.com/ut5ab07/cinerl/blob/main/web/history.py) (History storage), [`app.py`](https://github.com/ut5ab07/cinerl/blob/main/app.py) (Flask setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_research["Research workflow"]
  node_preparation["Data preparation"]
  node_tabular["Tabular Q-learning"]
  node_fitted["Fitted Q-learning"]
  node_evaluation["Model evaluation"]
  node_qtable["Saved tabular Q-table"]
  node_prepared["Prepared catalog and ratings"]
end

subgraph group_web["Web application"]
  node_application["Flask setup<br/>[app.py]"]
  node_routes["API and pages<br/>[routes.py]"]
  node_recommender["Recommendation inference<br/>[recommender.py]"]
end

subgraph group_presentation["User interface"]
  node_client["Page interactions<br/>[script.js]"]
  node_templates["Page templates"]
end

subgraph group_state["Application state"]
  node_history["History storage<br/>[history.py]"]
  node_historyfile[("Session history file")]
end

node_browser(("Browser user"))

node_browser -.->|"uses pages"| node_client
node_client -->|"requests API"| node_routes
node_routes -->|"renders pages"| node_templates
node_application -->|"creates"| node_recommender
node_application -->|"creates"| node_history
node_application -->|"registers routes"| node_routes
node_routes -->|"requests recommendations"| node_recommender
node_routes -->|"records sessions"| node_history
node_routes -->|"reads and clears"| node_history
node_recommender -.->|"loads Q-values"| node_qtable
node_recommender -->|"loads catalog and ratings"| node_prepared
node_history -->|"reads and writes"| node_historyfile
node_preparation -.->|"produces prepared data"| node_prepared
node_tabular -.->|"saves Q-table"| node_qtable
node_fitted -.->|"evaluated against alternatives"| node_evaluation
node_tabular -.->|"evaluated against baseline"| node_evaluation

click node_preparation "https://github.com/ut5ab07/cinerl/tree/main/notebooks"
click node_tabular "https://github.com/ut5ab07/cinerl/tree/main/notebooks"
click node_fitted "https://github.com/ut5ab07/cinerl/tree/main/notebooks"
click node_evaluation "https://github.com/ut5ab07/cinerl/tree/main/notebooks"
click node_application "https://github.com/ut5ab07/cinerl/blob/main/app.py"
click node_routes "https://github.com/ut5ab07/cinerl/blob/main/web/routes.py"
click node_recommender "https://github.com/ut5ab07/cinerl/blob/main/web/recommender.py"
click node_client "https://github.com/ut5ab07/cinerl/blob/main/static/js/script.js"
click node_templates "https://github.com/ut5ab07/cinerl/tree/main/templates"
click node_history "https://github.com/ut5ab07/cinerl/blob/main/web/history.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_preparation,node_tabular,node_fitted,node_evaluation,node_qtable,node_prepared,node_browser toneBlue
class node_application,node_routes,node_recommender toneAmber
class node_client,node_templates toneMint
class node_history,node_historyfile toneRose
```

## Components

### Research workflow

- [Data preparation](https://github.com/ut5ab07/cinerl/tree/main/notebooks): `notebooks`
- [Tabular Q-learning](https://github.com/ut5ab07/cinerl/tree/main/notebooks): `notebooks`
- [Fitted Q-learning](https://github.com/ut5ab07/cinerl/tree/main/notebooks): `notebooks`
- [Model evaluation](https://github.com/ut5ab07/cinerl/tree/main/notebooks): `notebooks`
- **Saved tabular Q-table**
- **Prepared catalog and ratings**

### Web application

- [Flask setup](https://github.com/ut5ab07/cinerl/blob/main/app.py): `app.py`
- [API and pages](https://github.com/ut5ab07/cinerl/blob/main/web/routes.py): `web/routes.py`
- [Recommendation inference](https://github.com/ut5ab07/cinerl/blob/main/web/recommender.py): `web/recommender.py`

### User interface

- [Page interactions](https://github.com/ut5ab07/cinerl/blob/main/static/js/script.js): `static/js/script.js`
- [Page templates](https://github.com/ut5ab07/cinerl/tree/main/templates): `templates`

### Application state

- [History storage](https://github.com/ut5ab07/cinerl/blob/main/web/history.py): `web/history.py`
- **Session history file**

### Other components

- **Browser user**

## Connections

- Browser user → Page interactions: uses pages (evidence: `README.md`)
- Page interactions → API and pages: requests API (evidence: `static/js/script.js`)
- API and pages → Page templates: renders pages (evidence: `web/routes.py`)
- Flask setup → Recommendation inference: creates (evidence: `app.py`)
- Flask setup → History storage: creates (evidence: `app.py`)
- Flask setup → API and pages: registers routes (evidence: `app.py`)
- API and pages → Recommendation inference: requests recommendations (evidence: `web/routes.py`)
- API and pages → History storage: records sessions (evidence: `web/routes.py`)
- API and pages → History storage: reads and clears (evidence: `web/routes.py`)
- Recommendation inference → Saved tabular Q-table: loads Q-values (evidence: `README.md`)
- Recommendation inference → Prepared catalog and ratings: loads catalog and ratings (evidence: `web/recommender.py`)
- History storage → Session history file: reads and writes (evidence: `README.md`)
- Data preparation → Prepared catalog and ratings: produces prepared data (evidence: `README.md`)
- Tabular Q-learning → Saved tabular Q-table: saves Q-table (evidence: `README.md`)
- Fitted Q-learning → Model evaluation: evaluated against alternatives (evidence: `README.md`)
- Tabular Q-learning → Model evaluation: evaluated against baseline (evidence: `README.md`)
