# andreidonskoi/post_recsys architecture

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

- Interactive diagram: https://gitdiagram.com/andreidonskoi/post_recsys
- Repository: https://github.com/andreidonskoi/post_recsys

## Overview

This is a text-post recommendation service with a separate model-development workflow. In the live path, a request is checked for a known user, user-and-time features are built across posts, an A/B group selects a model, and scored posts are returned in the requested order. The README also describes offline feature creation and model training; the notebook contents were not sampled, so those stages are shown only at the documented level. The baseline endpoint is a separate random-post path.

Main entry points: [`src/service/service.py`](https://github.com/andreidonskoi/post_recsys/blob/master/src/service/service.py) (Recommendation endpoints), [`src/data/data_for_launch.py`](https://github.com/andreidonskoi/post_recsys/blob/master/src/data/data_for_launch.py) (Launch data queries), [`src/models/get_predictions.py`](https://github.com/andreidonskoi/post_recsys/blob/master/src/models/get_predictions.py) (Post scoring and ranking), [`src/features/construct_user_dataframe.py`](https://github.com/andreidonskoi/post_recsys/blob/master/src/features/construct_user_dataframe.py) (User-post features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Service API"]
  node_service["Recommendation endpoints<br/>[service.py]"]
  node_response_schema["Response schemas<br/>[schema.py]"]
  node_baseline_posts["Random baseline posts<br/>[service.py]"]
end

subgraph group_features["Recommendation Features"]
  node_feature_builder["User-post features"]
end

subgraph group_models["Model Selection"]
  node_experiment_group["A/B assignment<br/>[model_loader.py]"]
  node_prediction["Post scoring and ranking<br/>[get_predictions.py]"]
  node_model_loader["Model loading<br/>[model_loader.py]"]
  node_model_files["Control and test models"]
  node_model_training["Model training"]
end

subgraph group_data["Data and Development"]
  node_launch_data["Launch data queries<br/>[data_for_launch.py]"]
  node_db_connection["Database connection<br/>[connection.py]"]
  node_offline_features["Offline feature creation"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"requests recommendations"| node_service
node_service -->|"checks known users"| node_launch_data
node_service -->|"builds user features"| node_feature_builder
node_service -->|"assigns experiment"| node_experiment_group
node_service -->|"requests ranked posts"| node_prediction
node_prediction -->|"loads group model"| node_model_loader
node_prediction -->|"looks up post text"| node_launch_data
node_model_loader -->|"loads model artifact"| node_model_files
node_feature_builder -->|"uses user and post data"| node_launch_data
node_launch_data -->|"queries through"| node_db_connection
node_db_connection -.->|"connects to"| node_postgres
node_service -->|"declares response types"| node_response_schema
node_client -->|"requests random baseline"| node_baseline_posts
node_baseline_posts -->|"selects post records"| node_launch_data
node_offline_features -.->|"prepares training data"| node_model_training
node_model_training -.->|"saves trained models"| node_model_files

click node_service "https://github.com/andreidonskoi/post_recsys/blob/master/src/service/service.py"
click node_response_schema "https://github.com/andreidonskoi/post_recsys/blob/master/src/service/schema.py"
click node_feature_builder "https://github.com/andreidonskoi/post_recsys/blob/master/src/features/construct_user_dataframe.py"
click node_experiment_group "https://github.com/andreidonskoi/post_recsys/blob/master/src/models/model_loader.py"
click node_prediction "https://github.com/andreidonskoi/post_recsys/blob/master/src/models/get_predictions.py"
click node_model_loader "https://github.com/andreidonskoi/post_recsys/blob/master/src/models/model_loader.py"
click node_model_files "https://github.com/andreidonskoi/post_recsys/tree/master/models"
click node_launch_data "https://github.com/andreidonskoi/post_recsys/blob/master/src/data/data_for_launch.py"
click node_db_connection "https://github.com/andreidonskoi/post_recsys/blob/master/src/service/connection.py"
click node_offline_features "https://github.com/andreidonskoi/post_recsys/tree/master/notebooks"
click node_model_training "https://github.com/andreidonskoi/post_recsys/tree/master/notebooks"
click node_baseline_posts "https://github.com/andreidonskoi/post_recsys/blob/master/src/service/service.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_service,node_response_schema,node_baseline_posts,node_client toneBlue
class node_feature_builder,node_postgres toneAmber
class node_experiment_group,node_prediction,node_model_loader,node_model_files,node_model_training toneMint
class node_launch_data,node_db_connection,node_offline_features toneRose
```

## Components

### Service API

- [Recommendation endpoints](https://github.com/andreidonskoi/post_recsys/blob/master/src/service/service.py): `src/service/service.py`
- [Response schemas](https://github.com/andreidonskoi/post_recsys/blob/master/src/service/schema.py): `src/service/schema.py`
- [Random baseline posts](https://github.com/andreidonskoi/post_recsys/blob/master/src/service/service.py): `src/service/service.py`

### Recommendation Features

- [User-post features](https://github.com/andreidonskoi/post_recsys/blob/master/src/features/construct_user_dataframe.py): `src/features/construct_user_dataframe.py`

### Model Selection

- [A/B assignment](https://github.com/andreidonskoi/post_recsys/blob/master/src/models/model_loader.py): `src/models/model_loader.py`
- [Post scoring and ranking](https://github.com/andreidonskoi/post_recsys/blob/master/src/models/get_predictions.py): `src/models/get_predictions.py`
- [Model loading](https://github.com/andreidonskoi/post_recsys/blob/master/src/models/model_loader.py): `src/models/model_loader.py`
- [Control and test models](https://github.com/andreidonskoi/post_recsys/tree/master/models): `models`
- [Model training](https://github.com/andreidonskoi/post_recsys/tree/master/notebooks): `notebooks`

### Data and Development

- [Launch data queries](https://github.com/andreidonskoi/post_recsys/blob/master/src/data/data_for_launch.py): `src/data/data_for_launch.py`
- [Database connection](https://github.com/andreidonskoi/post_recsys/blob/master/src/service/connection.py): `src/service/connection.py`
- [Offline feature creation](https://github.com/andreidonskoi/post_recsys/tree/master/notebooks): `notebooks`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Recommendation endpoints: requests recommendations (evidence: `README.md`)
- Recommendation endpoints → Launch data queries: checks known users (evidence: `src/service/service.py`)
- Recommendation endpoints → User-post features: builds user features (evidence: `src/service/service.py`)
- Recommendation endpoints → A/B assignment: assigns experiment (evidence: `src/service/service.py`)
- Recommendation endpoints → Post scoring and ranking: requests ranked posts (evidence: `src/service/service.py`)
- Post scoring and ranking → Model loading: loads group model (evidence: `src/models/get_predictions.py`)
- Post scoring and ranking → Launch data queries: looks up post text (evidence: `src/models/get_predictions.py`)
- Model loading → Control and test models: loads model artifact (evidence: `src/models/model_loader.py`)
- User-post features → Launch data queries: uses user and post data (evidence: `src/features/construct_user_dataframe.py`)
- Launch data queries → Database connection: queries through (evidence: `src/data/data_for_launch.py`)
- Database connection → PostgreSQL: connects to
- Recommendation endpoints → Response schemas: declares response types (evidence: `src/service/service.py`)
- API client → Random baseline posts: requests random baseline (evidence: `src/service/service.py`)
- Random baseline posts → Launch data queries: selects post records (evidence: `src/service/service.py`)
- Offline feature creation → Model training: prepares training data (evidence: `README.md`)
- Model training → Control and test models: saves trained models (evidence: `README.md`)
