Onboarding overview · for new developers · 2026-11-19

examples/image-annotation-toolHow it works.

People draw labelled bounding boxes on images, and every task is reviewed before it is exported. This deck walks through the parts, the task lifecycle and where each lives in the code.

admin annotator reviewer
own codeweb/ · api/ · worker/ · db/migrations/ runs withdocker compose (docker-compose.yml) this deckcommunications/project-deck/index.html
Deck map

Four chapters, details below each one

1 · What it isImages in, reviewed boxes outThree roles
2 · ArchitectureZoom levelsNotationL1 ContextL2 ContainersL3 Inside the apiThe transition table
3 · How it worksOne image, start to endStates and dataWho may do whatClaiming a taskWhere image bytes travelUpload and thumbnailsExport
4 · ReferenceFolder mapCommands

Pressing only → gives the short version: the first slide of each chapter stands on its own. The last slide says what the deck was checked against.

1 · What it is

Images go in, reviewed bounding boxes come out

An admin uploads a batch of images. Each image becomes exactly one task, which is annotated, reviewed and, once approved, exported as COCO-style JSON.

  • task the unit of work: one per image, carries the status
  • annotation one labelled box, in pixels of the original image
  • review one approve or reject decision, kept as history
  • export one run that writes all approved boxes to a file

The work happens in two places:

While you wait · api

A FastAPI service handles login, uploads, the task lifecycle, boxes and reviews.

In the background · worker

An RQ worker makes a thumbnail per image and builds the COCO export file.

api/app/ the serviceworker/jobs/ the background jobsweb/src/ the pages

↓ the three roles

1 · What it is

Three roles, one page each

admin

Does
Uploads batches of JPEG or PNG images; requests exports and downloads the file.
Page
/admin · AdminUploadPage
API
/api/images, /api/exports

annotator

Does
Claims a task, draws and labels boxes, submits; fixes rejected tasks.
Page
/annotate · AnnotatePage
API
/api/tasks/…

reviewer

Does
Works through the review queue; approves, or rejects with a comment.
Page
/review · ReviewQueuePage
API
/api/reviews/queue, /api/tasks/{id}/reviews
web/src/App.tsx HOME, routes per roleapi/app/auth.py require_role
2 · Architecture

The architecture at three zoom levels

Each level zooms into one box of the level before it. The next slides go through them in this order.

→ steps: one level at a time

adminannotatorreviewerannotation toolLEVEL 1Contextwho uses itwebworkerpostgresredisminioapiLEVEL 2Containerswhat docker compose startsroutesstate machineauthstorage · queueLEVEL 3Componentsmodules inside the api

Context: the tool as one box, with the three roles that use it.

Containers: what docker compose up starts: three own services and three stores.

Components: the modules inside the api, where the rules live.

↓ how to read the diagrams

2 · Architecture

How to read the diagrams in this deck

Every box showsits type, such as PERSON or CONTAINERa name, as it is spelled in the codea short description of its job
Every arrow showsa direction: who starts the callwhat it does, such as enqueue or SQLdashed = a reply, or done in the background
Coloursteal = done by the adminorange = done by the annotatorgreen = done by the reviewer
PERSONPersonSOFTWARE SYSTEMSystem in scopeCONTAINERContainerDATA STOREData storeCOMPONENTModule in a containerRUNS ONCEOne-shot jobadminuploads · exportsannotatorclaims · draws · submitsreviewerapproves · rejectsROLE COLOURSLINEScall / dependencyreply, or done in the backgrounddone by that role
LEVELL1 ContextL2 ContainersL3 Components

Three roles use the tool; nothing outside it is involved

PERSONAdminuploads image batchesdownloads the COCO exportPERSONAnnotatorclaims tasksdraws and labels boxesPERSONReviewerworks the review queueapproves or rejectsSOFTWARE SYSTEMImage Annotation Toolone task per image · review before exportimages in → COCO JSON outimagesexport requestsboxessubmissionsdecisionscomments

↓ zoom into the tool

LEVELL1 ContextL2 ContainersL3 Components

api and worker never call each other; they share three stores

