Skip to content

feat(laptop): add laptop device category (engine)#39

Merged
Seungpyo1007 merged 1 commit into
mainfrom
feat/laptop-category
Jul 8, 2026
Merged

feat(laptop): add laptop device category (engine)#39
Seungpyo1007 merged 1 commit into
mainfrom
feat/laptop-category

Conversation

@Seungpyo1007

Copy link
Copy Markdown
Member

What & why

Adds a new laptop device category to the engine, end-to-end, so TechAPI can carry data/laptop/ records that get validated, served and dumped like any other category. This is the engine half of the laptop rollout; the TechAPI data PR (seeding data/laptop/ + mirroring the validate rule) is paired and merges after this.

Design

  • brand FK required; cpu/gpu FK optional. Laptop CPU/GPU come from datasets as free-text strings, so cpu_name/gpu_name are always stored and cpu_id/gpu_id are set only when the string resolves to an existing CPU/GPU — no FK bottleneck on import.
  • Unscored (like tablet/watch/pda): lighter MVP, no /score endpoint, not in the dump SCORED set. Scoring can be added later without schema churn.

Changes

File Change
app/models/laptop.py new Laptop table
app/models/__init__.py register model
app/schemas/laptop.py + serializers.py + schemas/__init__.py LaptopRead + laptop_read()
app/routers/laptops.py + app/main.py list/detail endpoints (filters: brand, cpu, gpu), router registered
app/seed.py seed data/laptop/, resolve brand (req) + cpu/gpu (opt) FKs
app/dump.py laptops added to COLLECTIONS (not SCORED)
app/validate.py LAPTOP_REQUIRED + ranges (ram 1–256, weight 300–6000, msrp 50–50000) + FK checks + variant path
tests/integration/{laptop_fixtures,test_laptops}.py fixtures + list/detail/filter/404/unscored tests

Verification

  • ruff check app tests ✅ · mypy app ✅ (89 files)
  • pytest tests/integration/test_laptops.py ✅ (4 tests)
  • Manual: seed → /v1/laptops list, detail (embeds brand + cpu/gpu refs, preserves raw cpu_name), brand filter, 404, and app.dump writes v1/laptops/** + manifest entry (no scored key). Existing endpoints unaffected; /v1/laptops present in OpenAPI.

Tests use self-contained fixtures, so CI passes before any laptop data exists in TechAPI.

… validate)

Introduces a new `laptop` device category end-to-end:

- `app/models/laptop.py` — Laptop table; brand FK required, cpu/gpu FK
  optional (raw cpu_name/gpu_name always kept so a record is meaningful
  without a resolved component). Unscored.
- `app/schemas/laptop.py` + serializer `laptop_read` — detail response
  embeds brand + optional cpu/gpu refs; no score field.
- `app/routers/laptops.py` — list + detail with brand/cpu/gpu filters.
- `app/main.py` — register the router.
- `app/seed.py` — seed data/laptop/, resolve brand (required) + cpu/gpu
  (optional) FKs from slugs.
- `app/dump.py` — add "laptops" to COLLECTIONS (not SCORED).
- `app/validate.py` — LAPTOP_REQUIRED + ranges (ram 1-256, weight
  300-6000, msrp 50-50000) + brand/cpu/gpu FK checks + variant path.
- tests: laptop fixtures + integration tests (list, detail embeds,
  brand filter, 404, unscored).

Paired with the TechAPI data PR that seeds data/laptop/ and mirrors the
validate rule.
@Seungpyo1007 Seungpyo1007 merged commit d1c3b0b into main Jul 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant