The project is structured with two different modules, the server
and the client.
The server is built with FastAPI
and exposes one single endpoint greet/
that accepts a POST
request with a JSON payload.
The logic of this service is under src/services/srv_b
to be able to abstract the logic
of the service from the server itself.
Same for the client, the logic of the this service is under src/services/srv_a
alongside with
an HTTPClient
to abstract the logic of the client from the main file.
The entrypoint for the client service is at
src/client.py
- and the entrypoint for the server service is at
src/server.py
To automate the whole process of installing the project and its dependencies, the project list
the python dependencies in the pyproject.toml
file and a MakeFile
to automate the process.
The requirements are poetry
, make
and pyenv
to manage the python version.
Otherwise, you can install the dependencies manually with min requirement
python = ">=3.11,<3.13"
python -m venv .env
source .env/bin/activate
pip install -r requirements.txt
or
make setup-local-dev
Start the server by running the following command in the terminal
uvicorn src.main:app --reload
In a separate terminal, run the following command to test the server, by default the client will send 10 requests to the server, you can change the number of requests by changing the argument.
python -m src.client 30
To run the test cases, run the following command in the terminal
make test-local
- Refactor all constants to a single
config
usingpydantic settings
to manage the configuration of the server and the client using environment variables. - Add a
Dockerfile
to containerize the server and the client.