# mustafa-elsherif/volition architecture

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

- Interactive diagram: https://gitdiagram.com/mustafa-elsherif/volition
- Repository: https://github.com/mustafa-elsherif/volition

## Overview

Volition turns IBL neural recordings into processed sessions, trains and evaluates a shared region-tagged neuron-set decoder, then serves predictions with neuron and region attention through either a FastAPI service or an in-browser dashboard. The README documents the broader experimental outputs and deployment capabilities; sampled code supports the main training, inference, and UI links. Some data-building and experiment details are unsampled, so those links rely on SOURCE INDEX references or README statements.

Main entry points: [`src/models/run_experiments.py`](https://github.com/mustafa-elsherif/volition/blob/main/src/models/run_experiments.py) (Experiment runner), [`src/data/build_dataset.py`](https://github.com/mustafa-elsherif/volition/blob/main/src/data/build_dataset.py) (Dataset builder), [`src/common/settings.py`](https://github.com/mustafa-elsherif/volition/blob/main/src/common/settings.py) (Settings and storage), [`api/app/main.py`](https://github.com/mustafa-elsherif/volition/blob/main/api/app/main.py) (FastAPI routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset_builder["Dataset builder<br/>[build_dataset.py]"]
  node_trial_cleaning["Trial cleaning<br/>[clean_trials.py]"]
  node_neuron_features["Neuron features<br/>[features.py]"]
  node_session_processing["Session processing<br/>[sessions.py]"]
  node_settings["Settings and storage<br/>[settings.py]"]
  node_data_checks["Data checks<br/>[checks.py]"]
end

subgraph group_model["Model and evaluation"]
  node_model_data["Model data views<br/>[data.py]"]
  node_splits["Trial splits<br/>[splits.py]"]
  node_set_transformer["Neuron set transformer<br/>[set_transformer.py]"]
  node_training["Pretraining and training<br/>[train.py]"]
  node_baselines["Baseline models<br/>[baselines.py]"]
  node_experiment_runner["Experiment runner<br/>[run_experiments.py]"]
  node_evaluation_metrics["Decoding metrics<br/>[metrics.py]"]
  node_evaluation_statistics["Evaluation statistics<br/>[statistics.py]"]
  node_serialization["Model serialization<br/>[serialize.py]"]
  node_artifacts["Model artifacts<br/>[decoder.onnx]"]
end

subgraph group_serving["Inference services"]
  node_api_main["FastAPI routes<br/>[main.py]"]
  node_api_inference["ONNX decoder<br/>[inference.py]"]
  node_api_assistant["Grounded assistant<br/>[assistant.py]"]
end

subgraph group_experience["User experience"]
  node_dashboard["Web dashboard<br/>[app.js]"]
  node_browser_inference["Browser inference<br/>[inference.js]"]
  node_browser_assistant["Browser assistant<br/>[assistant.js]"]
end

node_ibl[("IBL recordings")]
node_visitor(("Demo visitor"))

node_ibl -->|"provides recordings"| node_dataset_builder
node_dataset_builder -->|"uses cleaning"| node_trial_cleaning
node_dataset_builder -->|"uses features"| node_neuron_features
node_dataset_builder -->|"uses session data"| node_session_processing
node_dataset_builder -->|"loads settings"| node_settings
node_session_processing -->|"loads sessions"| node_settings
node_settings -->|"validates sessions"| node_data_checks
node_experiment_runner -->|"loads configuration"| node_settings
node_experiment_runner -->|"loads model data"| node_model_data
node_experiment_runner -->|"creates splits"| node_splits
node_experiment_runner -->|"trains models"| node_training
node_experiment_runner -->|"runs baselines"| node_baselines
node_training -->|"packs trials"| node_model_data
node_training -->|"trains network"| node_set_transformer
node_experiment_runner -->|"scores predictions"| node_evaluation_metrics
node_experiment_runner -->|"summarizes results"| node_evaluation_statistics
node_experiment_runner -->|"exports model"| node_serialization
node_serialization -->|"writes artifacts"| node_artifacts
node_api_main -->|"initializes decoder"| node_api_inference
node_api_main -->|"initializes assistant"| node_api_assistant
node_api_main -->|"routes decode"| node_api_inference
node_api_inference -->|"loads ONNX model"| node_artifacts
node_dashboard -->|"requests decoding"| node_browser_inference
node_dashboard -->|"sends questions"| node_browser_assistant
node_browser_inference -->|"loads browser model"| node_artifacts
node_visitor -->|"uses demo"| node_dashboard

click node_dataset_builder "https://github.com/mustafa-elsherif/volition/blob/main/src/data/build_dataset.py"
click node_trial_cleaning "https://github.com/mustafa-elsherif/volition/blob/main/src/data/clean_trials.py"
click node_neuron_features "https://github.com/mustafa-elsherif/volition/blob/main/src/data/features.py"
click node_session_processing "https://github.com/mustafa-elsherif/volition/blob/main/src/data/sessions.py"
click node_settings "https://github.com/mustafa-elsherif/volition/blob/main/src/common/settings.py"
click node_data_checks "https://github.com/mustafa-elsherif/volition/blob/main/src/common/checks.py"
click node_model_data "https://github.com/mustafa-elsherif/volition/blob/main/src/models/data.py"
click node_splits "https://github.com/mustafa-elsherif/volition/blob/main/src/models/splits.py"
click node_set_transformer "https://github.com/mustafa-elsherif/volition/blob/main/src/models/set_transformer.py"
click node_training "https://github.com/mustafa-elsherif/volition/blob/main/src/models/train.py"
click node_baselines "https://github.com/mustafa-elsherif/volition/blob/main/src/models/baselines.py"
click node_experiment_runner "https://github.com/mustafa-elsherif/volition/blob/main/src/models/run_experiments.py"
click node_evaluation_metrics "https://github.com/mustafa-elsherif/volition/blob/main/src/evaluation/metrics.py"
click node_evaluation_statistics "https://github.com/mustafa-elsherif/volition/blob/main/src/evaluation/statistics.py"
click node_serialization "https://github.com/mustafa-elsherif/volition/blob/main/src/models/serialize.py"
click node_artifacts "https://github.com/mustafa-elsherif/volition/blob/main/artifacts/decoder.onnx"
click node_api_main "https://github.com/mustafa-elsherif/volition/blob/main/api/app/main.py"
click node_api_inference "https://github.com/mustafa-elsherif/volition/blob/main/api/app/inference.py"
click node_api_assistant "https://github.com/mustafa-elsherif/volition/blob/main/api/app/assistant.py"
click node_dashboard "https://github.com/mustafa-elsherif/volition/blob/main/web/app.js"
click node_browser_inference "https://github.com/mustafa-elsherif/volition/blob/main/web/inference.js"
click node_browser_assistant "https://github.com/mustafa-elsherif/volition/blob/main/web/assistant.js"

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_dataset_builder,node_trial_cleaning,node_neuron_features,node_session_processing,node_settings,node_data_checks toneBlue
class node_model_data,node_splits,node_set_transformer,node_training,node_baselines,node_experiment_runner,node_evaluation_metrics,node_evaluation_statistics,node_serialization,node_artifacts,node_ibl toneAmber
class node_api_main,node_api_inference,node_api_assistant toneMint
class node_dashboard,node_browser_inference,node_browser_assistant toneRose
class node_visitor toneIndigo
```

## Components

### Data preparation

- [Dataset builder](https://github.com/mustafa-elsherif/volition/blob/main/src/data/build_dataset.py): `src/data/build_dataset.py`
- [Trial cleaning](https://github.com/mustafa-elsherif/volition/blob/main/src/data/clean_trials.py): `src/data/clean_trials.py`
- [Neuron features](https://github.com/mustafa-elsherif/volition/blob/main/src/data/features.py): `src/data/features.py`
- [Session processing](https://github.com/mustafa-elsherif/volition/blob/main/src/data/sessions.py): `src/data/sessions.py`
- [Settings and storage](https://github.com/mustafa-elsherif/volition/blob/main/src/common/settings.py): `src/common/settings.py`
- [Data checks](https://github.com/mustafa-elsherif/volition/blob/main/src/common/checks.py): `src/common/checks.py`

### Model and evaluation

- [Model data views](https://github.com/mustafa-elsherif/volition/blob/main/src/models/data.py): `src/models/data.py`
- [Trial splits](https://github.com/mustafa-elsherif/volition/blob/main/src/models/splits.py): `src/models/splits.py`
- [Neuron set transformer](https://github.com/mustafa-elsherif/volition/blob/main/src/models/set_transformer.py): `src/models/set_transformer.py`
- [Pretraining and training](https://github.com/mustafa-elsherif/volition/blob/main/src/models/train.py): `src/models/train.py`
- [Baseline models](https://github.com/mustafa-elsherif/volition/blob/main/src/models/baselines.py): `src/models/baselines.py`
- [Experiment runner](https://github.com/mustafa-elsherif/volition/blob/main/src/models/run_experiments.py): `src/models/run_experiments.py`
- [Decoding metrics](https://github.com/mustafa-elsherif/volition/blob/main/src/evaluation/metrics.py): `src/evaluation/metrics.py`
- [Evaluation statistics](https://github.com/mustafa-elsherif/volition/blob/main/src/evaluation/statistics.py): `src/evaluation/statistics.py`
- [Model serialization](https://github.com/mustafa-elsherif/volition/blob/main/src/models/serialize.py): `src/models/serialize.py`
- [Model artifacts](https://github.com/mustafa-elsherif/volition/blob/main/artifacts/decoder.onnx): `artifacts/decoder.onnx`

### Inference services

- [FastAPI routes](https://github.com/mustafa-elsherif/volition/blob/main/api/app/main.py): `api/app/main.py`
- [ONNX decoder](https://github.com/mustafa-elsherif/volition/blob/main/api/app/inference.py): `api/app/inference.py`
- [Grounded assistant](https://github.com/mustafa-elsherif/volition/blob/main/api/app/assistant.py): `api/app/assistant.py`

### User experience

- [Web dashboard](https://github.com/mustafa-elsherif/volition/blob/main/web/app.js): `web/app.js`
- [Browser inference](https://github.com/mustafa-elsherif/volition/blob/main/web/inference.js): `web/inference.js`
- [Browser assistant](https://github.com/mustafa-elsherif/volition/blob/main/web/assistant.js): `web/assistant.js`

### Other components

- **IBL recordings**
- **Demo visitor**

## Connections

- IBL recordings → Dataset builder: provides recordings (evidence: `README.md`)
- Dataset builder → Trial cleaning: uses cleaning (evidence: `src/data/build_dataset.py`)
- Dataset builder → Neuron features: uses features (evidence: `src/data/build_dataset.py`)
- Dataset builder → Session processing: uses session data (evidence: `src/data/build_dataset.py`)
- Dataset builder → Settings and storage: loads settings (evidence: `src/data/build_dataset.py`)
- Session processing → Settings and storage: loads sessions (evidence: `src/data/sessions.py`)
- Settings and storage → Data checks: validates sessions (evidence: `src/common/settings.py`)
- Experiment runner → Settings and storage: loads configuration (evidence: `src/models/run_experiments.py`)
- Experiment runner → Model data views: loads model data (evidence: `src/models/run_experiments.py`)
- Experiment runner → Trial splits: creates splits (evidence: `src/models/run_experiments.py`)
- Experiment runner → Pretraining and training: trains models (evidence: `src/models/run_experiments.py`)
- Experiment runner → Baseline models: runs baselines (evidence: `src/models/run_experiments.py`)
- Pretraining and training → Model data views: packs trials (evidence: `src/models/train.py`)
- Pretraining and training → Neuron set transformer: trains network (evidence: `src/models/train.py`)
- Experiment runner → Decoding metrics: scores predictions (evidence: `src/models/run_experiments.py`)
- Experiment runner → Evaluation statistics: summarizes results (evidence: `src/models/run_experiments.py`)
- Experiment runner → Model serialization: exports model (evidence: `README.md`)
- Model serialization → Model artifacts: writes artifacts (evidence: `README.md`)
- FastAPI routes → ONNX decoder: initializes decoder (evidence: `api/app/main.py`)
- FastAPI routes → Grounded assistant: initializes assistant (evidence: `api/app/main.py`)
- FastAPI routes → ONNX decoder: routes decode (evidence: `api/app/main.py`)
- ONNX decoder → Model artifacts: loads ONNX model (evidence: `api/app/inference.py`)
- Web dashboard → Browser inference: requests decoding (evidence: `web/app.js`)
- Web dashboard → Browser assistant: sends questions (evidence: `web/app.js`)
- Browser inference → Model artifacts: loads browser model (evidence: `README.md`)
- Demo visitor → Web dashboard: uses demo (evidence: `README.md`)
