Captures user feedback on the platform
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Any editor of your choice can be used for this application.
-
This project has been built with Python 3.8. Ensure that you install this version of Python as outlined in the link provided here
-
This is a package manager for Python applications and will be useful when handling dependencies for this application. Installations instructions can be found in the link int the title.
-
An awesome dependency management tool for Python and is highly recommended. This is the preferred tool of choice for this project. This allows use to separate between dev dependencies and dependencies
-
This will be used when containerizing the application for running in a SOA(Service Oriented Architecture). This is used especially when deployment. Allows this application to run in any environment with minimal configuration.
First of, create a .env file from .env.skel which will contain environment variables for
configurations. This file is not checked into VCS(Version Control System).
Typically Application port will be set to a default of 8000, but if you prefer a different port to use, you can set that in the environment variable
You will first need to install the dependencies as specified in the pyproject file by running:
uv venvThis creates a virtual environment at the directory .venv.
Then run the below command
uv pip install -r pyproject.tomlOr
make installThis is a convenience wrapper around
uv install -r pyproject.tomlcommand
The Makefile contains commands that are used in the project. You can run make help to view a list of all the possible commands
In order to run the application, we need to first run docker containers specified in the docker compose file. This specifies services that are used by the application while it runs such as:
To get more details about the architecture of the project, consult the documentation as specified here.
Steps to run the project include:
-
Start by first running the docker containers of the above services
These services have been split into different profiles as stated in the doc here. In order to run all the services at once, one can use make to conveniently run all the services:
make start-docker
-
Next, run migration script to setup the database schema:
make migrateUp
-
Next, run the application with:
make run
Or
make run-reload
Runs the application watching for changes in the app directory
To run the application in a docker container use the below commands:
docker build -t <NAME_OF_IMAGE>:<VERSION> .
OR
docker build -t <NAME_OF_IMAGE>:<VERSION> -f Dockerfile
Or you can use the make command to build the image:
make buildDockerImageThis by default with tag the image to
latestand will default the image name tofeedback-serviceunless specified
First build the image and tag it with a name, the suffix is optional, notice the dot (.)
Then now you can run the application in the container and expose ports to the host
docker run -it -p <HOST_PORT>:8000 <NAME_OF_IMAGE>
Or using make
make runDockerContainerRun the application container binding the container port to a host port.
The host port can be whatever you like as long as it is not a reserved host port (e.g, running linux services, if on Linux). However, the container port (8000) is a must as the container exposes that port (This can be changed from the Dockerfile)
Ideally, this will be a representation of what will run in production in a single container(pod) in a kubernetes cluster.
The application tests can be found here split into sub folders for unit tests, integration tests and end-to-end tests. These tests can be run like below:
make test-unitRuns unit tests
make test-integrationRuns integration tests
make test-e2eRuns end-to-end tests Note, that running e2e tests is a little more complicated, as it involves spinning up docker containers, This is documented in the testing doc
make testRuns all the tests
API Documentation is generated with OpenAPI and can be accessed on the URL http://127.0.0.1:8000/docs while running the application locally.
This application has been built with the following tools:
- Python +3.10. Programming Language
- FastAPI. Web framework
- tenacity. Retrying library