This project is a FastAPI-based backend for the IHR system. It is designed for flexibility and can be run either in a Python virtual environment or using Docker.
In the project root directory, create a new .env
file to define your specific database connection string.
.env
content:
DATABASE_URL=postgresql://<username>:<password>@<host>:<port>/<database>
You can run this application in one of the following ways:
- Using a Python virtual environment
- Using Docker
python -m venv venv
venv\Scripts\activate
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
Once running, you can access:
- API: http://localhost:8000
- Interactive Docs (Swagger UI): http://localhost:8000/docs
- Redoc Docs: http://localhost:8000/redoc
docker build -t ihr-fastapi .
docker run -p 8000:8000 --env-file .env ihr-fastapi
Start an existing container:
docker start <container-id>
View logs:
docker logs -f <container-id>
Once running, you can access:
- API: http://localhost:8000
- Interactive Docs (Swagger UI): http://localhost:8000/docs
- Redoc Docs: http://localhost:8000/redoc
The docs/
folder contains detailed documentation for various aspects of the project. Below is a list of available documentation files and their descriptions:
Provides an overview of the project's file and folder structure, organized according to the Service-Controller-Repository architectural pattern.
Explains the Service-Controller-Repository architecture adopted by the project, highlighting the responsibilities of each layer and how they interact.
Details how to manage database migrations using Alembic, including TimescaleDB-specific features like hypertables and compression policies.
A step-by-step guide on how to add a new endpoint to the application.