# nukehub-dev/nukelab architecture

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

- Interactive diagram: https://gitdiagram.com/nukehub-dev/nukelab
- Repository: https://github.com/nukehub-dev/nukelab

## Overview

NukeLab is a multi-user scientific-computing platform: users navigate the React application, authenticate and manage servers through the FastAPI API, and receive containerized environments subject to permissions, plans, quotas, and credit billing. Background workers support lifecycle operations, scheduling, metrics, and crash recovery; PostgreSQL and Redis provide persistent and operational state. The README documents these major capabilities and integrations. Source excerpts are partial, so detailed service-to-service links are omitted where their call paths were not shown.

Main entry points: [`backend/app/worker.py`](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/worker.py) (Background workers), [`frontend/src/main.tsx`](https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/main.tsx) (React application), [`backend/app/main.py`](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/api/servers.py`](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/api/servers.py) (Server API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_spa["React application<br/>[main.tsx]"]
  node_server_views["Server workflows<br/>[servers.index.tsx]"]
  node_admin_views["Admin workflows<br/>[admin.index.tsx]"]
end

subgraph group_api["API and governance"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_server_api["Server API<br/>[servers.py]"]
  node_permissions["Access control<br/>[permissions.py]"]
  node_credit_service["Credit billing<br/>[credit_service.py]"]
end

subgraph group_compute["Compute operations"]
  node_server_lifecycle["Server lifecycle"]
  node_launch["Server launch"]
  node_environment["Environment registry"]
  node_container_driver["Container driver<br/>[factory.py]"]
  node_worker["Background workers<br/>[worker.py]"]
  node_recovery["Crash recovery"]
end

subgraph group_platform["Platform state"]
  node_metrics["Monitoring"]
  node_postgres[("PostgreSQL<br/>[session.py]")]
  node_redis[("Redis<br/>[redis_client.py]")]
  node_container_engine["Docker or Podman"]
  node_observability["Observability stack"]
end

node_user(("Platform user"))

node_user -->|"uses"| node_spa
node_spa -->|"routes to"| node_server_views
node_spa -->|"routes to"| node_admin_views
node_spa -->|"sends requests"| node_api_app
node_api_app -->|"registers"| node_auth
node_api_app -->|"registers"| node_server_api
node_auth -->|"queries users"| node_postgres
node_server_api -.->|"dispatches"| node_server_lifecycle
node_server_api -.->|"checks access"| node_permissions
node_server_lifecycle -.->|"manages launches"| node_launch
node_launch -.->|"resolves environment"| node_environment
node_launch -.->|"starts containers"| node_container_driver
node_worker -->|"uses"| node_postgres
node_worker -->|"uses"| node_redis
node_worker -->|"orchestrates"| node_container_driver
node_worker -->|"runs recovery"| node_recovery
node_worker -->|"collects metrics"| node_metrics
node_api_app -->|"uses"| node_postgres
node_container_driver -->|"controls"| node_container_engine
node_metrics -.->|"exports metrics"| node_observability

click node_spa "https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/main.tsx"
click node_server_views "https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/routes/servers.index.tsx"
click node_admin_views "https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/routes/admin.index.tsx"
click node_api_app "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/main.py"
click node_auth "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/api/auth.py"
click node_server_api "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/api/servers.py"
click node_permissions "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/core/permissions.py"
click node_credit_service "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/credit_service.py"
click node_server_lifecycle "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/server_lifecycle_service.py"
click node_launch "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/server_launch_service.py"
click node_environment "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/environment_service.py"
click node_container_driver "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/container/factory.py"
click node_worker "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/worker.py"
click node_recovery "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/operation_reconciler.py"
click node_metrics "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/metrics_collector.py"
click node_postgres "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/db/session.py"
click node_redis "https://github.com/nukehub-dev/nukelab/blob/main/backend/app/core/redis_client.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_spa,node_server_views,node_admin_views,node_user toneBlue
class node_api_app,node_auth,node_server_api,node_permissions,node_credit_service toneAmber
class node_server_lifecycle,node_launch,node_environment,node_container_driver,node_worker,node_recovery toneMint
class node_metrics,node_postgres,node_redis,node_container_engine,node_observability toneRose
```

## Components

### User experience

- [React application](https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Server workflows](https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/routes/servers.index.tsx): `frontend/src/routes/servers.index.tsx`
- [Admin workflows](https://github.com/nukehub-dev/nukelab/blob/main/frontend/src/routes/admin.index.tsx): `frontend/src/routes/admin.index.tsx`

### API and governance

- [FastAPI application](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Server API](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/api/servers.py): `backend/app/api/servers.py`
- [Access control](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/core/permissions.py): `backend/app/core/permissions.py`
- [Credit billing](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/credit_service.py): `backend/app/services/credit_service.py`

### Compute operations

- [Server lifecycle](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/server_lifecycle_service.py): `backend/app/services/server_lifecycle_service.py`
- [Server launch](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/server_launch_service.py): `backend/app/services/server_launch_service.py`
- [Environment registry](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/environment_service.py): `backend/app/services/environment_service.py`
- [Container driver](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/container/factory.py): `backend/app/container/factory.py`
- [Background workers](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/worker.py): `backend/app/worker.py`
- [Crash recovery](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/operation_reconciler.py): `backend/app/services/operation_reconciler.py`

### Platform state

- [Monitoring](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/services/metrics_collector.py): `backend/app/services/metrics_collector.py`
- [PostgreSQL](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Redis](https://github.com/nukehub-dev/nukelab/blob/main/backend/app/core/redis_client.py): `backend/app/core/redis_client.py`
- **Docker or Podman**
- **Observability stack**

### Other components

- **Platform user**

## Connections

- Platform user → React application: uses (evidence: `README.md`)
- React application → Server workflows: routes to (evidence: `frontend/src/main.tsx`)
- React application → Admin workflows: routes to (evidence: `frontend/src/main.tsx`)
- React application → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Authentication: registers (evidence: `backend/app/main.py`)
- FastAPI application → Server API: registers (evidence: `backend/app/main.py`)
- Authentication → PostgreSQL: queries users (evidence: `backend/app/api/auth.py`)
- Server API → Server lifecycle: dispatches
- Server API → Access control: checks access
- Server lifecycle → Server launch: manages launches
- Server launch → Environment registry: resolves environment
- Server launch → Container driver: starts containers
- Background workers → PostgreSQL: uses (evidence: `README.md`)
- Background workers → Redis: uses (evidence: `README.md`)
- Background workers → Container driver: orchestrates (evidence: `README.md`)
- Background workers → Crash recovery: runs recovery (evidence: `backend/app/tasks.py`)
- Background workers → Monitoring: collects metrics (evidence: `backend/app/tasks.py`)
- FastAPI application → PostgreSQL: uses (evidence: `README.md`)
- Container driver → Docker or Podman: controls (evidence: `README.md`)
- Monitoring → Observability stack: exports metrics
