API server for Artadas project
- Python 3.12+
- Docker
- Docker Compose plugin
-
Clone the repository:
git clone --recurse-submodules [email protected]:razmikarm/artadas_api.git cd artadas_api
-
Rename
.env.exampleto.envand fill real data (also forauthsubmodule)cp .env.example .env
-
Create a virtual environment:
python -m venv venv source venv/bin/activate -
Install dependencies:
pip install --upgrade pip pip install -r requirements.txt
-
Start the server:
uvicorn app.main:app --reload
-
Access the API at 127.0.0.1:8000.
-
View the interactive API docs:
- Swagger UI: 127.0.0.1:8000/docs
- ReDoc: 127.0.0.1:8000/redoc
Before running any docker command navigate to
dockerdirectory Make sure you have SSL certificates innginx/certsdirectory
-
Navigate to
dockerdirectorycd docker -
Update write permission on init script
chmod a+w init-scripts/02_init-auth-db.sql
-
Build your containers:
docker compose build
-
Run containers:
docker compose up
-
Access the API at 0.0.0.0:8000.
-
View the interactive API docs:
- Swagger UI: 0.0.0.0:8000/docs
- ReDoc: 0.0.0.0:8000/redoc
The project will be mounted in container and will reload on new changes
-
Install Pre-Commit Hooks:
pre-commit install
-
Check if it's working:
pre-commit run --all-files
-
Run to check with linter:
ruff check
-
Run to resolve fixable errors:
ruff check --fix
-
Run to reformat code:
ruff format
To only start database service, run
docker compose up db
-
Generate new revision:
alembic revision --autogenerate -m "Your migration message" -
Upgrade Database with new revision:
alembic upgrade head
-
When main repository detects that the submodule's commit reference has changed
git add <auth or tg_bot> git commit -m "Updated <Auth or TG_Bot> submodule to the latest version"
-
Update submodules to the latest commit that repositories references
git submodule update --remote
-
Remove existing containers
docker compose down
-
Remove database volume
docker volume rm artadas_api_postgres_data
-
Or delete volumes with one command:
docker-compose down -v
-
Install testing dependencies:
pip install pytest pytest-asyncio
-
Run tests:
pytest
- Add authentication using OAuth2 or JWT.
- Integrate Alembic for database migrations.
- Deploy to a cloud provider like AWS, GCP, or Heroku.