[Link]-ImplementAPI.
md
al
rn
HoHai
te
Mar-2026
In
RECORD OF CHANGES
No Effective Change Descrip- Reason Reviewer Approver
Date tion
1 Mar-2026 Initial Version. Create new HoHai
al
rn
te
In
FSA - FPT Software (Internal Use) [Link]
Exercise: FastAPI + Async SQLAlchemy + Basic TODO CRUD
Goal
Build an API-only TODO service using FastAPI + SQLAlchemy 2.x async (asyncpg) connected to the Dock-
erized Postgres.
Suggested Project Structure
app/
core/[Link]
db/[Link]
db/[Link]
db/[Link]
api/routes/[Link]
[Link]
alembic/ (created in Lab 4)
al
[Link] (later adds app service)
Dockerfile
Tasks
1. Dependencies
2. Async SQLAlchemy setup
rn
pip install fastapi uvicorn sqlalchemy asyncpg pydantic pydantic-settings
• Depend on your implementation
3. Model
• Todo model has some fields: id, title, description, completed, created_at, updated_at
te
4. Schema (Pydantic)
• Create schema models: TodoCreate, TodoRead with require validation
5. FastAPI App
• Consider to use router (APIRouter - fastapi)
6. Run
In
uvicorn [Link]:app --reload
# Test in /docs (Swagger) and with curl
curl -X POST [Link] -H "Content-Type: application/json" -d '{"title":"Read paper"
Acceptance Criteria
• API responds with 201 on create, returns JSON aligned with schema.
• GET, PATCH toggle, DELETE behave as defined.
• /docs loads correctly with generated OpenAPI.
Deliverables
• Source code.
• A short README with run instructions and sample curl or test script calls.
Author: HoHai Page 3 / 4 Mar-2026
FSA - FPT Software (Internal Use) [Link]
Rubric (40 pts)
• Async DB setup
• Model + schema correctness
• CRUD endpoints working
• README & API docs
al
rn
te
In
Author: HoHai Page 4 / 4 Mar-2026