# jawadul-codes/algamask architecture

> Architecture diagram of the GitHub repository jawadul-codes/algamask, 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/jawadul-codes/algamask
- Repository: https://github.com/jawadul-codes/algamask

## Overview

AlgaMask is a local algae-bar formulation screening application. Its principal workflow accepts experiment settings, retrieves evidence, produces a constrained evidence explanation, screens formulations and controls, then returns a report that can be saved and reopened. The backend also supports versioned dataset review/publication and local retrieval-index workflows. Edges follow shown calls or README-documented behavior; API internals and several report/storage details were not excerpted, so those links rely only on README statements.

Main entry points: [`services/algamask/agents/supervisor.py`](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/supervisor.py) (Agent supervisor), [`services/algamask/rag.py`](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/rag.py) (Evidence search), [`services/algamask/api.py`](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/api.py) (FastAPI service), [`services/algamask/dataset.py`](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/dataset.py) (Dataset validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Screening workflow"]
  node_api["FastAPI service<br/>[api.py]"]
  node_contracts["Run contracts<br/>[schemas.py]"]
  node_orchestrator["Agent supervisor<br/>[supervisor.py]"]
  node_retrieval_agent["Evidence agent<br/>[retrieve.py]"]
  node_sensory["Sensory profile<br/>[profile.py]"]
  node_impact["Impact assessment<br/>[impact_agent.py]"]
  node_recipe_agent["Recipe strategy<br/>[chemistry.py]"]
end

subgraph group_evidence["Evidence retrieval"]
  node_search["Evidence search<br/>[rag.py]"]
  node_embeddings["Local embeddings<br/>[embeddings.py]"]
  node_search_contracts["Search contracts<br/>[search_schemas.py]"]
  node_generation["Grounded explanations<br/>[generation.py]"]
  node_retrieval["Mock retrieval<br/>[retrieval.py]"]
end

subgraph group_science["Dataset and screening"]
  node_dataset["Dataset validation<br/>[dataset.py]"]
  node_dataset_schema["Dataset schema<br/>[dataset_schema.py]"]
  node_publication["Dataset publication<br/>[publication.py]"]
  node_formulation["Formulation screening"]
  node_nutrition["Nutrition estimates<br/>[nutrition.py]"]
  node_optimizer["Recipe candidates<br/>[optimizer.py]"]
end

subgraph group_results["Results and history"]
  node_interpretation["Report interpretation"]
  node_report["Run report<br/>[report.py]"]
  node_run_store[("Saved run history<br/>[run_store.py]")]
  node_backup["Database recovery<br/>[backup.py]"]
end

node_user(("App user"))

node_user -->|"submits run"| node_api
node_api -->|"runs workflow"| node_orchestrator
node_api -->|"saves history"| node_run_store
node_api -->|"serves reports"| node_report
node_orchestrator -->|"builds profile"| node_sensory
node_orchestrator -->|"requests evidence"| node_retrieval_agent
node_orchestrator -->|"selects strategy"| node_recipe_agent
node_orchestrator -->|"assesses impact"| node_impact
node_orchestrator -->|"checks candidates"| node_formulation
node_orchestrator -->|"builds candidates"| node_optimizer
node_retrieval_agent -->|"queries evidence"| node_search
node_retrieval_agent -->|"loads mock cards"| node_retrieval
node_search -->|"embeds queries"| node_embeddings
node_search -->|"verifies snapshot"| node_dataset
node_search -->|"checks release"| node_publication
node_search -->|"returns search results"| node_search_contracts
node_recipe_agent -->|"explains evidence"| node_generation
node_formulation -->|"estimates nutrients"| node_nutrition
node_formulation -->|"creates formulas"| node_contracts
node_nutrition -->|"reads nutrition data"| node_dataset
node_publication -->|"validates snapshot"| node_dataset
node_dataset -->|"validates records"| node_dataset_schema
node_orchestrator -.->|"interprets results"| node_interpretation
node_report -.->|"persists reports"| node_run_store
node_backup -->|"backs up database"| node_run_store

click node_api "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/api.py"
click node_contracts "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/schemas.py"
click node_orchestrator "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/supervisor.py"
click node_retrieval_agent "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/retrieve.py"
click node_sensory "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/profile.py"
click node_impact "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/impact_agent.py"
click node_recipe_agent "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/chemistry.py"
click node_search "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/rag.py"
click node_embeddings "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/embeddings.py"
click node_search_contracts "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/search_schemas.py"
click node_generation "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/generation.py"
click node_retrieval "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/retrieval.py"
click node_dataset "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/dataset.py"
click node_dataset_schema "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/dataset_schema.py"
click node_publication "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/publication.py"
click node_formulation "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/formulation_engine.py"
click node_nutrition "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/nutrition.py"
click node_optimizer "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/optimizer.py"
click node_interpretation "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/report_interpretation.py"
click node_report "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/report.py"
click node_run_store "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/run_store.py"
click node_backup "https://github.com/jawadul-codes/algamask/blob/main/services/algamask/backup.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_contracts,node_orchestrator,node_retrieval_agent,node_sensory,node_impact,node_recipe_agent,node_user toneBlue
class node_search,node_embeddings,node_search_contracts,node_generation,node_retrieval toneAmber
class node_dataset,node_dataset_schema,node_publication,node_formulation,node_nutrition,node_optimizer toneMint
class node_interpretation,node_report,node_run_store,node_backup toneRose
```

## Components

### Screening workflow

- [FastAPI service](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/api.py): `services/algamask/api.py`
- [Run contracts](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/schemas.py): `services/algamask/schemas.py`
- [Agent supervisor](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/supervisor.py): `services/algamask/agents/supervisor.py`
- [Evidence agent](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/retrieve.py): `services/algamask/agents/retrieve.py`
- [Sensory profile](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/profile.py): `services/algamask/agents/profile.py`
- [Impact assessment](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/impact_agent.py): `services/algamask/agents/impact_agent.py`
- [Recipe strategy](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/agents/chemistry.py): `services/algamask/agents/chemistry.py`

### Evidence retrieval

- [Evidence search](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/rag.py): `services/algamask/rag.py`
- [Local embeddings](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/embeddings.py): `services/algamask/embeddings.py`
- [Search contracts](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/search_schemas.py): `services/algamask/search_schemas.py`
- [Grounded explanations](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/generation.py): `services/algamask/generation.py`
- [Mock retrieval](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/retrieval.py): `services/algamask/retrieval.py`

### Dataset and screening

- [Dataset validation](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/dataset.py): `services/algamask/dataset.py`
- [Dataset schema](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/dataset_schema.py): `services/algamask/dataset_schema.py`
- [Dataset publication](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/publication.py): `services/algamask/publication.py`
- [Formulation screening](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/formulation_engine.py): `services/algamask/formulation_engine.py`
- [Nutrition estimates](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/nutrition.py): `services/algamask/nutrition.py`
- [Recipe candidates](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/optimizer.py): `services/algamask/optimizer.py`

### Results and history

- [Report interpretation](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/report_interpretation.py): `services/algamask/report_interpretation.py`
- [Run report](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/report.py): `services/algamask/report.py`
- [Saved run history](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/run_store.py): `services/algamask/run_store.py`
- [Database recovery](https://github.com/jawadul-codes/algamask/blob/main/services/algamask/backup.py): `services/algamask/backup.py`

### Other components

- **App user**

## Connections

- App user → FastAPI service: submits run (evidence: `README.md`)
- FastAPI service → Agent supervisor: runs workflow (evidence: `README.md`)
- FastAPI service → Saved run history: saves history (evidence: `README.md`)
- FastAPI service → Run report: serves reports (evidence: `README.md`)
- Agent supervisor → Sensory profile: builds profile (evidence: `services/algamask/agents/supervisor.py`)
- Agent supervisor → Evidence agent: requests evidence (evidence: `services/algamask/agents/supervisor.py`)
- Agent supervisor → Recipe strategy: selects strategy (evidence: `services/algamask/agents/supervisor.py`)
- Agent supervisor → Impact assessment: assesses impact (evidence: `services/algamask/agents/supervisor.py`)
- Agent supervisor → Formulation screening: checks candidates (evidence: `services/algamask/agents/supervisor.py`)
- Agent supervisor → Recipe candidates: builds candidates (evidence: `services/algamask/agents/supervisor.py`)
- Evidence agent → Evidence search: queries evidence (evidence: `services/algamask/agents/retrieve.py`)
- Evidence agent → Mock retrieval: loads mock cards (evidence: `services/algamask/agents/retrieve.py`)
- Evidence search → Local embeddings: embeds queries (evidence: `services/algamask/rag.py`)
- Evidence search → Dataset validation: verifies snapshot (evidence: `services/algamask/rag.py`)
- Evidence search → Dataset publication: checks release (evidence: `services/algamask/rag.py`)
- Evidence search → Search contracts: returns search results (evidence: `services/algamask/rag.py`)
- Recipe strategy → Grounded explanations: explains evidence (evidence: `services/algamask/agents/chemistry.py`)
- Formulation screening → Nutrition estimates: estimates nutrients (evidence: `services/algamask/formulation_engine.py`)
- Formulation screening → Run contracts: creates formulas (evidence: `services/algamask/formulation_engine.py`)
- Nutrition estimates → Dataset validation: reads nutrition data (evidence: `services/algamask/nutrition.py`)
- Dataset publication → Dataset validation: validates snapshot (evidence: `services/algamask/publication.py`)
- Dataset validation → Dataset schema: validates records (evidence: `services/algamask/dataset.py`)
- Agent supervisor → Report interpretation: interprets results (evidence: `services/algamask/agents/supervisor.py`)
- Run report → Saved run history: persists reports
- Database recovery → Saved run history: backs up database (evidence: `services/algamask/backup.py`)
