This repository contains a little demonstration. It contains an api-server that handles employee working time data. To run this you need python>=3.13
First clone the repo
git clone https://github.com/MarcBrueck/time_tracking.gitIf you dont have uv installed, you can install it using pip:
pip install uvThen create a virtual environment and install the dependencies using uv.
uv syncThen activate the virtual environment:
source .venv/bin/activateCreate a .env file for storing the env variables outside of git
touch .envand then add the necessary env variables, here we only need the database connection. Here I decided to use sqlite, because it is the easiest to set up, It can be easily switched to a any of the rdbms like postgres, since we are using sqlalchemy.
CONNECTION_STRING="sqlite:///time_tracking.db"You can run the api server using:
uvicorn time_tracking.main:app --host 127.0.0.1 --port 8000Then you can see the swagger UI listing the api documentation here:
http://127.0.0.1:8000/docsThere you can see all the endpoints and paths for example
curl -X 'GET' \
'http://127.0.0.1:8000/employees/' \
-H 'accept: application/json'to fetch all employee data
There is also a script that fills the database with some random data:
python scripts/fill_database.pyFirst build the image
docker build -t time_tracking:v1 .and then run it
docker run -p 8000:8000 -e CONNECTION_STRING="sqlite:///time_tracking.db" time_tracking:v1pytest