Prerequisites
Before you begin, ensure you have the following installed:- Python 3.10 or higher
- PostgreSQL 12 or higher
- Git
- pip (Python package manager)
Initial Setup
Run Initialization Script
The project includes an automated setup script that handles most of the configuration:This script will:
- Verify Python installation
- Create the project directory structure
- Set up a virtual environment in
venv/ - Install base dependencies from
requirements/base.txt - Optionally install development dependencies
- Configure pre-commit hooks (if
.pre-commit-config.yamlexists)
Configure Environment Variables
Create a Update the
.env file in the project root by copying the example file:.env file with your local configuration:Set Up PostgreSQL Database
Create a local PostgreSQL database:Alternatively, set the environment variables for PostgreSQL:
Install Development Dependencies
If you didn’t install development dependencies during initialization, install them now:This includes:
pytestandpytest-flaskfor testingblackfor code formattingmypyfor type checkingFlask-DebugToolbarfor debugging
Environment Configuration
The project supports multiple environments through theFLASK_ENV variable:
Local Development
config.py:41-51
- Debug mode enabled
- Local PostgreSQL database
- Relaxed security settings
Development Server
config.py:53-59
- Debug mode enabled
- Development database
- Similar to local but separate database
Testing
config.py:79-88
- Testing mode enabled
- Separate test database
- CSRF protection disabled
Production
config.py:61-77
- Debug mode disabled
- Requires all security variables
- Validates critical configuration
Project Structure
After setup, your project structure will look like this:Verifying Your Setup
Common Issues
Virtual Environment Not Activating
Solution: Ensure you’re using the correct activation command for your OS:- Linux/Mac:
source venv/bin/activate - Windows:
venv\Scripts\activate
PostgreSQL Connection Error
Solution: Verify PostgreSQL is running and credentials are correct:Missing Dependencies
Solution: Ensure you’ve installed the correct requirements file:Port Already in Use
Solution: Specify a different port:Next Steps
Create Features
Learn how to create new features using Clean Architecture
Testing
Write and run tests for your code
Migrations
Manage database migrations
Architecture
Understand the Clean Architecture structure