PromptBase
Upgrade
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
(claude-4-7-opus)
Token size
930
Example input
[PROJECT_CONTEXT]: scratch [TECH_STACK]: Python FastAPI + SQLite [TASK]: REST API for shortening links, with create and redirect endpoints, [CONSTRAINTS]: (blank β€” defaults) [OUTPUT_MODE]: plan
Example output
Proposed structure: link-shortener/ β”œβ”€β”€ app/ # application code, importable as a package β”‚ β”œβ”€β”€ main.py # FastAPI app + route wiring β”‚ β”œβ”€β”€ db.py # SQLite connection + schema init β”‚ β”œβ”€β”€ models.py # Pydantic request/response schemas β”‚ └── shortener.py # short-code generation + lookup logic β”œβ”€β”€ tests/ # pytest tests against the API └── requirements.txt # pinned dependencies Each top-level folder, one phrase: app/ holds runnable application code; tests/ keeps verification separate from shippable code; requirements.txt pins what runs. Task restatement: Build a small FastAPI service backed by SQLite that lets a client submit a long URL and get back a short code, then resolve that short code via a redirect endpoint that sends the browser to the original URL. Steps: Pin dependencies (fastapi, uvicorn, pydantic) in requirements.txt β€” SQLite needs no package, it's in Python's stdlib. In db.py, open a SQLite connection and create a links table (code primary key, url, created_at) if it doesn't exist. In shortener.py, write short-code generation (base62 over a random or sequential id) and a lookup-by-code function. In models.py, define a CreateLinkRequest (the long URL) and a CreateLinkResponse (the short code + full short URL). In main.py, wire two routes: POST /links to create, GET /{code} to redirect. In tests/, cover create-then-redirect and the unknown-code case. Files to create: requirements.txt β€” declares what the project runs on. app/db.py β€” owns the SQLite connection and schema so other modules don't duplicate it. app/models.py β€” request/response shapes, validated by Pydantic at the edge. app/shortener.py β€” isolates code-generation logic so it's unit-testable without HTTP. app/main.py β€” the FastAPI app and the two endpoints. tests/test_api.py β€” proves create and redirect work end to end. Assumptions / open questions that could change the approach: ASSUMPTION: short codes are server-generated; you don't need custom vanity aliases. If you want user-chosen codes, POST /links needs a collision check and the code becomes optional input. ASSUMPTION: a single-file SQLite DB on local disk is fine; no concurrency or multi-process deployment concern yet. Open question: should GET /{code} return 307 (temporary) or 301 (permanent) redirect? Default below is 307 so you can change destinations later without browsers caching the old one. Security note: the create endpoint should validate that the submitted URL is actually http/https to avoid storing javascript: or file: schemes β€” I'll fold that into the Pydantic model. Approve this plan, amend any assumption, or ask a question and I'll write the code. Next: confirm 307 vs 301 redirect and whether codes are server-generated, then re-run with OUTPUT_MODE: code.
πŸŒ€ Claude
Boosted itemBoosted

Vibe Coding Partners

Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
CLAUDE-4-7-OPUS
Tested icon
Guide icon
4 examples icon
Free credits icon
πŸš€ Turn any coding task into working software with a senior pair-programming partner. On an existing project it auto-detects your stack and conventions from the repo; on a new one it proposes a clean structure. It plans before it codes and writes real logic β€” never fake stubs or invented APIs. Five simple slots adapt it to your task and rules. Plan-first by default so you stay in control; switch to code mode when you're ready to ship.
...more
Added 1 day ago
Report
Browse Marketplace