developer coding user risk: low
FastAPI PostgreSQL Keyword Synonym Search Service
Develop a FastAPI application with endpoints for keyword and synonym searches using PostgreSQL's full-text search features and a suitable library. Design the system architecture fo…
PROMPT
Act as a software engineer tasked with developing a scalable search service. You are tasked to use FastAPI along with PostgreSQL to implement a system that supports keyword and synonym searches. Your task is to: - Develop a FastAPI application with endpoints for searching data stored in PostgreSQL. - Implement keyword and synonym search functionalities. - Design the system architecture to allow future integration with Elasticsearch for enhanced search capabilities. - Plan for Kafka integration to handle search request logging and real-time updates. Guidelines: - Use FastAPI for creating RESTful API services. - Utilize PostgreSQL's full-text search features for keyword search. - Implement synonym search using a suitable library or algorithm. - Consider scalability and code maintainability. - Ensure the system is designed to easily extend with Elasticsearch and Kafka in the future.
ROLES & RULES
Role assignments
- Act as a software engineer tasked with developing a scalable search service.
- Develop a FastAPI application with endpoints for searching data stored in PostgreSQL.
- Implement keyword and synonym search functionalities.
- Design the system architecture to allow future integration with Elasticsearch for enhanced search capabilities.
- Plan for Kafka integration to handle search request logging and real-time updates.
- Use FastAPI for creating RESTful API services.
- Utilize PostgreSQL's full-text search features for keyword search.
- Implement synonym search using a suitable library or algorithm.
- Consider scalability and code maintainability.
- Ensure the system is designed to easily extend with Elasticsearch and Kafka in the future.
EXPECTED OUTPUT
- Format
- markdown
SUCCESS CRITERIA
- Develop FastAPI app with PostgreSQL search endpoints
- Implement keyword search using PostgreSQL FTS
- Implement synonym search
- Design architecture for Elasticsearch integration
- Plan Kafka integration for logging and updates
- Ensure scalability and maintainability
FAILURE MODES
- May not utilize PostgreSQL full-text search
- Might skip synonym implementation
- Could neglect future integration planning
- May overlook scalability considerations
CAVEATS
- Missing context
-
- Database schema or data model for searchable content.
- Example search queries and expected results.
- API request/response formats.
- Scalability metrics (e.g., QPS, user load).
- Deliverables (e.g., full code, architecture diagram, README).
- Ambiguities
-
- Unclear what specific data entities are to be searched (e.g., no schema or examples provided).
- Vague on exact endpoints (e.g., paths, methods, parameters).
- 'Suitable library or algorithm' for synonyms is ambiguous without recommendations.
- Scope of future integrations: design/plan only, or stubs?
QUALITY
- OVERALL
- 0.65
- CLARITY
- 0.85
- SPECIFICITY
- 0.70
- REUSABILITY
- 0.40
- COMPLETENESS
- 0.60
IMPROVEMENT SUGGESTIONS
- Add a data model section, e.g., 'Assume a 'products' table with id, name, description columns.'
- Specify endpoints like 'GET /search/keyword?q={query}' and sample JSON responses.
- Recommend synonym tools, e.g., 'Use NLTK for synonyms or pg_trgm extension.'
- Require deliverables: 'Provide complete FastAPI code, SQL setup, architecture diagram in Mermaid, and integration plan.'
- Include constraints like async support or Docker setup.
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR DEVELOPER
- Context7 Library Documentation Expertdevelopercoding
- Structured Python Production Code Generatordevelopercoding
- Angular Standalone Directive Generatordevelopercoding
- Pytest Unit Test Suite Generatordevelopercoding
- Unity Architecture Specialistdevelopercoding
- Web Typography CSS Generatordevelopercoding
- VSCode CodeTour File Expertdevelopercoding
- Senior Python Code Reviewerdevelopercoding
- Structured Cross-Language Code Translatordevelopercoding
- Multi-DB SQL Query Optimizer and Builderdevelopercoding