# westbrook210207-tech/movielens100k-retrieval architecture

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

- Interactive diagram: https://gitdiagram.com/westbrook210207-tech/movielens100k-retrieval
- Repository: https://github.com/westbrook210207-tech/movielens100k-retrieval

## Overview

This repository builds and serves a MovieLens two-tower recommendation system. Offline, raw data is prepared into features and splits, a model is trained and evaluated, then user/item vectors and metadata are indexed. Online, FastAPI validates a request, the recommender retrieves a user vector, excludes previously rated items, searches for similar item vectors, and attaches metadata. The graph includes the model and shared settings as internal layers. Some training and indexing excerpts are partial; uncertain links are omitted or marked unverified.

Main entry points: [`training/train.py`](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/train.py) (Train Model), [`config.py`](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/config.py) (Shared Settings), [`training/evaluate.py`](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/evaluate.py) (Offline Evaluation), [`training/index.py`](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/index.py) (Build Vector Index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_offline["Offline Modeling"]
  node_prepare["Prepare Features<br/>[prepare.py]"]
  node_sampling["Negative Sampling<br/>[sampling.py]"]
  node_model["Two-Tower Model<br/>[two_tower.py]"]
  node_train["Train Model<br/>[train.py]"]
  node_evaluate["Offline Evaluation<br/>[evaluate.py]"]
end

subgraph group_indexing["Indexing"]
  node_artifacts["Model Artifacts<br/>[train.py]"]
  node_indexer["Build Vector Index<br/>[index.py]"]
end

subgraph group_serving["Recommendation API"]
  node_app["FastAPI App<br/>[main.py]"]
  node_routes["Recommendation Routes<br/>[routes.py]"]
  node_schemas["Response Schemas<br/>[schemas.py]"]
  node_service["Recommendation Service<br/>[recommender.py]"]
  node_repository["Data Repository<br/>[repositories.py]"]
end

subgraph group_storage["Data Stores"]
  node_postgres[("Postgres")]
  node_qdrant[("Qdrant")]
end

node_data[("MovieLens Data")]
node_settings["Shared Settings<br/>[config.py]"]
node_http(("HTTP Client"))
node_mlflow["MLflow"]

node_data -->|"reads"| node_prepare
node_prepare -.->|"writes prepared data"| node_train
node_sampling -->|"samples negatives"| node_train
node_train -->|"trains"| node_model
node_train -->|"evaluates scores"| node_evaluate
node_train -->|"exports checkpoint"| node_artifacts
node_evaluate -->|"scores model"| node_model
node_train -->|"logs runs"| node_mlflow
node_evaluate -->|"logs metrics"| node_mlflow
node_settings -->|"configures paths"| node_prepare
node_settings -->|"configures paths"| node_train
node_settings -->|"configures paths"| node_evaluate
node_settings -->|"configures stores"| node_indexer
node_artifacts -->|"loads model"| node_indexer
node_indexer -->|"loads metadata"| node_postgres
node_indexer -->|"writes vectors"| node_qdrant
node_http -->|"sends requests"| node_app
node_app -->|"registers router"| node_routes
node_routes -->|"calls"| node_service
node_routes -->|"shapes responses"| node_schemas
node_app -->|"constructs"| node_repository
node_service -->|"retrieves recommendations"| node_repository
node_repository -->|"reads metadata"| node_postgres
node_repository -->|"searches vectors"| node_qdrant

click node_prepare "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/prepare.py"
click node_sampling "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/sampling.py"
click node_model "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/models/two_tower.py"
click node_train "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/train.py"
click node_evaluate "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/evaluate.py"
click node_settings "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/config.py"
click node_artifacts "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/train.py"
click node_indexer "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/index.py"
click node_app "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/main.py"
click node_routes "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/routes.py"
click node_schemas "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/schemas.py"
click node_service "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/recommender.py"
click node_repository "https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/repositories.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_prepare,node_sampling,node_model,node_train,node_evaluate,node_http toneBlue
class node_artifacts,node_indexer,node_data toneAmber
class node_app,node_routes,node_schemas,node_service,node_repository toneMint
class node_postgres,node_qdrant toneRose
class node_settings toneTeal
class node_mlflow toneIndigo
```

## Components

### Offline Modeling

- [Prepare Features](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/prepare.py): `training/prepare.py`
- [Negative Sampling](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/sampling.py): `training/sampling.py`
- [Two-Tower Model](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/models/two_tower.py): `training/models/two_tower.py`
- [Train Model](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/train.py): `training/train.py`
- [Offline Evaluation](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/evaluate.py): `training/evaluate.py`

### Indexing

- [Model Artifacts](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/train.py): `training/train.py`
- [Build Vector Index](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/training/index.py): `training/index.py`

### Recommendation API

- [FastAPI App](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/main.py): `api/main.py`
- [Recommendation Routes](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/routes.py): `api/routes.py`
- [Response Schemas](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/schemas.py): `api/schemas.py`
- [Recommendation Service](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/recommender.py): `api/recommender.py`
- [Data Repository](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/api/repositories.py): `api/repositories.py`

### Data Stores

- **Postgres**
- **Qdrant**

### Other components

- **MovieLens Data**
- [Shared Settings](https://github.com/westbrook210207-tech/movielens100k-retrieval/blob/main/config.py): `config.py`
- **HTTP Client**
- **MLflow**

## Connections

- MovieLens Data → Prepare Features: reads (evidence: `training/prepare.py`)
- Prepare Features → Train Model: writes prepared data
- Negative Sampling → Train Model: samples negatives (evidence: `training/train.py`)
- Train Model → Two-Tower Model: trains (evidence: `training/train.py`)
- Train Model → Offline Evaluation: evaluates scores (evidence: `training/train.py`)
- Train Model → Model Artifacts: exports checkpoint (evidence: `training/train.py`)
- Offline Evaluation → Two-Tower Model: scores model (evidence: `training/evaluate.py`)
- Train Model → MLflow: logs runs (evidence: `training/train.py`)
- Offline Evaluation → MLflow: logs metrics (evidence: `training/evaluate.py`)
- Shared Settings → Prepare Features: configures paths (evidence: `training/prepare.py`)
- Shared Settings → Train Model: configures paths (evidence: `training/train.py`)
- Shared Settings → Offline Evaluation: configures paths (evidence: `training/evaluate.py`)
- Shared Settings → Build Vector Index: configures stores (evidence: `training/index.py`)
- Model Artifacts → Build Vector Index: loads model (evidence: `training/index.py`)
- Build Vector Index → Postgres: loads metadata (evidence: `training/index.py`)
- Build Vector Index → Qdrant: writes vectors (evidence: `training/index.py`)
- HTTP Client → FastAPI App: sends requests (evidence: `api/main.py`)
- FastAPI App → Recommendation Routes: registers router (evidence: `api/main.py`)
- Recommendation Routes → Recommendation Service: calls (evidence: `api/routes.py`)
- Recommendation Routes → Response Schemas: shapes responses (evidence: `api/routes.py`)
- FastAPI App → Data Repository: constructs (evidence: `api/main.py`)
- Recommendation Service → Data Repository: retrieves recommendations (evidence: `api/recommender.py`)
- Data Repository → Postgres: reads metadata (evidence: `api/repositories.py`)
- Data Repository → Qdrant: searches vectors (evidence: `api/repositories.py`)