IMAGE ANNOTATION TOOL · DOCKER COMPOSEPERSONBrowserall threerolesCONTAINERwebnginx + React SPAport 3000CONTAINERapiFastAPI · port 8000rules, uploads, signed URLsDATA STOREminioimages · thumbnails · exportsDATA STOREpostgres6 tables · system of recordDATA STOREredisqueues thumbnails, exportsCONTAINERworkerRQ · thumbnail and COCO export jobsminio-initcreates 3 buckets, exitsHTTPproxies /api/read / writeput originalsenqueueSQLget / puttake jobsmc mbGET bysigned URL
docker-compose.yml all seven servicesweb/nginx.conf proxies /api/ to api:8000.env.example every address
LEVELL1 ContextL2 ContainersL3 Components

Inside the api: six routers, one state machine, three adapters

API CONTAINER · api/app/auth.pylogin · JWTrequire_roleroutes/tasks.pyclaim · submitreopenroutes/annotations.pyreplace all boxesroutes/reviews.pyqueue · decideroutes/images.pybatch uploadroutes/export.pyrequest · pollstate_machine.pyTRANSITIONSpure logicmodels.py · db.py6 ORM classessession per requeststorage.pyput originalssign URLsqueue.pyenqueue bydotted pathDATA STOREpostgresDATA STOREminioDATA STOREredisapply_actionapply_actionchecks statusUserupload_imageenqueueenqueueSQLS3 APIRQ
api/app/main.py registers the routersapi/app/routes/ one file per resourceapi/app/state_machine.py
2 · Architecture

One table decides every status change

A move that is not in the table becomes HTTP 409; the wrong role becomes 403. The module imports no framework and no database, so it is tested alone.

api/app/state_machine.py TRANSITIONS, next_statusapi/app/routes/tasks.py apply_action maps the errors
3 · How it works

One image, from upload to export

uploadPOST /api/imagesclaimPOST /tasks/nextdraw boxesPUT …/annotationssubmit→ submittedreviewapprove or rejectexportPOST /api/exportsthumbnail jobworkerCOCO export jobworkerenqueueenqueuerejected with a comment → reopen
  • upload: stores the original in MinIO and creates one pending task
  • claim: the oldest pending task goes to the annotator who asks
  • draw + submit: boxes are saved as a whole set; at least one is needed
  • review: approve ends the task; reject needs a comment
  • export: all approved tasks, written as one COCO JSON file
  • background jobs: queued in Redis, run by the worker
api/app/routes/ images.py · tasks.py · annotations.py · reviews.py · export.pyworker/jobs/

↓ states, permissions, then three flows in detail

3 · How it works

The states of a task and the records behind it

pendingin_progresssubmittedrejectedapprovedfinalclaimsubmitapproverejectreopen

Lifecycle: approved is final. Arrow colour shows which role makes the move.

tasksimage_id → images (unique)assignee_id → users?statusimagesbatch_name · filenamestorage_keythumbnail_key?annotationstask_id → taskslabelx, y, width, heightreviewstask_id → tasksreviewer_id → usersdecision · comment1 → *1 → *1 → 1

Four of the six tables; users and exports are left out here.

api/app/state_machine.pydb/migrations/001_init.sql the schemaapi/app/models.py ORM classes
3 · How it works

Who may do what, and what else the API checks

ActionadminannotatorreviewerExtra check in the route
POST /api/images upload a batch●——JPEG or PNG only, else 415
POST /api/tasks/next claim—●—returns your open task first, if you have one
PUT /api/tasks/{id}/annotations save boxes—●—assignee only; task must be in_progress, else 409
POST /api/tasks/{id}/submit—●—assignee only; at least one box, else 422
GET /api/reviews/queue——●submitted tasks, oldest first
POST /api/tasks/{id}/reviews decide——●a comment is required when rejecting, else 422
POST /api/tasks/{id}/reopen—●—assignee only
POST /api/exports · GET /api/exports/{id}●——none
GET tasks, one task, one image, annotations●●●any signed-in user
api/app/auth.py require_roleapi/app/routes/tasks.py require_assignee
3 · How it works

Two annotators asking at once never get the same task

