Skip to content

InternetHealthReport/ihr-api

IHR FastAPI App

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.


Getting Started

1. Clone the Repository

2. Create a .env File

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>

Running the Application

You can run this application in one of the following ways:

  • Using a Python virtual environment
  • Using Docker

Option 1: Run in a Python Virtual Environment

Step 1: Create and Activate a Virtual Environment

On Windows:

python -m venv venv
venv\Scripts\activate

On macOS/Linux:

python3 -m venv venv
source venv/bin/activate

Step 2: Install Dependencies

pip install -r requirements.txt

Step 3: Run the Application

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Step 4: Access the API

Once running, you can access:


Option 2: Run with Docker

Step 1: Build the Docker Image

docker build -t ihr-fastapi .

Step 2: Run the Docker Container

docker run -p 8000:8000 --env-file .env ihr-fastapi

(Optional) Step 3: Manage the Container

Start an existing container:

docker start <container-id>

View logs:

docker logs -f <container-id>

Step 4: Access the API

Once running, you can access:


Documentation

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.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •