Python Developer Coding Assessment – Requirement
Document
Overview
This document describes the requirements for a coding assessment to build a
microservice backend using Python. The candidate should demonstrate proficiency in
API development, database interaction, caching, and containerization using Docker.
Technology Stack
• Python with FastAPI
• SQLAlchemy or any equivalent ORM
• PostgreSQL
• Redis / any equivalent for caching
• Docker and Docker Compose
Functional Requirements
1. API Development
Develop a FastAPI application exposing the following endpoints:
• GET /products – List all products
• POST /products – Add a new product
• GET /products/{id} – Get product by ID
• PUT /products/{id} – Update product by ID
• DELETE /products/{id} – Delete product by ID
2. Data Modeling
Design a SQLAlchemy (or equivalent ORM) model for Product with the following fields:
• id: UUID or auto-incrementing ID
• name: String, required
• description: String
• price: Float, required
• in_stock: Boolean
3. Database Integration
• Configure the FastAPI app to connect to a PostgreSQL database
• Implement basic CRUD operations for the product model
4. Caching with Redis
• Cache the GET /products/{id} response using Redis
• Set the cache expiry to 60 seconds
• Invalidate the cache when a product is updated or deleted
5. Dockerization
• Create a Dockerfile for the FastAPI application
• Create a docker-compose.yml file including:
o FastAPI app
o PostgreSQL service
o Redis service
6. Optional Enhancements (Bonus)
• Use Pydantic models for request/response validation
• Write at least one basic unit test for any endpoint
• Expose interactive API documentation using Swagger UI (/docs)
• Use .env files to manage environment variables
• Provide a Postman collection or cURL commands to test the API
Deliverables
Submit the following:
• GitHub repository or zipped folder containing your project files
• README file with clear setup instructions
• Dockerfile and docker-compose.yml
• .env.sample file to describe expected environment variables
• (Optional) Postman collection or API test script
Timeline
Within 5 days from the time of task assignment