- Introduction
- Project Structure
- Setup
- Database
- Running the Application
- Development
- API Documentation
- Testing
Welcome to the 10XScale-in Backend Base project. This FastAPI-based application serves as a robust foundation for building scalable and efficient backend services. Our project is designed with modern development practices in mind, offering a streamlined setup process and powerful features to accelerate your development workflow.
Key Features:
- FastAPI framework for high-performance, easy-to-use REST APIs
- Aerich for smooth database migrations and management
- Pre-commit hooks for maintaining code quality
- VS Code integration for enhanced debugging capabilities
- Comprehensive documentation to guide you through setup and development
This backend base is ideal for developers looking to quickly bootstrap a new project or for teams aiming to standardize their backend infrastructure. Whether you're building a small service or laying the groundwork for a large-scale application, our project provides the tools and structure you need to succeed.
The documentation that follows will guide you through setting up your development environment, running the application, managing the database, and contributing to the project. We've designed this guide to be as comprehensive as possible, ensuring that both newcomers and experienced developers can quickly get up to speed.
Let's get started on building your next great backend service!
project_root/
├── src/
│ └── app/
│ ├── main.py
│ └── db/
│ └── setup_database.py
├── tests/
├── requirements.txt
├── .pre-commit-config.yaml
└── README.md
- Python 3.x
- pip
- [Any other prerequisites]
-
Clone the repository:
git clone https://github.com/10XScale-in/backend-base.git
-
Create a virtual environment and activate:
python -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
The database configuration is located in src/app/db/setup_database.py.
We use Aerich for database migrations. Follow these steps to manage your database:
-
Initialize the database initially:
aerich init -t src.app.db.setup_database.TORTOISE_ORM
-
Create initial database schema:
aerich init-db
-
Generate migration files:
aerich migrate
-
Apply migrations:
aerich upgrade
-
Revert migrations (if needed):
aerich downgrade
To run the FastAPI application using Uvicorn:
-
Start the application:
uvicorn src.app.main:app --reload
-
You can also run the debugger.
Add the following configuration to your .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"src.app.main:app",
"--host",
"localhost",
"--port",
"8880"
],
"jinja": true,
"justMyCode": true
}
]
}Then you can run and debug the application using the VS Code debugger.
- Run the taskiq worker
We use pre-commit hooks to ensure code quality. To set them up:
- Install the pre-commit package:
pip install pre-commit
- Install the git hook scripts:
pre-commit install
1.ruff,
2.mypy,
3.bandit
1.pytest
https://keda.sh/ Get all the fixers pytest --fixtures https://www.tutorialspoint.com/pytest/pytest_run_tests_in_parallel.html