System view
Architecture
Components
| Component | Responsibility |
|---|---|
| Browser | Uploads a PDF. Reads status. Shows JSON. |
| FastAPI | Validates requests. Starts external jobs. Provides the public API. |
| SQLite | Stores local job state and final JSON. |
| LlamaCloud | Uploads the file and runs extraction. |
Upload flow
- The browser sends a PDF to
POST /api/v1/documents. - FastAPI validates the file.
- FastAPI creates a local job with status
PENDING. - FastAPI uploads the file to LlamaCloud.
- FastAPI creates an extraction job in LlamaCloud.
- FastAPI stores the two external IDs.
- FastAPI sets the local status to
PROCESSING. - FastAPI returns
202 Acceptedand the local job ID.
Status flow
- The browser reads
GET /api/v1/jobs/{job_id}. - FastAPI reads the local job.
- FastAPI checks LlamaCloud only when the job is not final.
- FastAPI saves the result when LlamaCloud reports completion.
- FastAPI returns the local status.
The browser polls every 2.5 seconds. It stops when the job is complete, failed, or cancelled.
Why no worker exists
LlamaCloud already runs the long extraction task. FastAPI only submits the job and reads its state. A Celery worker would add operations work without improving this first version.