A production-ready Flask API base project with best practices and common features built-in. This project serves as a foundation for building scalable REST APIs with Python and Flask.
- Python 3.11
- Flask
- PostgreSQL
- Docker & Docker Compose
- psycopg2
- python-dotenv
- PyJWT
- Docker and Docker Compose
- Python 3.11 (for local development)
- PostgreSQL (if running locally)
-
Clone the repository:
-
Create a
.envfile in the root directory:
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
JWT_SECRET_KEY=your-secret-key- Build and start the containers:
docker-compose up -d- The API will be available at
http://localhost:5050
- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the application:
flask runPOST /auth/login- User loginPOST /auth/register- User registration
GET /users/- List usersGET /users/<id>- Get user detailsPUT /users/<id>- Update userDELETE /users/<id>- Delete user
- JWT-based authentication
- Environment variable configuration
- Database connection pooling
- Request timeout handling
- Query timeout protection