# mikatrow/fravil architecture

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

- Interactive diagram: https://gitdiagram.com/mikatrow/fravil
- Repository: https://github.com/mikatrow/fravil

## Overview

Fravil is a micro-workout recommendation app: a user sets time, available space, and mood; the web page sends these inputs to a Flask prediction endpoint and presents the recommended exercise with explanatory text and learning links. The endpoint validates and encodes the request, predicts with a trained classifier, and decodes the exercise label. A separate training script builds the classifier and encoders from a dataset. The README documents these capabilities; the graph follows the sampled runtime code and documented training flow.

Main entry points: [`src/app/page.tsx`](https://github.com/mikatrow/fravil/blob/main/src/app/page.tsx) (Recommendation page), [`host_flask.py`](https://github.com/mikatrow/fravil/blob/main/host_flask.py) (Prediction endpoint), [`model/train_and_predict_micro_exercises.py`](https://github.com/mikatrow/fravil/blob/main/model/train_and_predict_micro_exercises.py) (Model training), [`model/mood_encoder.pkl`](https://github.com/mikatrow/fravil/blob/main/model/mood_encoder.pkl) (Mood encoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_page["Recommendation page<br/>[page.tsx]"]
end

subgraph group_service["Recommendation service"]
  node_flask["Prediction endpoint<br/>[host_flask.py]"]
end

subgraph group_ml["Model lifecycle"]
  node_mood["Mood encoder<br/>[mood_encoder.pkl]"]
  node_exercise["Exercise encoder"]
  node_classifier["Exercise classifier"]
  node_trainer["Model training"]
  node_dataset["Exercise dataset"]
end

subgraph group_content["Exercise guidance"]
  node_catalog["Exercise descriptions<br/>[exercise_info.ts]"]
end

node_user(("User"))
node_resources(("Learning resources"))

node_user -->|"sets inputs"| node_page
node_page -->|"posts inputs"| node_flask
node_flask -->|"encodes mood"| node_mood
node_flask -->|"predicts exercise"| node_classifier
node_flask -->|"decodes label"| node_exercise
node_flask -->|"returns exercise"| node_page
node_page -->|"looks up details"| node_catalog
node_page -->|"shows recommendation"| node_user
node_page -.->|"links to guidance"| node_resources
node_trainer -->|"loads examples"| node_dataset
node_trainer -->|"saves classifier"| node_classifier
node_trainer -->|"saves encoder"| node_mood
node_trainer -->|"saves encoder"| node_exercise

click node_page "https://github.com/mikatrow/fravil/blob/main/src/app/page.tsx"
click node_catalog "https://github.com/mikatrow/fravil/blob/main/exercise_info.ts"
click node_flask "https://github.com/mikatrow/fravil/blob/main/host_flask.py"
click node_mood "https://github.com/mikatrow/fravil/blob/main/model/mood_encoder.pkl"
click node_exercise "https://github.com/mikatrow/fravil/blob/main/model/exercise_encoder.pkl"
click node_classifier "https://github.com/mikatrow/fravil/blob/main/model/exercise_rf_model.pkl"
click node_trainer "https://github.com/mikatrow/fravil/blob/main/model/train_and_predict_micro_exercises.py"
click node_dataset "https://github.com/mikatrow/fravil/blob/main/model/micro_exercises_dataset_grouped.csv"

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_page,node_user toneBlue
class node_flask toneAmber
class node_mood,node_exercise,node_classifier,node_trainer,node_dataset toneMint
class node_catalog toneRose
class node_resources toneIndigo
```

## Components

### Web experience

- [Recommendation page](https://github.com/mikatrow/fravil/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Recommendation service

- [Prediction endpoint](https://github.com/mikatrow/fravil/blob/main/host_flask.py): `host_flask.py`

### Model lifecycle

- [Mood encoder](https://github.com/mikatrow/fravil/blob/main/model/mood_encoder.pkl): `model/mood_encoder.pkl`
- [Exercise encoder](https://github.com/mikatrow/fravil/blob/main/model/exercise_encoder.pkl): `model/exercise_encoder.pkl`
- [Exercise classifier](https://github.com/mikatrow/fravil/blob/main/model/exercise_rf_model.pkl): `model/exercise_rf_model.pkl`
- [Model training](https://github.com/mikatrow/fravil/blob/main/model/train_and_predict_micro_exercises.py): `model/train_and_predict_micro_exercises.py`
- [Exercise dataset](https://github.com/mikatrow/fravil/blob/main/model/micro_exercises_dataset_grouped.csv): `model/micro_exercises_dataset_grouped.csv`

### Exercise guidance

- [Exercise descriptions](https://github.com/mikatrow/fravil/blob/main/exercise_info.ts): `exercise_info.ts`

### Other components

- **User**
- **Learning resources**

## Connections

- User → Recommendation page: sets inputs
- Recommendation page → Prediction endpoint: posts inputs
- Prediction endpoint → Mood encoder: encodes mood
- Prediction endpoint → Exercise classifier: predicts exercise
- Prediction endpoint → Exercise encoder: decodes label
- Prediction endpoint → Recommendation page: returns exercise
- Recommendation page → Exercise descriptions: looks up details
- Recommendation page → User: shows recommendation
- Recommendation page → Learning resources: links to guidance
- Model training → Exercise dataset: loads examples
- Model training → Exercise classifier: saves classifier
- Model training → Mood encoder: saves encoder
- Model training → Exercise encoder: saves encoder
