# pavlinhristov/codexlab architecture

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

- Interactive diagram: https://gitdiagram.com/pavlinhristov/codexlab
- Repository: https://github.com/pavlinhristov/codexlab

## Overview

#### Purpose and Runtime

CodexLab is a compact FastAPI task-manager backend used as a Codex-driven engineering lab. It serves a local HTTP API for listing, creating, retrieving, and completing tasks. Run it with Uvicorn via `uvicorn app.main:app --reload`; FastAPI exposes interactive OpenAPI docs at `/docs`.

Core runtime paths: `app/main.py`, `requirements.txt`.

#### HTTP Entry Point

`app/main.py` owns the FastAPI application and endpoint wiring. The main API boundary is HTTP request parsing and response serialization for task operations, including `GET /tasks`, task creation, task lookup, and `POST /tasks/{task_id}/complete`.

Query filters such as task status—and the intended optional text search—enter at the list route and should be passed into the service layer rather than implemented in storage.

Paths: `app/main.py`, `app/schemas.py`.

#### API Contracts

`app/schemas.py` defines the request/response models shared between routes and application logic. These models establish the public task shape: task identity and fields such as title, description, status, and completion state/timestamp.

This is the validation/serialization boundary: malformed client input is rejected before business logic, and route outputs are constrained to the API schema.

Paths: `app/schemas.py`, `app/main.py`.

#### Task Service Layer

`app/service.py` contains task-domain operations: list/filter tasks, create tasks, retrieve a task, and mark a task complete. It is the primary policy layer between HTTP handlers and persistence.

The list flow should compose optional filters (status and text query) over tasks obtained from the store. Completion must update task status and completion metadata, then invoke persistence so a subsequent request observes the change.

Paths: `app/service.py`, `app/main.py`, `app/store.py`.

#### JSON Persistence Boundary

`app/store.py` abstracts reads and writes of the local task collection. Persistence is file-based rather than database-backed; writes mutate repository working-tree data and are therefore a runtime side effect to review before commits.

`data/tasks.json` is both seed/sample data and the durable state source for API operations. There are no external databases, queues, authentication providers, or remote application services indicated.

Paths: `app/store.py`, `data/tasks.json`.

#### Primary Flows

For reads, a request follows `app/main.py` → schema/query handling → `app/service.py` filtering or lookup → `app/store.py` JSON read → schema-backed HTTP response.

For writes, create/complete requests follow `app/main.py` → `app/service.py` domain mutation → `app/store.py` JSON write → response. Persistence correctness depends on the service explicitly writing the modified collection; in-memory mutation alone is insufficient.

Paths: `app/main.py`, `app/service.py`, `app/store.py`.

#### Operational Constraints

The application requires Python 3.9+ and dependencies declared in `requirements.txt`; it runs locally on Uvicorn/FastAPI, normally at `127.0.0.1:8000`. Its stateful JSON-file design is suitable for the lab but implies no concurrency control, transaction handling, or multi-instance coordination.

Paths: `requirements.txt`, `data/tasks.json`, `app/main.py`.

Main entry points: [`app/main.py`](https://github.com/pavlinhristov/codexlab/blob/main/app/main.py) (Task routes), [`app/service.py`](https://github.com/pavlinhristov/codexlab/blob/main/app/service.py) (Task service), [`app/store.py`](https://github.com/pavlinhristov/codexlab/blob/main/app/store.py) (JSON task store), [`requirements.txt`](https://github.com/pavlinhristov/codexlab/blob/main/requirements.txt) (Python dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_runtime{{"Uvicorn / FastAPI runtime<br/>local server<br/>[main.py]"}}
  node_routes["Task routes<br/>HTTP handlers<br/>[main.py]"]
  node_schemas["Task API schemas<br/>validation contracts<br/>[schemas.py]"]
end

subgraph group_domain["Task Domain"]
  node_service["Task service<br/>domain service<br/>[service.py]"]
end

subgraph group_persistence["Local Persistence"]
  node_store["JSON task store<br/>persistence adapter<br/>[store.py]"]
  node_tasks_json[("Task state<br/>JSON file<br/>[tasks.json]")]
end

node_requirements["Python dependencies<br/>runtime dependencies<br/>[requirements.txt]"]

node_runtime -->|"serves"| node_routes
node_routes -->|"validates / serializes"| node_schemas
node_routes -->|"delegates task operations"| node_service
node_service -->|"reads and persists tasks"| node_store
node_store -->|"JSON read/write"| node_tasks_json
node_requirements -.->|"provides dependencies"| node_runtime

click node_runtime "https://github.com/pavlinhristov/codexlab/blob/main/app/main.py"
click node_routes "https://github.com/pavlinhristov/codexlab/blob/main/app/main.py"
click node_schemas "https://github.com/pavlinhristov/codexlab/blob/main/app/schemas.py"
click node_service "https://github.com/pavlinhristov/codexlab/blob/main/app/service.py"
click node_store "https://github.com/pavlinhristov/codexlab/blob/main/app/store.py"
click node_tasks_json "https://github.com/pavlinhristov/codexlab/blob/main/data/tasks.json"
click node_requirements "https://github.com/pavlinhristov/codexlab/blob/main/requirements.txt"

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_runtime,node_routes,node_schemas toneBlue
class node_service toneAmber
class node_store,node_tasks_json toneMint
class node_requirements toneNeutral
```

## Components

### HTTP API

- [Uvicorn / FastAPI runtime](https://github.com/pavlinhristov/codexlab/blob/main/app/main.py): local server · Runs the local HTTP API and OpenAPI docs. · `app/main.py`
- [Task routes](https://github.com/pavlinhristov/codexlab/blob/main/app/main.py): HTTP handlers · Lists, creates, retrieves, and completes tasks. · `app/main.py`
- [Task API schemas](https://github.com/pavlinhristov/codexlab/blob/main/app/schemas.py): validation contracts · Validates request data and constrains serialized responses. · `app/schemas.py`

### Task Domain

- [Task service](https://github.com/pavlinhristov/codexlab/blob/main/app/service.py): domain service · Applies task policy, filtering, and completion mutations. · `app/service.py`

### Local Persistence

- [JSON task store](https://github.com/pavlinhristov/codexlab/blob/main/app/store.py): persistence adapter · Reads and writes the local task collection. · `app/store.py`
- [Task state](https://github.com/pavlinhristov/codexlab/blob/main/data/tasks.json): JSON file · Seed data and durable runtime task state. · `data/tasks.json`

### Other components

- [Python dependencies](https://github.com/pavlinhristov/codexlab/blob/main/requirements.txt): runtime dependencies · Declares FastAPI and Uvicorn dependencies for Python 3.9+. · `requirements.txt`

## Connections

- Uvicorn / FastAPI runtime → Task routes: serves
- Task routes → Task API schemas: validates / serializes
- Task routes → Task service: delegates task operations
- Task service → JSON task store: reads and persists tasks
- JSON task store → Task state: JSON read/write
- Python dependencies → Uvicorn / FastAPI runtime: provides dependencies
