The README is auto generated by an AI
Before starting, create a .env file in the root folder. You can find the required environment variables in env_example.txt and modify them as needed.
To start the app for the first time, run the following command in the root folder:
docker-compose up --buildAdding initial values to your database can be done from the commands/seeding section. By executing these commands you can insert pre defined values to your tables when needed.
If you need to to execute multiple seeding steps when running your application for the first time, the run-init-seeders.sh script can be utilized. Follow as started by adding new seeding steps. To execute the script itself just run bash ./scripts/run-init-seeders.sh command from the project root. If you are using windows you will need to do this from the wsl/bash terminal instead from cmd/powershell.
OpenAPI docs are available when the server is started, they can be viewed my going to http://localhost:5000/ in your browser.
The docs should be updated by following the current setup in the schemas folder.
Note: For any docker exec command to run, ensure the Docker container is up and running.
-
Create a migration:
docker exec backend flask db:create-migration --name <migration_name>
-
Run migrations:
docker exec backend flask db:migrate [--single] -
Rollback migrations:
docker exec backend flask db:rollback [--steps <n>]
-
Check migration status:
docker exec backend flask db:migrate-status
- Pull the latest code.
- Run migrations to ensure the database schema is up to date.
- Backend developers create, test, and push migration files. These changes are included in pull requests.
- On production, migrations are applied automatically after code deployment.
-
Bring down services:
docker-compose down
-
Remove old database volume:
docker volume rm development_postgresdata
-
Delete old migration files:
sudo rm -rf migrations
-
Pull the latest code and bring up services:
git pull origin develop && docker-compose up -d --build -
Run migrations:
docker exec backend flask db:migrate
- Models: Use
BaseModelas a parent class for all database models (e.g.,UserProfile). - Tasks: Asynchronous tasks are located in the
tasksfolder. These tasks are run using Celery, with Redis as the broker. - Validators: Use
BaseValidatoras a parent class for new validators. - Config: The
BaseConfigis extended byAppConfig. Follow this structure for any new configurations. - Logging: All logging is configured in the
logsfolder. Adjust the logger setup to add new workflows if needed. - Commands: Backend testing commands such as health checks and migrations are in the
commandsfolder. - Storage: Temporary storage for user files is in the
storagefolder.
Whenever you modify the database (e.g., adding, editing, or removing a model), create a new migration using the steps above to keep the database schema up to date.
Once the app is running, the backend will be available at localhost:5000.