# achrafarbounper/thinktuning architecture

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

- Interactive diagram: https://gitdiagram.com/achrafarbounper/thinktuning
- Repository: https://github.com/achrafarbounper/thinktuning

## Overview

ThinkTuning is a multilingual French/English sentiment-analysis product with a React dashboard and FastAPI backend. Its main workflow is to submit text for classification or train a model; the documented pipeline also labels unlabeled data, filters by confidence, then fine-tunes an LLM. Manual review closes an active-learning loop back into training. The backend additionally exposes an AI agent and MCP integrations. Some capabilities are documented but their implementation was not sampled, so those links are cited to the README rather than presented as inspected source calls.

Main entry points: [`backend/app/api/routes/pipeline.py`](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/api/routes/pipeline.py) (Pipeline routes), [`backend/app/application/pipeline_runner.py`](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/application/pipeline_runner.py) (Pipeline runner), [`backend/app/application`](https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/application) (Prediction and training), [`backend/app/agent/core.py`](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/agent/core.py) (Agent runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web dashboard"]
  node_app["Dashboard shell<br/>[App.tsx]"]
  node_pages["Product pages"]
  node_api_client["API client"]
  node_pipeline_page["Pipeline page<br/>[PipelinePage.tsx]"]
  node_tracker["Job tracker"]
end

subgraph group_api["API and application"]
  node_api_routes["Versioned API"]
  node_pipeline_route["Pipeline routes<br/>[pipeline.py]"]
  node_pipeline_runner["Pipeline runner<br/>[pipeline_runner.py]"]
  node_models["Domain job models<br/>[models.py]"]
  node_job_store[("Job persistence<br/>[job_store.py]")]
end

subgraph group_ml["ML workflows"]
  node_predict_train["Prediction and training"]
  node_ml_adapters["ML adapters"]
  node_augmentation["EDA augmentation<br/>[eda.py]"]
  node_labeling["Confidence labeling<br/>[label_dataset.py]"]
  node_finetune["LLM fine-tuning<br/>[finetune_llm.py]"]
  node_review["Active learning review<br/>[active_learning.py]"]
  node_merge["Reviewed-data merge"]
end

subgraph group_agent["Agent and MCP"]
  node_agent_core["Agent runtime<br/>[core.py]"]
  node_tools["Agent tools"]
  node_mcp["MCP server<br/>[mcp_server_sse.py]"]
end

node_user(("User"))
node_external_models{{"Model providers"}}
node_reviewer(("Human reviewer"))

node_user -->|"uses"| node_app
node_app -->|"navigates"| node_pages
node_pages -->|"requests"| node_api_client
node_pipeline_page -->|"starts and tracks"| node_api_client
node_pipeline_page -->|"renders"| node_tracker
node_api_client -->|"calls"| node_api_routes
node_api_routes -.->|"routes pipeline"| node_pipeline_route
node_pipeline_route -->|"starts and cancels"| node_pipeline_runner
node_pipeline_route -->|"reads and lists"| node_job_store
node_pipeline_route -->|"validates and returns"| node_models
node_pipeline_runner -->|"updates jobs"| node_job_store
node_pipeline_runner -->|"labels and filters"| node_labeling
node_pipeline_runner -->|"runs subprocess"| node_finetune
node_labeling -.->|"uses classifier"| node_ml_adapters
node_predict_train -.->|"executes ML"| node_ml_adapters
node_predict_train -->|"augments training data"| node_augmentation
node_user -->|"submits text or training"| node_predict_train
node_review -->|"selects uncertain samples"| node_reviewer
node_reviewer -->|"provides corrections"| node_merge
node_merge -->|"feeds retraining"| node_predict_train
node_user -->|"asks assistant"| node_agent_core
node_agent_core -.->|"invokes tools"| node_tools
node_user -->|"connects MCP client"| node_mcp
node_agent_core -.->|"uses language model"| node_external_models

click node_app "https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/App.tsx"
click node_pages "https://github.com/achrafarbounper/thinktuning/tree/main/frontend/src/pages"
click node_api_client "https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/api/sentimentApiClient.ts"
click node_pipeline_page "https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/pages/PipelinePage.tsx"
click node_tracker "https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/components/PipelineJobTracker.tsx"
click node_api_routes "https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/api/routes/v1"
click node_pipeline_route "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/api/routes/pipeline.py"
click node_pipeline_runner "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/application/pipeline_runner.py"
click node_models "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/domain/entities/models.py"
click node_job_store "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/infrastructure/persistence/job_store.py"
click node_predict_train "https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/application"
click node_ml_adapters "https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/infrastructure/ml"
click node_augmentation "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/infrastructure/ml/augmentation/eda.py"
click node_labeling "https://github.com/achrafarbounper/thinktuning/blob/main/backend/label_dataset.py"
click node_finetune "https://github.com/achrafarbounper/thinktuning/blob/main/backend/finetune_llm.py"
click node_review "https://github.com/achrafarbounper/thinktuning/blob/main/backend/active_learning.py"
click node_merge "https://github.com/achrafarbounper/thinktuning/blob/main/backend/merge_reviewed_data.py"
click node_agent_core "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/agent/core.py"
click node_tools "https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/infrastructure/tools"
click node_mcp "https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/infrastructure/mcp/mcp_server_sse.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_app,node_pages,node_api_client,node_pipeline_page,node_tracker,node_user,node_reviewer toneBlue
class node_api_routes,node_pipeline_route,node_pipeline_runner,node_models,node_job_store toneAmber
class node_predict_train,node_ml_adapters,node_augmentation,node_labeling,node_finetune,node_review,node_merge toneMint
class node_agent_core,node_tools,node_mcp toneRose
class node_external_models toneIndigo
```

## Components

### Web dashboard

- [Dashboard shell](https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Product pages](https://github.com/achrafarbounper/thinktuning/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/api/sentimentApiClient.ts): `frontend/src/api/sentimentApiClient.ts`
- [Pipeline page](https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/pages/PipelinePage.tsx): `frontend/src/pages/PipelinePage.tsx`
- [Job tracker](https://github.com/achrafarbounper/thinktuning/blob/main/frontend/src/components/PipelineJobTracker.tsx): `frontend/src/components/PipelineJobTracker.tsx`

### API and application

- [Versioned API](https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/api/routes/v1): `backend/app/api/routes/v1`
- [Pipeline routes](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/api/routes/pipeline.py): `backend/app/api/routes/pipeline.py`
- [Pipeline runner](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/application/pipeline_runner.py): `backend/app/application/pipeline_runner.py`
- [Domain job models](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/domain/entities/models.py): `backend/app/domain/entities/models.py`
- [Job persistence](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/infrastructure/persistence/job_store.py): `backend/app/infrastructure/persistence/job_store.py`

### ML workflows

- [Prediction and training](https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/application): `backend/app/application`
- [ML adapters](https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/infrastructure/ml): `backend/app/infrastructure/ml`
- [EDA augmentation](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/infrastructure/ml/augmentation/eda.py): `backend/app/infrastructure/ml/augmentation/eda.py`
- [Confidence labeling](https://github.com/achrafarbounper/thinktuning/blob/main/backend/label_dataset.py): `backend/label_dataset.py`
- [LLM fine-tuning](https://github.com/achrafarbounper/thinktuning/blob/main/backend/finetune_llm.py): `backend/finetune_llm.py`
- [Active learning review](https://github.com/achrafarbounper/thinktuning/blob/main/backend/active_learning.py): `backend/active_learning.py`
- [Reviewed-data merge](https://github.com/achrafarbounper/thinktuning/blob/main/backend/merge_reviewed_data.py): `backend/merge_reviewed_data.py`

### Agent and MCP

- [Agent runtime](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/agent/core.py): `backend/app/agent/core.py`
- [Agent tools](https://github.com/achrafarbounper/thinktuning/tree/main/backend/app/infrastructure/tools): `backend/app/infrastructure/tools`
- [MCP server](https://github.com/achrafarbounper/thinktuning/blob/main/backend/app/infrastructure/mcp/mcp_server_sse.py): `backend/app/infrastructure/mcp/mcp_server_sse.py`

### Other components

- **User**
- **Model providers**
- **Human reviewer**

## Connections

- User → Dashboard shell: uses
- Dashboard shell → Product pages: navigates (evidence: `frontend/src/App.tsx`)
- Product pages → API client: requests (evidence: `frontend/src/api/sentimentApiClient.ts`)
- Pipeline page → API client: starts and tracks (evidence: `frontend/src/pages/PipelinePage.tsx`)
- Pipeline page → Job tracker: renders (evidence: `frontend/src/pages/PipelinePage.tsx`)
- API client → Versioned API: calls (evidence: `frontend/src/api/sentimentApiClient.ts`)
- Versioned API → Pipeline routes: routes pipeline (evidence: `backend/app/api/routes/v1/pipeline.py`)
- Pipeline routes → Pipeline runner: starts and cancels (evidence: `backend/app/api/routes/pipeline.py`)
- Pipeline routes → Job persistence: reads and lists (evidence: `backend/app/api/routes/pipeline.py`)
- Pipeline routes → Domain job models: validates and returns (evidence: `backend/app/api/routes/pipeline.py`)
- Pipeline runner → Job persistence: updates jobs (evidence: `backend/app/application/pipeline_runner.py`)
- Pipeline runner → Confidence labeling: labels and filters (evidence: `backend/app/application/pipeline_runner.py`)
- Pipeline runner → LLM fine-tuning: runs subprocess (evidence: `backend/app/application/pipeline_runner.py`)
- Confidence labeling → ML adapters: uses classifier
- Prediction and training → ML adapters: executes ML (evidence: `backend/app/application/classifier_registry.py`)
- Prediction and training → EDA augmentation: augments training data
- User → Prediction and training: submits text or training
- Active learning review → Human reviewer: selects uncertain samples
- Human reviewer → Reviewed-data merge: provides corrections
- Reviewed-data merge → Prediction and training: feeds retraining
- User → Agent runtime: asks assistant
- Agent runtime → Agent tools: invokes tools
- User → MCP server: connects MCP client
- Agent runtime → Model providers: uses language model
