This is a Cookiecutter template for creating a new Python project with a well-structured, modular architecture. It sets up a FastAPI-based application with a clean project structure, including configuration management, API routing, and dependency injection.
Before you begin, ensure you have the following installed:
- Python
- uv (for dependency management)
- Temporarily Install and run Cookiecutter to generate a new project using this template:
uvx cookiecutter https://github.com/Manas73/service_template
-
You will be prompted to enter various project details. Fill them out according to your preferences.
-
Once the project is generated, navigate to the project directory:
cd your-project-name
- Set up a virtual environment (optional but recommended):
uv sync
The generated project will have the following structure:
your-project-name/
├── {{ cookiecutter.pkg_name }}/
│ ├── adapters/
│ │ ├── api/
│ │ └── middlewares/
│ ├── config/
│ ├── domain/
│ │ └── entities/
│ ├── infrastructure/
│ ├── use_cases/
│ ├── __init__.py
│ ├── container.py
│ └── main.py
├── tests/
├── README.md
├── pyproject.toml
└── cookiecutter.json
The project uses pyproject.toml
for configuration. You can modify this file to adjust your project settings, including:
- Project metadata (name, version, description)
- Python version requirements
- Dependencies
- Development dependencies
- Linting and formatting tools (ruff, black)
- Testing configuration (pytest)
To run the application:
uv run your-project-name.main
This will start the FastAPI server on http://127.0.0.1:8000
.
Once the server is running, you can access the automatic API documentation:
- Swagger UI:
http://127.0.0.1:8000/docs
- ReDoc:
http://127.0.0.1:8000/redoc
To run the tests:
uv run pytest
Contributions are welcome! Please feel free to submit a Pull Request.