Task Overview Develop a RESTful API for an e-commerce platform with the following:
User Authentication
Register/Login (JWT-based)
Role-based access (Admin, Customer)
Product Management
CRUD for products (Only admins can add/remove products)
Products have: name, price, description, stock
Order Management
Customers can place orders
Orders have: items, total_price, status (pending, shipped, delivered)
Admins can update order status
Tech Stack You can pick based on what you're comfortable with, but a solid choice:
Backend: Python (FastAPI/Flask), Node.js (Express/NestJS), Go (Gin/Fiber)
Database: PostgreSQL, MySQL (or MongoDB if NoSQL is preferred)
Authentication: JWT-based auth
Tooling: Postman or Curl for testing
Interview Structure π‘ They will test how you structure your code, handle edge cases, and explain your decisions.
Set Up the Project (~10 mins)
Initialize the project (npm init, pip install fastapi, etc.)
Set up a minimal folder structure
Implement User Authentication (JWT) (~15β20 mins)
POST /register β Create user
POST /login β Authenticate user & return JWT
Middleware for protecting routes (admin, customer)
Build Product API (~15 mins)
POST /products β Admins add new products
GET /products β List all products
PUT /products/{id} β Update product details
DELETE /products/{id} β Remove a product (admin-only)
Build Order API (~20β25 mins)
POST /orders β Customer places an order
GET /orders/{id} β Fetch order details
PUT /orders/{id} β Admin updates order status
Error Handling & Optimization (~10 mins)
Handle bad requests, authentication failures, missing products
Use pagination for product listing (?page=1&size=10)
Use caching (optional, but shows system design thinking)
- caching
- api testing