Lesson 8 — Beginner

Capstone: Ship a No-AI REST Service

Ab tak sab alag-alag the — ab sab ek saath. Is capstone mein tum ek chhoti service banayenge bina kisi AI feature ke: Python + FastAPI + PostgreSQL + tests + git workflow + Docker + public deploy. Neeche clear spec, build plan aur ship checklist di hai — ise follow karke apna pehla deployable service le aao.

⏱ 10 min• Beginner• Containers & Deployment

Capstone kya hai aur kyun

WHAT

Ek poora REST service jo actually public URL pe chalta hai — CRUD endpoints, validation, database, tests, README, container. Koi AI/LLM call nahi; sirf solid software engineering.

WHEN

L0 ke end par — jab Python, HTTP, FastAPI, DB, git, AI-assisted workflow aur Docker sab covered ho. Aage har AI service isi skeleton par banegi.

WHERE

Resume project, interview demo aur agle levels ka base — isi service mein aage AI features chadhte jayenge.

Capstone ka asli maksad code nahi — maksad hai process: spec likhna, plan banana, agent se collaborate karke chhote diffs mein build karna, har diff verify karna, aur end-to-end ship karna. Ek din mein ho jaane wala kaam hai — lekin steps mat chhodna.

Non-negotiable: Service mein koi AI/LLM call nahi. Ye jaan-boojh kar hai — pehle fundamentals ka ek clean artifact banao, phir AI features isi par chadhaoge.

Scope chhota rakho, spec pehle likho

# Service: Bookings API (no-AI)

## Resources
rooms    : {id, name, capacity}
bookings : {id, room_id, start, end, guest}

## Endpoints
GET    /health        -> 200 {"status": "ok"}
GET    /rooms         -> 200 list
POST   /rooms         -> 201 | 422
GET    /bookings      -> 200 list (?room_id= filter)
POST   /bookings      -> 201 | 409 clash (overlapping time)
GET    /bookings/{id} -> 200 | 404
DELETE /bookings/{id} -> 204 | 404

## Rules
- Har input Pydantic se validated, ISO times, past booking = 422
- Errors: {"error": "...", "code": "..."} — har jagah same shape
- Write routes par X-API-Key header
Scope rule: Jo feature list mein nahi, wo is capstone mein nahi. Idea aaye toh "baad mein" wali file mein daalo — focus hi shipping ki taakat hai.

Repo layout aur build order

repo/
├── app/
│   ├── main.py          # app + lifespan
│   ├── config.py        # env vars (Pydantic Settings)
│   ├── db.py            # connection + pool
│   ├── routes/          # rooms.py, bookings.py
│   └── schemas.py       # Pydantic in/out models
├── tests/               # test_rooms.py, test_bookings.py
├── .env.example         # keys ka sample (commit hota hai)
├── .gitignore
├── Dockerfile
├── pyproject.toml
└── README.md

# Order — har step par tests green, har step ek commit
1. uv init + FastAPI skeleton + /health
2. Pydantic schemas + rooms CRUD (in-memory)
3. PostgreSQL swap + credentials env se
4. bookings + 409 clash rule + filters
5. README + Dockerfile
6. Deploy + smoke test -> tag v1.0
Definition of done: Doosra developer README padhkar bina tumhare baat kiye service locally chala le, test chala le aur endpoint call kar le. Yahi capstone ka gate hai.

Ship checklist — local se public tak

# Ship se pehle (local — chaaro green)
uv run ruff check . && uv run mypy app && uv run pytest -q
docker build -t bookings-api:1.0 .
docker run --rm -p 8000:8000 --env-file .env bookings-api:1.0

# Ship (platform: image + env vars) ke baad — smoke test
curl -sS https://<public-url>/health
curl -sS https://<public-url>/rooms
curl -sS -X POST https://<public-url>/rooms -H "Content-Type: application/json" -d @room.json

# Har response ka STATUS CODE dekho (201/409/422) — sirf body nahi
git tag v1.0 && git push --tags
Interview angle: Project ke saath yehi 4 line bolo — kya banaya, kaunsa stack, kaise deploy kiya, aur ek problem jo solve ki (409 clash, container crash). Stories > features.

Exercise

Question: Is capstone ki service mein AI/LLM feature hona chahiye ya nahi?

Question: FastAPI ki generated interactive docs ka default local path?

Question: Final service ko public URL pe chalane ke liye jo image banata hai uska tool kya hai?

Common mistakes

Desi example: Pehla ghar — capstone ka desi analogy

Register mein pehla ghar banane jaisa — naksha chhota rakho, material fixed, aur har kamra banne ke baad inspection. Ghar tab complete hai jab bijli-paani (health + DB) bhi chalu ho aur mehmaan (teammate) bina tumhare poochhe ghar mein ghoom le:

bash
Naksha   : spec -> 2 resources, 7 endpoints, status codes fix
Material : uv + FastAPI + PostgreSQL + pytest
Building : har kamra ek commit, har step par test (verification loop)
Shift    : docker build -> platform -> public URL -> curl smoke
Pehla din: git tag v1.0 — ship ho gaya!
Interview angle — yahan se sawaal aate hain
  • Q: Tumhari service ke endpoints kaunse hain aur status codes kaise decide kiye? — Spec se:201 create, 409 clash, 422 validation.
  • Q: 409 clash wala rule kaise implement kiya? — Overlapping time check + consistent error body.
  • Q: Config aur secrets deploy tak kaise pahunchaye? — Env vars, .env.example commit, production mein platform secrets; repo mein kabhi nahi.
  • Q: Ek bug jo containerization mein mila aur kaise debug kiya? — logs -> env -> port -> path ka order se.
  • Q: Ye project AI level mein kaise kaam aayega? — Same service par AI features (LLM endpoints) isi skeleton par chadhte hain.
Lesson complete?

L0 complete — Python, web, FastAPI, DB, git, AI-assisted workflow aur Docker ab tumhare paas hai. Agle level mein inhi foundations par AI features banana shuru honge.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course