# kajamaqbool/dyslexia-ml-service-master architecture

> Architecture diagram of the GitHub repository kajamaqbool/dyslexia-ml-service-master, 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/kajamaqbool/dyslexia-ml-service-master
- Repository: https://github.com/kajamaqbool/dyslexia-ml-service-master

## Overview

This repository provides a FastAPI dyslexia-risk analysis service. A backend sends reading-session data to `/analyze`; the service accepts feature values or eye-tracking frames, derives metrics where needed, and returns a risk score, classification, confidence, and score breakdown. The README describes the result as a 70/30 blend of rule-based and Random Forest scoring. The sampled `main.py` shows frame processing and model loading, but omits the endpoint’s scoring body; the relationship to the standalone rules module is therefore documented at the service level, not verified as a direct call. The tree contains duplicate root and `dyslexia-ml-service-master/` copies; this map uses the root files.

Main entry points: [`main.py`](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py) (FastAPI endpoints), [`generator.py`](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/generator.py) (Synthetic training data), [`schema.py`](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/schema.py) (Risk result), [`rules.py`](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/rules.py) (Rule-based scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and workflow"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_frame_metrics["Frame metrics<br/>[main.py]"]
  node_contracts["Request and response schemas<br/>[schema.py]"]
  node_analysis_result["Risk result<br/>[schema.py]"]
end

subgraph group_analysis["Risk analysis"]
  node_rule_engine["Rule-based scoring<br/>[rules.py]"]
  node_rf_model["Random Forest scoring<br/>[main.py]"]
  node_synthetic_data["Synthetic training data<br/>[generator.py]"]
end

subgraph group_model["Model data"]
  node_model_file["Serialized model<br/>[dyslexia_model.pkl]"]
end

node_backend(("Backend service"))

node_backend -->|"calls analyze"| node_api
node_api -->|"derives metrics"| node_frame_metrics
node_api -.->|"uses rule score"| node_rule_engine
node_api -.->|"uses ML score"| node_rf_model
node_rf_model -->|"loads model"| node_model_file
node_api -.->|"returns analysis"| node_analysis_result
node_synthetic_data -.->|"generates training data"| node_rf_model

click node_api "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py"
click node_frame_metrics "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py"
click node_contracts "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/schema.py"
click node_rule_engine "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/rules.py"
click node_rf_model "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py"
click node_synthetic_data "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/generator.py"
click node_model_file "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/dyslexia_model.pkl"
click node_analysis_result "https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/schema.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_api,node_frame_metrics,node_contracts,node_analysis_result toneBlue
class node_rule_engine,node_rf_model,node_synthetic_data toneAmber
class node_model_file toneMint
class node_backend toneIndigo
```

## Components

### API and workflow

- [FastAPI endpoints](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py): `main.py`
- [Frame metrics](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py): `main.py`
- [Request and response schemas](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/schema.py): `schema.py`
- [Risk result](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/schema.py): `schema.py`

### Risk analysis

- [Rule-based scoring](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/rules.py): `rules.py`
- [Random Forest scoring](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/main.py): `main.py`
- [Synthetic training data](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/generator.py): `generator.py`

### Model data

- [Serialized model](https://github.com/kajamaqbool/dyslexia-ml-service-master/blob/main/dyslexia_model.pkl): `dyslexia_model.pkl`

### Other components

- **Backend service**

## Connections

- Backend service → FastAPI endpoints: calls analyze (evidence: `README.md`)
- FastAPI endpoints → Frame metrics: derives metrics (evidence: `main.py`)
- FastAPI endpoints → Rule-based scoring: uses rule score (evidence: `README.md`)
- FastAPI endpoints → Random Forest scoring: uses ML score (evidence: `README.md`)
- Random Forest scoring → Serialized model: loads model (evidence: `main.py`)
- FastAPI endpoints → Risk result: returns analysis (evidence: `README.md`)
- Synthetic training data → Random Forest scoring: generates training data
