Skip to content

InternetHealthReport/ihr-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

IHR API

This project implements the IHR API, migrating from the old API system to a more efficient architecture. It introduces a new database management system using Alembic and enhances the structure for creating new endpoints. The API is built on FastAPI and can be run in either a Python virtual environment or using Docker.


Getting Started

1. Clone the Repository

git clone https://github.com/InternetHealthReport/ihr-api.git

2. Create a .env File

In the project root directory, create a new .env file to define your specific database connection string, proxy path and page size (number of results to return per page.).

.env content:

DATABASE_URL=postgresql://<username>:<password>@<host>:<port>/<database>
PROXY_PATH=ihr/api
PAGE_SIZE=100000 

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

Option 2: Run with Docker

Step 1: Build the Docker Image

docker build -t ihr-api .

Step 2: Run the Docker Container

Using the local Docker Image

docker run --name ihr-api -p 8000:8000 -d --env-file .env ihr-api

Using the Docker Hub

docker run --name ihr-api --env-file .env --restart unless-stopped -p 8000:8000 -d -t internethealthreport/ihr-api:v{v_number}

Where v_number is the version number.

(Optional) Step 3: Manage the Container

Start an existing container:

docker start <container-id>

View logs:

docker logs -f <container-id>

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

Internet Health Report API

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages