# ruthi-l/seqlab architecture

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

- Interactive diagram: https://gitdiagram.com/ruthi-l/seqlab
- Repository: https://github.com/ruthi-l/seqlab

## Overview

SeqLab is a FastAPI DNA-sequence analysis API. A client submits a sequence to an analysis route; the shared request flow rate-limits first, validates input, checks Redis for a cached result, computes a miss with Biopython, and caches it before returning timing and cache status. The graph separates the shared flow, Redis-backed state, and the four documented analysis operations. All runtime logic is in main.py; relationships are based on its excerpt and the README, not on unsampled files.

Main entry points: [`main.py`](https://github.com/ruthi-l/seqlab/blob/main/main.py) (Shared request flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API request flow"]
  node_routes["Analysis routes<br/>[main.py]"]
  node_request_flow["Shared request flow<br/>[main.py]"]
  node_validation["Sequence validation<br/>[main.py]"]
end

subgraph group_state["Rate limiting and cache"]
  node_limiter["Token-bucket limiter<br/>[main.py]"]
  node_result_cache["Result cache<br/>[main.py]"]
  node_redis[("Redis")]
end

subgraph group_analysis["Sequence analysis"]
  node_gc["GC analysis<br/>[main.py]"]
  node_reverse["Reverse complement<br/>[main.py]"]
  node_translation["Translation<br/>[main.py]"]
  node_orfs["ORF finder<br/>[main.py]"]
end

node_client(("API client"))

node_client -->|"submits sequence"| node_routes
node_routes -->|"calls"| node_request_flow
node_request_flow -->|"enforces first"| node_limiter
node_request_flow -->|"validates"| node_validation
node_request_flow -->|"checks and stores"| node_result_cache
node_request_flow -->|"computes via callback"| node_gc
node_request_flow -->|"computes via callback"| node_reverse
node_request_flow -->|"computes via callback"| node_translation
node_request_flow -->|"computes via callback"| node_orfs
node_limiter -->|"reads and writes buckets"| node_redis
node_result_cache -->|"gets and sets results"| node_redis

click node_routes "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_request_flow "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_validation "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_limiter "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_result_cache "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_gc "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_reverse "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_translation "https://github.com/ruthi-l/seqlab/blob/main/main.py"
click node_orfs "https://github.com/ruthi-l/seqlab/blob/main/main.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_routes,node_request_flow,node_validation,node_client toneBlue
class node_limiter,node_result_cache,node_redis toneAmber
class node_gc,node_reverse,node_translation,node_orfs toneMint
```

## Components

### API request flow

- [Analysis routes](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- [Shared request flow](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- [Sequence validation](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`

### Rate limiting and cache

- [Token-bucket limiter](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- [Result cache](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- **Redis**

### Sequence analysis

- [GC analysis](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- [Reverse complement](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- [Translation](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`
- [ORF finder](https://github.com/ruthi-l/seqlab/blob/main/main.py): `main.py`

### Other components

- **API client**

## Connections

- API client → Analysis routes: submits sequence (evidence: `README.md`)
- Analysis routes → Shared request flow: calls (evidence: `main.py`)
- Shared request flow → Token-bucket limiter: enforces first (evidence: `main.py`)
- Shared request flow → Sequence validation: validates (evidence: `main.py`)
- Shared request flow → Result cache: checks and stores (evidence: `main.py`)
- Shared request flow → GC analysis: computes via callback (evidence: `main.py`)
- Shared request flow → Reverse complement: computes via callback (evidence: `main.py`)
- Shared request flow → Translation: computes via callback (evidence: `main.py`)
- Shared request flow → ORF finder: computes via callback (evidence: `main.py`)
- Token-bucket limiter → Redis: reads and writes buckets (evidence: `main.py`)
- Result cache → Redis: gets and sets results (evidence: `main.py`)
