GpacAPI is a service for interacting with the GPAC application.
See the API documentation for details.
- 📡 FastAPI-based: Built using FastAPI for high-performance API responses.
- 📊 Database connectivity: Uses MongoDB as the primary database.
- 🛠️ CI/CD integration: Automated testing, linting, and deployment workflows.
- 🐳 Docker support: Easily deployable using Docker containers.
- 📌 Pre-commit hooks: Ensures clean and standardized code.
The following environment variables are required for running the API:
| Variable Name | Description |
|---|---|
DATABASE_CLIENT |
The name or identifier for the database client being used for the connection. |
DATABASE_CONNECTION_STRING |
The full MongoDB connection string used to connect to the database, including credentials, server address, etc. |
FRONTEND_ORIGIN |
The origin (URL) of the frontend application, the location where the frontend is hosted. |
It is recommended to run the server in a separate environment.
- Clone the repository:
git clone https://github.com/mihamieat/gpac-api.git
cd gpac-api- Install dependencies
pip install -r requirements.txtfastapi run src/gpac_api/app/main.py --port 80fastapi dev src/gpac_api/app/main.py --reloadMake sure to have Docker installed.
To run the server in a docker container.
Create a Docker image.
docker build -t gpac_api_image .Run the server container.
docker run -d --name gpac_api_container -p 80:80 gpac_api_imageHere is the list for CI/CD environment variables to be created in GitHub Action Secret variables.
| Variable Name | Description |
|---|---|
CODECOV_TOKEN |
The authentication token for uploading code coverage reports to Codecov. |
DATABASE_CONNECTION_STRING |
The full connection string used to connect to the database in the CI/CD pipeline. |
DOCKERHUB_TOKEN |
The access token for authenticating with DockerHub to push/pull images. |
FRONTEND_ORIGIN |
The origin (URL) of the frontend application, typically used for CORS settings. |
GH_PAT |
The GitHub Personal Access Token (PAT) used for authenticating GitHub actions or API requests. |
REMOTE_HOST |
The hostname or IP address of the remote server used for deployment. |
REMOTE_USER |
The username for accessing the remote server. |
SSH_PRIVATE_KEY |
The private SSH key used for secure authentication with remote servers. |
SSH_PUBLIC_KEY |
The corresponding public SSH key for authentication and access control. |
Pre-commit is a tool that helps developers automatically run checks and formatting on their code before they commit changes to a version control system like Git.
python -m ensurepip
curl -sSL https://bootstrap.pypa.io/get-pip.py | python -
python -m pip install --user pre-commit
pre-commit installUnit test is an essential tool for the pre-commit action. It could also be launched alone.
Again, make sure to have Docker installed as well as Docker Compose
Make sure that the shell script is executable for the current user
chmod u+x ./unittest.shYou can now run
./unittest.shIf you have any questions or need further assistance, feel free to open an issue or reach out! 🚀