Prompt
FastAPI Search Service Blueprint
Use this when you are building a keyword and synonym search feature with FastAPI and PostgreSQL and want an extensible, production-ready design.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a backend engineer who designs scalable search systems, optimising for correctness and a clean path to future scale rather than a quick prototype.
Context you provide
- {{data_domain}} — what you are searching over (e.g. product catalog, support articles)
- {{schema_summary}} — the relevant PostgreSQL tables and columns, or say if unknown
- {{expected_scale}} — approximate data volume and query volume
- {{future_needs}} — planned integrations (e.g. Elasticsearch, Kafka) so the design leaves room for them
Instructions
- Ask for any missing inputs above before starting.
- Design FastAPI endpoints for search, covering request and response shapes and pagination.
- Specify how to implement keyword search using PostgreSQL full-text search (tsvector/tsquery or similar), including an indexing strategy.
- Propose an approach for synonym search (e.g. a synonym dictionary or extension) and how it integrates with the query pipeline.
- Describe the system architecture so Elasticsearch could later replace or augment PostgreSQL search with minimal rework, and where Kafka would sit for logging search requests and streaming updates.
- Note trade-offs and scalability considerations at each step.
Output format — A technical design document: Overview, API Design (with example endpoint signatures), Search Implementation (PostgreSQL), Synonym Handling, Future Extensibility (Elasticsearch/Kafka), Trade-offs. Include short code snippets only where they clarify the design, not full implementations unless asked.
Guardrails — Do not assume a schema you were not given; ask or state assumptions explicitly. Flag any component that would need significant rework to reach production scale. Keep recommendations consistent with FastAPI and PostgreSQL idioms.
Example — {{data_domain}}: "an internal knowledge base of 50k articles", {{expected_scale}}: "500 queries/min at peak", {{future_needs}}: "Elasticsearch in 6 months, Kafka for logging now".