This guide provides fully detailed instructions on how to set up the Python environment, install necessary dependencies, and run the FastAPI backend server.
python and pip are accessible from your terminal/command prompt.It is best practice to use a virtual environment to manage project-specific dependencies.
E:\ASTRA):
cd E:\ASTRA
venv inside the services directory using Python 3.12:
python -m venv services\venv
(Note: If your system uses py or python3 instead of python, replace it accordingly: py -3.12 -m venv services\venv)Before installing packages or running the server, you must activate the virtual environment.
services\venv\Scripts\activate.bat
services\venv\Scripts\Activate.ps1
source services/venv/bin/activate
Once activated, your terminal prompt should be prefixed with (venv).
With the virtual environment activated, install the required packages.
requirements.txt file located in the services folder:
pip install -r services\requirements.txt
This will install all necessary libraries, including FastAPI, Uvicorn, OpenCV, DeepFace, and SQLAlchemy. (If you also want to run the AI processing module, you will need to create a separate virtual environment inside services/ai and run pip install -r services\ai\requirements.txt there, which installs DeepFace, OpenCV, SciPy, and TF-Keras.)
We have created a script to seed test users across all system roles (Admin, Dispatcher, Officer). You can find the login details for these users in TEST_CREDENTIALS.md.
To run the seed script again manually (from the root folder):
$env:PYTHONPATH="."
.\services\venv\Scripts\python database\scripts\seed_users.py
The project uses SQLAlchemy and Alembic for database migrations.
.env file).database directory (where alembic.ini is located) and run the upgrade:
cd database
alembic upgrade head
cd ..
The backend is built with FastAPI and runs using the Uvicorn ASGI server.
E:\ASTRA) and your virtual environment is still activated.uvicorn services.backend.main:app --reload
uvicorn: The lightning-fast ASGI server.services.backend.main:app: Tells Uvicorn to look inside the services/backend/main.py file for the app instance (the FastAPI application).--reload: Enables hot-reloading so the server automatically restarts when you make code changes (useful for development).Once the server starts successfully, it will display a local URL (typically http://127.0.0.1:8000).
This guide provides fully detailed instructions on how to set up the Python environment, install necessary dependencies, and run the FastAPI backend server.
python and pip are accessible from your terminal/command prompt.It is best practice to use a virtual environment to manage project-specific dependencies.
E:\ASTRA):
cd E:\ASTRA
venv inside the services directory using Python 3.12:
python -m venv services\venv
(Note: If your system uses py or python3 instead of python, replace it accordingly: py -3.12 -m venv services\venv)Before installing packages or running the server, you must activate the virtual environment.
services\venv\Scripts\activate.bat
services\venv\Scripts\Activate.ps1
source services/venv/bin/activate
Once activated, your terminal prompt should be prefixed with (venv).
With the virtual environment activated, install the required packages.
requirements.txt file located in the services folder:
pip install -r services\requirements.txt
This will install all necessary libraries, including FastAPI, Uvicorn, OpenCV, DeepFace, and SQLAlchemy. (If you also want to run the AI processing module, you will need to create a separate virtual environment inside services/ai and run pip install -r services\ai\requirements.txt there, which installs DeepFace, OpenCV, SciPy, and TF-Keras.)
We have created a script to seed test users across all system roles (Admin, Dispatcher, Officer). You can find the login details for these users in TEST_CREDENTIALS.md.
To run the seed script again manually (from the root folder):
$env:PYTHONPATH="."
.\services\venv\Scripts\python database\scripts\seed_users.py
The project uses SQLAlchemy and Alembic for database migrations.
.env file).database directory (where alembic.ini is located) and run the upgrade:
cd database
alembic upgrade head
cd ..
The backend is built with FastAPI and runs using the Uvicorn ASGI server.
E:\ASTRA) and your virtual environment is still activated.uvicorn services.backend.main:app --reload
uvicorn: The lightning-fast ASGI server.services.backend.main:app: Tells Uvicorn to look inside the services/backend/main.py file for the app instance (the FastAPI application).--reload: Enables hot-reloading so the server automatically restarts when you make code changes (useful for development).Once the server starts successfully, it will display a local URL (typically http://127.0.0.1:8000).