Team assignments app is a FastAPI-based web application that uses a PostgreSQL database for data storage. It allows to assign teams to experiment.
Follow these steps to set up and run app with Docker
To run this app, you will need to install Docker and Docker Compose.
Install Docker Desktop for your OS https://www.docker.com/products/docker-desktop/
Follow the installation instructions and start Docker Desktop.
Clone the repository to your local machine:
git clone https://github.com/drezi29/teams-assignment.git
cd team-assignmentCreate a .env file in the project root and add the following:
DATABASE_URL=postgresql://fastapiapp:fastapiapp@db:5432/fastapiapp_db
TEST_DATABASE_URL = "postgresql://fastapiapp:fastapiapp@db:5432/fastapiapp_test"
POSTGRES_USER=fastapiapp
POSTGRES_PASSWORD=fastapiapp
POSTGRES_DB=fastapiapp_db
Use Docker Compose to build the Docker images and run the containers:
docker-compose up --buildNow, you should be able to access the application by navigating to http://localhost:8000 in your web browser.
If you need to stop the containers, you can use the following command:
docker-compose downThis command will stop and remove the containers, but the data in the PostgreSQL volume will persist. If you want to remove the volumes as well (e.g., to start fresh), you can use this command insted above one:
docker-compose down -vFollow these steps to set up and run app locally
Create a new virtual environment using Python 3.10:
python3.10 -m venv venv/Activate the newly created virtual environment:
source venv/bin/activateUpgrade pip to the latest version:
pip install --upgrade pipInstall the required Python packages:
pip install -r requirements.txtInstall and start PostgreSQL version 14 in your operating system.
For Mac:
- Install using Homebrew:
brew install postgresql@14- Start the PostgreSQL service:
brew services start postgresqlFor Windows:
- Download PostgreSQL Installer:
Go to the official PostgreSQL download page [https://www.postgresql.org/download/windows/] and download the installer for your version of Windows.
- Run the Installer:
Follow the prompts in the installer. It will guide you through the installation process, including setting up a database superuser and a password.
- Start PostgreSQL Service:
Press Win + R to open the Run dialog. Type services.msc and press Enter. Look for "PostgreSQL" in the list of services and ensure it is running.
Open the PostgreSQL shell:
psql postgresThen, create a new role named fastapiapp with login privileges and a password of fastapiapp and create
CREATE ROLE fastapiapp WITH LOGIN PASSWORD 'fastapiapp';
ALTER ROLE fastapiapp CREATEDB;
CREATE DATABASE fastapiapp_db;
GRANT ALL PRIVILEGES ON DATABASE fastapiapp_db TO fastapiapp;
ALTER DATABASE fastapiapp_db OWNER TO fastapiapp;Create a .env file in the project root and add the following: DATABASE_URL=postgresql://fastapiapp:fastapiapp@localhost/fastapiapp_db
Start the FastAPI development server:
uvicorn src.main:app --reloadNow, you should be able to access the app application by navigating to http://localhost:8000 in your web browser.