The Stats API is a REST API that collects and provides statistical information about processed messages in a system. It allows tracking the number of messages and the total amount processed for each customer ID and message type within a specified date interval.
To run the Stats API, you need the following:
- Docker and Docker Compose
The Stats API is built using the following technologies:
- Python: The programming language used to develop the API.
- FastAPI: A modern, fast (high-performance), web framework for building APIs with Python.
- SQLAlchemy: A SQL toolkit and Object-Relational Mapping (ORM) library for Python.
- PostgreSQL: A popular open-source relational database.
- Docker: A containerization platform for packaging the application and its dependencies.
To start the Stats API, use the following command:
- Build the docker image
$ docker build -t statsapi .
- Run the app with docker-compose
$ docker-compose up -d
The API will be accessible at http://0.0.0.0:80.
Swagger UI (API documentation): Visit http://0.0.0.0:80/docs to interact with the API using the Swagger UI. It provides a user-friendly interface to explore and test the available endpoints.
OR
ReDoc (API documentation): Alternatively, you can access the API documentation using the ReDoc UI at http://0.0.0.0:80/redoc. ReDoc provides a clean and simple interface to view and understand the API specification.
To run the tests for the Stats API, use the following command:
- (Optionnal) Set up a virtual environment
$ python3 -m venv venv
$ source venv/bin/activate
- Install all the required dependencies
$ pip install -r requirements.txt
$ pip install -r requirements-dev.txt
- Run the tests
$ pytest
The tests will be executed, and the results will be displayed in the console.
This project is licensed under the MIT License.