The oldest pending row is locked while it is claimed, and skip_locked makes a second request take the next row instead of waiting.

api/app/routes/tasks.py claim_next_task · POST /api/tasks/next
3 · How it works

Uploads pass through the api; downloads go straight to MinIO

→ steps: upload · the signed URL · the direct download

PERSONBrowserthe React appCONTAINERapistorage.pyDATA STOREminio3 bucketsPOST /api/imagesput_objectJSON with signed URLsGET signed URL · image, thumbnail or export file
  • Upload: the api reads each file and puts it in bucket images
  • Signing: every task and export response carries URLs valid for one hour
  • Two endpoints: S3_ENDPOINT inside the network, S3_PUBLIC_ENDPOINT for the browser
  • Download: images, thumbnails and the export file never pass through the api
api/app/storage.py upload_image, presigned_url.env.example S3_ENDPOINT, S3_PUBLIC_ENDPOINT
Flow 1 · upload a batch

The api answers at once; thumbnails are made afterwards

→ steps through each message

LATERIN THE WORKERBrowseradminapiroutes/images.pyminioobject storagepostgresimages · tasksredisqueue thumbnailsworkerjobs/thumbnail.pyPOST /api/imagesbatch_name + files1admin only · JPEG or PNG only2put original3insert image + pending task4enqueue generate_thumbnail(image_id)5201 · image_ids6take job7select storage_key8get original9Pillow: fit into 320 x 320, JPEG10put thumbnail11update thumbnail_key, width, height12
api/app/routes/images.py upload_batchapi/app/queue.py enqueue_thumbnailworker/jobs/thumbnail.py generate_thumbnail
Flow 2 · export approved annotations

Request an export, poll for it, download the file

→ steps through each message

LATERIN THE WORKERBrowseradminapiroutes/export.pypostgresexports · tasksredisqueue exportsworkerjobs/export_coco.pyminiobucket exportsPOST /api/exports1insert export · queued2enqueue export_approved(export_id)3202 · status queued4take job5set status running6select boxes of approved tasks7build_coco(rows)8put export-<id>.coco.json9set done · storage_key · task_count10the page polls every 2 s until done or failedGET /api/exports/{id}11200 · download_url12GET the file by signed URL13
api/app/routes/export.pyworker/jobs/export_coco.py export_approvedweb/src/pages/AdminUploadPage.tsx polling
4 · Reference

Folder map for finding your way around

image-annotation-tool/
├─ README.md                  ← start here
├─ docker-compose.yml         ← the running parts (L2)
├─ .env.example               ← every address and secret
├─ db/migrations/001_init.sql ← the schema
├─ api/app/
│  ├─ main.py                 ← entry point, routers
│  ├─ routes/                 ← one file per resource
│  ├─ state_machine.py        ← task lifecycle
│  ├─ auth.py                 ← login, JWT, roles
│  └─ storage.py · queue.py   ← MinIO and Redis clients
├─ api/tests/                 ← state machine tests
├─ worker/
│  ├─ main.py                 ← RQ worker, two queues
│  └─ jobs/                   ← thumbnail, COCO export
└─ web/src/
   ├─ pages/                  ← one page per role
   ├─ components/             ← BoundingBoxCanvas
   └─ api/client.ts           ← every API call

Where to look first

  • To run it: README.md, section "Starting it"
  • To change a rule of the lifecycle: api/app/state_machine.py and its tests
  • To add an endpoint: a module in api/app/routes/, registered in main.py
  • To add a background job: a function in worker/jobs/ and an enqueue helper in api/app/queue.py
  • To change a table: db/migrations/ and api/app/models.py together

↓ commands

4 · Reference

Commands, as the README gives them

The README describes this as a theoretical example that has never been executed, so treat the commands as intended, not as tried.

README.md Starting it · Tests
End of the overview · questions welcome

examples/image-annotation-tool

A longer written version, with a file reference for every statement, is in the project brief.

project briefcommunications/project-brief.md deck built2026-11-19 21:35 UTC+0100 checked againstthe working tree on 2026-11-19 (not a git repository; nothing was run) sourcescommunications/project-deck/src/ (rebuild to refresh the timestamp)