# genomic-medicine-sweden/mimosa architecture

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

- Interactive diagram: https://gitdiagram.com/genomic-medicine-sweden/mimosa
- Repository: https://github.com/genomic-medicine-sweden/mimosa

## Overview

MIMOSA is a genomic-surveillance and outbreak-investigation application. Its principal workflow ingests allele profiles and sample metadata (from Bonsai or chewBBACA TSVs), processes samples and genetic similarity, then supports case monitoring and visualisation alongside user-managed sample, outbreak, and operational functions. The graph includes backend API domains and frontend product areas named in the tree; their detailed connections are limited where source excerpts were unavailable. Dashed edges indicate documented capabilities or likely integration whose implementation relationship was not shown.

Main entry points: [`scripts/main.py`](https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/main.py) (Pipeline runner), [`frontend/src/components/App.js`](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/App.js) (Web application), [`frontend/src/components/dashboard/DashboardOverview.js`](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/DashboardOverview.js) (Surveillance dashboard), [`backend/src/pipeline/pipeline.controller.ts`](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/pipeline/pipeline.controller.ts) (Pipeline control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion pipeline"]
  node_bonsai["Bonsai source"]
  node_chewbbaca_tsv["chewBBaca TSV"]
  node_pipeline_runner["Pipeline runner<br/>[main.py]"]
  node_sample_processing["Sample processing<br/>[process_samples.py]"]
  node_similarity_processing["Similarity processing"]
  node_upload["Data upload<br/>[upload.py]"]
  node_api_client["Bonsai API client<br/>[api.py]"]
end

subgraph group_api["Backend API"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_allele_profiles["Allele profiles"]
  node_samples["Sample features"]
  node_clustering["Clustering"]
  node_distance["Genetic distance"]
  node_outbreaks["Outbreak detection"]
  node_exclusions["Sample exclusions"]
end

subgraph group_ui["Surveillance interface"]
  node_frontend["Web application<br/>[App.js]"]
  node_map["Map and filtering<br/>[Map.js]"]
  node_dashboard["Surveillance dashboard"]
  node_tree["Cluster trees<br/>[TreePage.js]"]
  node_matrix["Distance matrix<br/>[MatrixPage.js]"]
end

subgraph group_ops["Administration and operations"]
  node_pipeline_control["Pipeline control"]
  node_logs["Pipeline logs<br/>[logs.service.ts]"]
  node_mail["Alert email<br/>[mail.controller.ts]"]
  node_users["User management"]
end

node_operator(("Operator"))
node_database[("Application database")]
node_automation["Automation service"]

node_bonsai -.->|"provides profiles"| node_pipeline_runner
node_chewbbaca_tsv -.->|"imports profiles"| node_pipeline_runner
node_pipeline_runner -->|"uses"| node_api_client
node_pipeline_runner -->|"uses"| node_sample_processing
node_pipeline_runner -->|"uses"| node_similarity_processing
node_pipeline_runner -->|"uses"| node_upload
node_pipeline_runner -.->|"reads and writes"| node_database
node_operator -.->|"uses"| node_frontend
node_frontend -.->|"presents"| node_map
node_frontend -.->|"presents"| node_dashboard
node_frontend -.->|"presents"| node_tree
node_frontend -.->|"presents"| node_matrix
node_dashboard -.->|"monitors"| node_samples
node_dashboard -.->|"monitors"| node_outbreaks
node_dashboard -.->|"views"| node_clustering
node_dashboard -.->|"views"| node_distance
node_pipeline_control -->|"triggers"| node_automation
node_pipeline_control -->|"records trigger"| node_logs
node_operator -.->|"requests run"| node_pipeline_control
node_mail -->|"finds recipients"| node_users
node_mail -.->|"sends alerts"| node_automation
node_operator -.->|"administers accounts"| node_users
node_allele_profiles -.->|"stores profiles"| node_database
node_samples -.->|"manages features"| node_database
node_exclusions -.->|"stores exclusions"| node_database
node_outbreaks -.->|"reads surveillance data"| node_database

click node_pipeline_runner "https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/main.py"
click node_sample_processing "https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/process_samples.py"
click node_similarity_processing "https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/process_similarity.py"
click node_upload "https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/upload.py"
click node_api_client "https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/api.py"
click node_auth "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/auth/auth.service.ts"
click node_allele_profiles "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/chewbbaca/chewbbaca.service.ts"
click node_samples "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/features/features.controller.ts"
click node_clustering "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/clustering/clustering.service.ts"
click node_distance "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/distance/distance.service.ts"
click node_outbreaks "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/outbreaks/outbreaks.service.ts"
click node_exclusions "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/excluded-samples/excluded-samples.service.ts"
click node_frontend "https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/App.js"
click node_map "https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/Map.js"
click node_dashboard "https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/DashboardOverview.js"
click node_tree "https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/TreePage.js"
click node_matrix "https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/MatrixPage.js"
click node_pipeline_control "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/pipeline/pipeline.controller.ts"
click node_logs "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/logs/logs.service.ts"
click node_mail "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/mail/mail.controller.ts"
click node_users "https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/users/users.controller.ts"

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_bonsai,node_chewbbaca_tsv,node_pipeline_runner,node_sample_processing,node_similarity_processing,node_upload,node_api_client toneBlue
class node_auth,node_allele_profiles,node_samples,node_clustering,node_distance,node_outbreaks,node_exclusions,node_database toneAmber
class node_frontend,node_map,node_dashboard,node_tree,node_matrix toneMint
class node_pipeline_control,node_logs,node_mail,node_users toneRose
class node_operator,node_automation toneIndigo
```

## Components

### Ingestion pipeline

- **Bonsai source**
- **chewBBaca TSV**
- [Pipeline runner](https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/main.py): `scripts/main.py`
- [Sample processing](https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/process_samples.py): `scripts/process_samples.py`
- [Similarity processing](https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/process_similarity.py): `scripts/process_similarity.py`
- [Data upload](https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/upload.py): `scripts/upload.py`
- [Bonsai API client](https://github.com/genomic-medicine-sweden/mimosa/blob/main/scripts/api.py): `scripts/api.py`

### Backend API

- [Authentication](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [Allele profiles](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/chewbbaca/chewbbaca.service.ts): `backend/src/chewbbaca/chewbbaca.service.ts`
- [Sample features](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/features/features.controller.ts): `backend/src/features/features.controller.ts`
- [Clustering](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/clustering/clustering.service.ts): `backend/src/clustering/clustering.service.ts`
- [Genetic distance](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/distance/distance.service.ts): `backend/src/distance/distance.service.ts`
- [Outbreak detection](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/outbreaks/outbreaks.service.ts): `backend/src/outbreaks/outbreaks.service.ts`
- [Sample exclusions](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/excluded-samples/excluded-samples.service.ts): `backend/src/excluded-samples/excluded-samples.service.ts`

### Surveillance interface

- [Web application](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/App.js): `frontend/src/components/App.js`
- [Map and filtering](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/Map.js): `frontend/src/components/Map.js`
- [Surveillance dashboard](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/DashboardOverview.js): `frontend/src/components/dashboard/DashboardOverview.js`
- [Cluster trees](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/TreePage.js): `frontend/src/components/dashboard/TreePage.js`
- [Distance matrix](https://github.com/genomic-medicine-sweden/mimosa/blob/main/frontend/src/components/dashboard/MatrixPage.js): `frontend/src/components/dashboard/MatrixPage.js`

### Administration and operations

- [Pipeline control](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/pipeline/pipeline.controller.ts): `backend/src/pipeline/pipeline.controller.ts`
- [Pipeline logs](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/logs/logs.service.ts): `backend/src/logs/logs.service.ts`
- [Alert email](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/mail/mail.controller.ts): `backend/src/mail/mail.controller.ts`
- [User management](https://github.com/genomic-medicine-sweden/mimosa/blob/main/backend/src/users/users.controller.ts): `backend/src/users/users.controller.ts`

### Other components

- **Operator**
- **Application database**
- **Automation service**

## Connections

- Bonsai source → Pipeline runner: provides profiles (evidence: `README.md`)
- chewBBaca TSV → Pipeline runner: imports profiles (evidence: `README.md`)
- Pipeline runner → Bonsai API client: uses (evidence: `scripts/main.py`)
- Pipeline runner → Sample processing: uses (evidence: `scripts/main.py`)
- Pipeline runner → Similarity processing: uses (evidence: `scripts/main.py`)
- Pipeline runner → Data upload: uses (evidence: `scripts/main.py`)
- Pipeline runner → Application database: reads and writes
- Operator → Web application: uses (evidence: `README.md`)
- Web application → Map and filtering: presents
- Web application → Surveillance dashboard: presents
- Web application → Cluster trees: presents
- Web application → Distance matrix: presents
- Surveillance dashboard → Sample features: monitors
- Surveillance dashboard → Outbreak detection: monitors
- Surveillance dashboard → Clustering: views
- Surveillance dashboard → Genetic distance: views
- Pipeline control → Automation service: triggers (evidence: `backend/src/pipeline/pipeline.controller.ts`)
- Pipeline control → Pipeline logs: records trigger (evidence: `backend/src/pipeline/pipeline.controller.ts`)
- Operator → Pipeline control: requests run
- Alert email → User management: finds recipients (evidence: `backend/src/mail/mail.controller.ts`)
- Alert email → Automation service: sends alerts
- Operator → User management: administers accounts
- Allele profiles → Application database: stores profiles
- Sample features → Application database: manages features
- Sample exclusions → Application database: stores exclusions
- Outbreak detection → Application database: reads surveillance data
