From Flask to Workers
What the 2026 rewrite changed and which parts of the 2021 contract it kept.
The 2021 implementation was Python 3, Flask, Peewee and Postgres behind Docker Compose, with pytest and a Postman collection. The 2026 rewrite targets Cloudflare Workers and D1 and drops Docker entirely.
Stack#
| Layer | 2021 | 2026 |
|---|---|---|
| Runtime | Flask dev server in Docker | Cloudflare Workers |
| Routing | Flask blueprints-free routes | Hono |
| Database | Postgres + hstore | D1 (SQLite, nutrition as JSON) |
| Auth | PyJWT + werkzeug password hashes | Web Crypto: HS256 JWTs, PBKDF2 hashing |
| Validation | ad-hoc dictionary checks | Zod schemas per route |
| Tests | pytest against a Docker Compose Postgres | Vitest inside workerd against real D1 |
Kept from the 2021 API#
- Paths, including the
/recipes/:pageand/recipes/id/:idshapes. - Response keys:
Recipe,Ingredient,recipes-classification,recipe-review,weekly-menu-review,WeeklyMenu,users, with the same capitalisation. - Pagination of 10 rows per page with
meta.page,meta.per_pageandmeta.page_url. - Soft deletes through
is_publish, customer deactivation throughis_active, and 400 for resources other rows depend on. - 404 for an empty list or a missing row, and a 30-minute token.
Changed on purpose#
| Change | Why |
|---|---|
| Password hashes never appear in a response | The 2021 user and customer listings returned password hashes. |
| PBKDF2 instead of werkzeug hashing | Workers expose no scrypt or bcrypt. See Authentication. |
| Duplicate registration answers 409, not 403 | A conflict is not a forbidden request. |
| Validation answers 422 or 400 with JSON | The 2021 error paths could return HTML. |
WWW-Authenticate with the correct header name | The 2021 code sent WWW.Authentication, which is not a header. |
| PUT answers 200 everywhere | The 2021 weekly-menu PUT answered 204 with a body. |
nutrition is a JSON object | D1 has no hstore. |
Login reads Authorization: Basic | Same as 2021 in effect; the old header name check was unreliable. |
What stayed behind#
data/ holds the assignment's sample payloads, and PostmanCollectionE2ETestDev.json the 2021 E2E collection. Both still describe this API.