- Clone the repository to a local machine
- From ./bloomreach_interview/api directory
- execute
pip install -r requirements.txt
- run
main.py
or executeuvicorn main:app
- Clone the repository to a local machine
- From ./bloomreach_interview/api directory
- Execute commands:
docker build -t bloomreach_api .
docker run -p 8000:8000 --name bloomreach_api bloomreach_api
This will also start Prometheus and Grafana services
- Clone the repository to a local machine
- Execute command:
docker-compose up
Send an HTTP GET request to endpoint
- For accessing OpenApi documentation:
localhost:8000/
- JSON OpenApi endpoint:
localhost:8000/openapi.json
- FastAPI metrics endpoint:
localhost:8000/metrics
- Prometheus endpoint:
localhost:9090
- Grafana Endpoint:
localhost:3000
- To configure the server check the docker-compose.yml file and set the environmental variables to your liking. If you don't want to use docker compose, you can change the default variables in the config.py directly
- To configure Grafana credentials check env.example file and rename it to env. You can also modify dashboard with dashbords/fastapi-dashboard.json
- To configure Prometheus check datasource.yml
There is a script for creating ec2 t2.micro server on AWS, and installing all the packages needed to run this app with docker-compose. All the commands for executing this are listed below:
terraform init
terraform validate
terraform plan
terraform apply
Responsible file - init.tf, and instructions.sh for bash initialization script
- Python 3.10
- FastAPI framework
- Various libraries for python: httpx, asyncio, pytest, prometheus-fastapi-instrumentator, uvicorn
- Prometheus image for monitoring the system
- Grafana for analytics and dashboards
- Terraform for quicker deployment on dev servers in the cloud
- Docker with docker-compose plugin for containerization and deployment
- GitHub as repository host
Logs can be checked in the shell where you ran the app, or in api.log file with better formatting.
To set log-level check LOGLEVEL variable in config.py file.
Testing was done using jMeter with plugins for Transactions per Second and Requests per Second metrics.
I regret not having more time to add unit and integration testing for the project. I would have added various tests covering smart endpoint and it's behaviour in different circumstances, such as low/high timeout parameter values, simulating low system resources avaliability, etc.