Week 8/40 — CatAtlas: Identity Layer + Tests
Tech stack (this week)
Backend: FastAPI + SQLite + schema evolution
Testing:
pytest+ FastAPITestClientFrontend: React + TypeScript
“GenAI-style”: aggregation + templating for cat profiles
New topic: separating observations from identity + adding tests.
Why this week?
To make CatAtlas scalable, I needed “cats” as entities — not just sightings — and I wanted guardrails (tests) so I can evolve safely.
What I shipped
Added a
catstable (identity) separate from sightings (facts)Sightings can optionally link to a cat
Photo support via photo URLs (for now)
A generated “cat profile” that aggregates multiple sightings
First automated tests with pytest + TestClient
The One Feature Rule
One feature: identity layer + tests (foundation upgrade).
Not doing: real photo uploads, vision matching, complicated UI flows.
What I learned
A lot of “GenAI features” start as aggregation + structured templates, not magic models. And tests make iteration less scary.
Follow along (code it yourself): This week’s task
Task: Separate “observations” from “identity” and add your first tests.
Add a
catstable (identity).Add
cat_idto sightings (nullable).Build two endpoints (keep boundaries clean):
POST /cats(create identity)POST /sightings/{id}/assign(assignment happens after creation)
Add a “cat profile” endpoint that aggregates sightings into a readable summary.
Write 2 tests:
creating a cat works
assigning a sighting updates
cat_id
Success criteria: You can create a cat, assign a sighting, and tests pass.
Extra help & hints
This is a key AI-engineering pattern: entities vs events.
Keep tests integration-style: call the real API with a temporary DB.
If tests break due to schema changes: that’s the point—tests protect your iteration speed.