Backend principles
Much more or less the Backend Checklist note but this is like the condensed version.
1. CORS
— First thing you hit when React tries to talk to Flask.
Controls which origins can access your API.
2. Error Handling
— Centralised error responses. Instead of scattered
return {"error": ...} everywhere, one place handles
all errors consistently.
3. Input Validation
— Validate data before it touches your DB.
Wrong types, missing fields, bad formats — caught early.
Tools: Marshmallow, Pydantic, or manual checks.
4. Pagination
— Don't return 10,000 rows at once. Return page 1 of 20,
let the client ask for more. Needed as soon as your
DB grows beyond toy data.
5. Rate Limiting
— Limit how many requests a client can make in a time window.
Protects against abuse and brute force attacks.
Tool: flask-limiter.
6. Swagger / API Documentation
— Auto-generate interactive docs from your code.
Employers, teammates, and your future self will thank you.
Tool: flask-smorest or flasgger.
7. Caching
— Store expensive query results temporarily so you don't
hit the DB on every request. Needs Redis.
Tool: flask-caching + Redis.
8. Celery
— Run tasks in the background (sending emails, processing
images, scheduled jobs) without blocking the request.
Needs Redis or RabbitMQ as a message broker.