# tatsu1207/amr architecture

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

- Interactive diagram: https://gitdiagram.com/tatsu1207/amr
- Repository: https://github.com/tatsu1207/amr

## Overview

AMR Predictor is a web service for estimating antimicrobial resistance phenotypes from bacterial genome assemblies. A user uploads a FASTA through the browser; the API creates a job, identifies the organism and sequence type, runs streamlined genome annotation, builds model features, and returns per-antibiotic predictions with detected genes and mutations. The repository also documents a broader 18-step annotation workflow and offline feature-matrix and model-training capabilities. The graph follows the sampled web path; some broader capabilities are documented in the README but their implementation links were not sampled.

Main entry points: [`app/pipeline/runner.py`](https://github.com/tatsu1207/amr/blob/main/app/pipeline/runner.py) (Pipeline orchestrator), [`app/main.py`](https://github.com/tatsu1207/amr/blob/main/app/main.py) (HTTP API), [`app/static/js/app.js`](https://github.com/tatsu1207/amr/blob/main/app/static/js/app.js) (Upload and results UI), [`app/pipeline/predict.py`](https://github.com/tatsu1207/amr/blob/main/app/pipeline/predict.py) (Phenotype prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_browser["Upload and results UI<br/>[app.js]"]
end

subgraph group_service["API and jobs"]
  node_api["HTTP API<br/>[main.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_jobstore[("Job state store<br/>[job_store.py]")]
  node_schemas["Job and result schemas<br/>[schemas.py]"]
end

subgraph group_analysis["Genome analysis"]
  node_runner["Pipeline orchestrator<br/>[runner.py]"]
  node_species["Species and MLST<br/>[species_id.py]"]
  node_annotate["Annotation routines<br/>[annotate.py]"]
  node_minimal["Streamlined annotation"]
  node_annotation_tools{{"Genome annotation tools"}}
end

subgraph group_prediction["Feature prediction"]
  node_features["Feature extraction<br/>[features.py]"]
  node_predict["Phenotype prediction<br/>[predict.py]"]
  node_models[("Species-drug models")]
  node_results["Prediction results<br/>[schemas.py]"]
  node_offline["Offline training and matrices"]
end

node_user(("Genome analyst"))
node_mlst_tool{{"MLST executable"}}

node_user -->|"uploads genome"| node_browser
node_browser -->|"sends upload"| node_api
node_api -->|"creates and reads"| node_jobstore
node_api -->|"starts job"| node_runner
node_api -->|"checks stage"| node_schemas
node_api -->|"uses limits"| node_config
node_api -.->|"serves status and results"| node_browser
node_browser -->|"polls and fetches"| node_api
node_runner -->|"updates state"| node_jobstore
node_runner -->|"runs identification"| node_mlst_tool
node_runner -.->|"identifies species"| node_species
node_runner -->|"runs annotation"| node_minimal
node_minimal -.->|"runs tools"| node_annotation_tools
node_annotate -.->|"invokes tools"| node_annotation_tools
node_runner -->|"extracts features"| node_features
node_features -.->|"reads annotation outputs"| node_minimal
node_runner -->|"requests predictions"| node_predict
node_predict -->|"loads model path"| node_config
node_predict -->|"loads model files"| node_models
node_predict -->|"builds results"| node_results
node_browser -.->|"renders predictions"| node_results
node_offline -.->|"trains model set"| node_models
node_offline -.->|"builds feature matrices"| node_features

click node_browser "https://github.com/tatsu1207/amr/blob/main/app/static/js/app.js"
click node_api "https://github.com/tatsu1207/amr/blob/main/app/main.py"
click node_config "https://github.com/tatsu1207/amr/blob/main/app/config.py"
click node_jobstore "https://github.com/tatsu1207/amr/blob/main/app/models/job_store.py"
click node_schemas "https://github.com/tatsu1207/amr/blob/main/app/models/schemas.py"
click node_runner "https://github.com/tatsu1207/amr/blob/main/app/pipeline/runner.py"
click node_species "https://github.com/tatsu1207/amr/blob/main/app/pipeline/species_id.py"
click node_annotate "https://github.com/tatsu1207/amr/blob/main/app/pipeline/annotate.py"
click node_minimal "https://github.com/tatsu1207/amr/blob/main/annotate_minimal.sh"
click node_features "https://github.com/tatsu1207/amr/blob/main/app/pipeline/features.py"
click node_predict "https://github.com/tatsu1207/amr/blob/main/app/pipeline/predict.py"
click node_models "https://github.com/tatsu1207/amr/tree/main/models"
click node_results "https://github.com/tatsu1207/amr/blob/main/app/models/schemas.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_browser toneBlue
class node_api,node_config,node_jobstore,node_schemas toneAmber
class node_runner,node_species,node_annotate,node_minimal,node_annotation_tools toneMint
class node_features,node_predict,node_models,node_results,node_offline toneRose
class node_user,node_mlst_tool toneIndigo
```

## Components

### Web interface

- [Upload and results UI](https://github.com/tatsu1207/amr/blob/main/app/static/js/app.js): `app/static/js/app.js`

### API and jobs

- [HTTP API](https://github.com/tatsu1207/amr/blob/main/app/main.py): `app/main.py`
- [Runtime configuration](https://github.com/tatsu1207/amr/blob/main/app/config.py): `app/config.py`
- [Job state store](https://github.com/tatsu1207/amr/blob/main/app/models/job_store.py): `app/models/job_store.py`
- [Job and result schemas](https://github.com/tatsu1207/amr/blob/main/app/models/schemas.py): `app/models/schemas.py`

### Genome analysis

- [Pipeline orchestrator](https://github.com/tatsu1207/amr/blob/main/app/pipeline/runner.py): `app/pipeline/runner.py`
- [Species and MLST](https://github.com/tatsu1207/amr/blob/main/app/pipeline/species_id.py): `app/pipeline/species_id.py`
- [Annotation routines](https://github.com/tatsu1207/amr/blob/main/app/pipeline/annotate.py): `app/pipeline/annotate.py`
- [Streamlined annotation](https://github.com/tatsu1207/amr/blob/main/annotate_minimal.sh): `annotate_minimal.sh`
- **Genome annotation tools**

### Feature prediction

- [Feature extraction](https://github.com/tatsu1207/amr/blob/main/app/pipeline/features.py): `app/pipeline/features.py`
- [Phenotype prediction](https://github.com/tatsu1207/amr/blob/main/app/pipeline/predict.py): `app/pipeline/predict.py`
- [Species-drug models](https://github.com/tatsu1207/amr/tree/main/models): `models`
- [Prediction results](https://github.com/tatsu1207/amr/blob/main/app/models/schemas.py): `app/models/schemas.py`
- **Offline training and matrices**

### Other components

- **Genome analyst**
- **MLST executable**

## Connections

- Genome analyst → Upload and results UI: uploads genome (evidence: `README.md`)
- Upload and results UI → HTTP API: sends upload (evidence: `app/static/js/app.js`)
- HTTP API → Job state store: creates and reads (evidence: `app/main.py`)
- HTTP API → Pipeline orchestrator: starts job (evidence: `app/main.py`)
- HTTP API → Job and result schemas: checks stage (evidence: `app/main.py`)
- HTTP API → Runtime configuration: uses limits (evidence: `app/main.py`)
- HTTP API → Upload and results UI: serves status and results
- Upload and results UI → HTTP API: polls and fetches (evidence: `app/static/js/app.js`)
- Pipeline orchestrator → Job state store: updates state (evidence: `app/pipeline/runner.py`)
- Pipeline orchestrator → MLST executable: runs identification (evidence: `app/pipeline/runner.py`)
- Pipeline orchestrator → Species and MLST: identifies species
- Pipeline orchestrator → Streamlined annotation: runs annotation (evidence: `app/pipeline/runner.py`)
- Streamlined annotation → Genome annotation tools: runs tools
- Annotation routines → Genome annotation tools: invokes tools
- Pipeline orchestrator → Feature extraction: extracts features (evidence: `app/pipeline/runner.py`)
- Feature extraction → Streamlined annotation: reads annotation outputs
- Pipeline orchestrator → Phenotype prediction: requests predictions (evidence: `app/pipeline/runner.py`)
- Phenotype prediction → Runtime configuration: loads model path (evidence: `app/pipeline/predict.py`)
- Phenotype prediction → Species-drug models: loads model files (evidence: `app/pipeline/predict.py`)
- Phenotype prediction → Prediction results: builds results (evidence: `app/pipeline/predict.py`)
- Upload and results UI → Prediction results: renders predictions
- Offline training and matrices → Species-drug models: trains model set (evidence: `README.md`)
- Offline training and matrices → Feature extraction: builds feature matrices (evidence: `README.md`)
