Clean architecture, as defined by Robert C. Martin in his book Clean Architecture: A Craftsman's Guide to Software Structure and Design emphasizes the separation of concerns into distinct layers to promote modularity, testing, and code maintenance.
- Clone the repository to your local environment:
git clone https://github.com/wesleey/python-clean-architecture.git
- Navigate to the project directory:
cd python-clean-architecture
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # For Unix/macOS
venv\Scripts\activate # For Windows
- Install dependencies using pip3:
pip3 install -r requirements.txt
- Install pre-commit hooks:
pre-commit install
After installing and configuring the database, you can apply the necessary migrations using the following command:
alembic upgrade head
python cli_memory_process_handler.py
python flask_memory_process_handler.py
python flask_process_handler.py
curl -X POST -H "Content-Type: application/json" -d '{"first_name": "John", "last_name": "Doe", "email": "john@example.com"}' http://localhost:5000/v1/user/
Make sure the Flask server is running before making requests using cURL.
docker compose up -d
docker compose down
docker ps
docker exec -it <container_id> bash
exit
psql -U db_user -d db_name -c "SELECT * FROM users"
psql -U db_user -d db_name -c "DELETE FROM users"
psql -U db_user -d db_name -c "DELETE FROM users WHERE email = '<user_email>'"
- Python Clean Architecture In-memory CLI implementation
- Error Handling, Logging and Validation implementation in Python Clean Architecture
- Python Clean Architecture Flask Web API In-memory implementation
- Python Clean Architecture Flask Web API Postgresql implementation
This project is licensed under the MIT License.