How pavlinhristov/codexlab works
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: main.py Task routes · service.py Task service · store.py JSON task store · requirements.txt Python dependencies
Components 7
HTTP API
- Uvicorn / FastAPI runtime · Runs the local HTTP API and OpenAPI docs.
app/main.py - Task routes · Lists, creates, retrieves, and completes tasks.
app/main.py - Task API schemas · Validates request data and constrains serialized responses.
app/schemas.py
Task Domain
- Task service · Applies task policy, filtering, and completion mutations.
app/service.py
Local Persistence
- JSON task store · Reads and writes the local task collection.
app/store.py - Task state · Seed data and durable runtime task state.
data/tasks.json
Other components
- Python dependencies · Declares FastAPI and Uvicorn dependencies for Python 3.9+.
requirements.txt
Connections 6
- 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