# iain-crowe/atlas-api architecture

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

- Interactive diagram: https://gitdiagram.com/iain-crowe/atlas-api
- Repository: https://github.com/iain-crowe/atlas-api

## Overview

Atlas is a FastAPI service-management API: clients authenticate, then manage registered services and request runtime actions or status. The API also exposes host telemetry and Minecraft status through a Unix-socket agent, while SQLite stores users and managed-service records. Authentication and role checks protect the API; Pydantic models define request and response shapes. The excerpts show the API-to-agent boundary and database helpers, but the README is empty and the agent implementation is external or not present in the tree, so its internals are not mapped.

Main entry points: [`app/main.py`](https://github.com/iain-crowe/atlas-api/blob/main/app/main.py) (HTTP API), [`app/security.py`](https://github.com/iain-crowe/atlas-api/blob/main/app/security.py) (Auth and roles), [`app/services/database.py`](https://github.com/iain-crowe/atlas-api/blob/main/app/services/database.py) (Service records), [`app/bootstrap_admin.py`](https://github.com/iain-crowe/atlas-api/blob/main/app/bootstrap_admin.py) (Admin bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and contracts"]
  node_fastapi["HTTP API<br/>[main.py]"]
  node_schemas["Request responses<br/>[models.py]"]
end

subgraph group_identity["Identity and access"]
  node_security["Auth and roles<br/>[security.py]"]
  node_users["User records<br/>[db_models.py]"]
  node_admin_setup["Admin bootstrap<br/>[bootstrap_admin.py]"]
end

subgraph group_registry["Service registry"]
  node_service_ops["Service records<br/>[database.py]"]
  node_service_records["Managed services<br/>[db_models.py]"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_runtime["Runtime monitoring"]
  node_agent_client["Agent socket client<br/>[agent.py]"]
  node_system_helpers["Host telemetry helpers<br/>[system.py]"]
end

node_client(("API client"))
node_agent["Atlas agent"]

node_client -->|"calls endpoints"| node_fastapi
node_fastapi -->|"uses contracts"| node_schemas
node_fastapi -->|"checks access"| node_security
node_fastapi -->|"queries and creates"| node_service_ops
node_fastapi -->|"loads records"| node_service_records
node_fastapi -->|"requests status and actions"| node_agent_client
node_security -->|"loads user model"| node_users
node_security -->|"looks up username"| node_service_ops
node_admin_setup -->|"creates admin"| node_users
node_admin_setup -->|"hashes password"| node_security
node_service_ops -->|"queries and writes"| node_service_records
node_db_session -->|"opens sessions"| node_sqlite
node_service_ops -->|"uses session"| node_db_session
node_agent_client -->|"sends socket requests"| node_agent
node_fastapi -.->|"telemetry link unclear"| node_system_helpers

click node_fastapi "https://github.com/iain-crowe/atlas-api/blob/main/app/main.py"
click node_schemas "https://github.com/iain-crowe/atlas-api/blob/main/app/models.py"
click node_security "https://github.com/iain-crowe/atlas-api/blob/main/app/security.py"
click node_users "https://github.com/iain-crowe/atlas-api/blob/main/app/db_models.py"
click node_admin_setup "https://github.com/iain-crowe/atlas-api/blob/main/app/bootstrap_admin.py"
click node_service_ops "https://github.com/iain-crowe/atlas-api/blob/main/app/services/database.py"
click node_service_records "https://github.com/iain-crowe/atlas-api/blob/main/app/db_models.py"
click node_db_session "https://github.com/iain-crowe/atlas-api/blob/main/app/database.py"
click node_agent_client "https://github.com/iain-crowe/atlas-api/blob/main/app/services/runtime/agent.py"
click node_system_helpers "https://github.com/iain-crowe/atlas-api/blob/main/app/services/system.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_fastapi,node_schemas,node_client toneBlue
class node_security,node_users,node_admin_setup toneAmber
class node_service_ops,node_service_records,node_db_session,node_sqlite toneMint
class node_agent_client,node_system_helpers toneRose
class node_agent toneIndigo
```

## Components

### API and contracts

- [HTTP API](https://github.com/iain-crowe/atlas-api/blob/main/app/main.py): `app/main.py`
- [Request responses](https://github.com/iain-crowe/atlas-api/blob/main/app/models.py): `app/models.py`

### Identity and access

- [Auth and roles](https://github.com/iain-crowe/atlas-api/blob/main/app/security.py): `app/security.py`
- [User records](https://github.com/iain-crowe/atlas-api/blob/main/app/db_models.py): `app/db_models.py`
- [Admin bootstrap](https://github.com/iain-crowe/atlas-api/blob/main/app/bootstrap_admin.py): `app/bootstrap_admin.py`

### Service registry

- [Service records](https://github.com/iain-crowe/atlas-api/blob/main/app/services/database.py): `app/services/database.py`
- [Managed services](https://github.com/iain-crowe/atlas-api/blob/main/app/db_models.py): `app/db_models.py`
- [Database sessions](https://github.com/iain-crowe/atlas-api/blob/main/app/database.py): `app/database.py`
- **SQLite database**

### Runtime monitoring

- [Agent socket client](https://github.com/iain-crowe/atlas-api/blob/main/app/services/runtime/agent.py): `app/services/runtime/agent.py`
- [Host telemetry helpers](https://github.com/iain-crowe/atlas-api/blob/main/app/services/system.py): `app/services/system.py`

### Other components

- **API client**
- **Atlas agent**

## Connections

- API client → HTTP API: calls endpoints (evidence: `app/main.py`)
- HTTP API → Request responses: uses contracts (evidence: `app/main.py`)
- HTTP API → Auth and roles: checks access (evidence: `app/main.py`)
- HTTP API → Service records: queries and creates (evidence: `app/main.py`)
- HTTP API → Managed services: loads records (evidence: `app/main.py`)
- HTTP API → Agent socket client: requests status and actions (evidence: `app/main.py`)
- Auth and roles → User records: loads user model (evidence: `app/security.py`)
- Auth and roles → Service records: looks up username (evidence: `app/security.py`)
- Admin bootstrap → User records: creates admin (evidence: `app/bootstrap_admin.py`)
- Admin bootstrap → Auth and roles: hashes password (evidence: `app/bootstrap_admin.py`)
- Service records → Managed services: queries and writes (evidence: `app/services/database.py`)
- Database sessions → SQLite database: opens sessions (evidence: `app/database.py`)
- Service records → Database sessions: uses session (evidence: `app/services/database.py`)
- Agent socket client → Atlas agent: sends socket requests (evidence: `app/services/runtime/agent.py`)
- HTTP API → Host telemetry helpers: telemetry link unclear
