To use this template, rename all mentions of "jardinier" in the filenames and file content with the codename of your project.
HTTP Web Backend using the following technologies:
- Python 3.11+
- Poetry to manage Python Virtual Environment and dependencies.
- Docker to manage deployment in production and database in development.
- Postgresql as database choice.
- SQLAlchemy as ORM (Object Relational Mapper) library.
- Alembic to manage database migrations.
- Strawberry as GraphQL API Framework.
- FastAPI as Asynchronous Web Framework.
- Uvicorn as Asynchronous Web Server.
- Pytest as Test Framework.
- Sphinx to generate documentation from codebase.
Single Page App frontend using the following technologies:
You first need to create 2 configuration files:
- Create ./docker/docker.env file with as structure similar to ./docker/docker.example.env
- Create ./jardinier-backend/src/settings.ini file with a structure similar to ./jardinier-backend/src/settings.example.ini
If everything is properly setup (configuration files), its only a git pull and restart:
rsync -avz --stats --delete ~/dev/jardinier/ philaeux@192.168.0.35:~/jardinier cd docker git pull docker compose --env-file docker.env build docker compose --env-file docker.env up --build -d
If you wish to use a postgresql database similar to production in dev, use the .dev compose file:
# Starts a PostgreSQL similar to prod cd docker docker compose -f docker-compose.dev.yaml --env-file docker.env up # Optional, make a backup of production database and use it as a snapshot for dev purposes # On server: sudo rsync -av --no-perms --delete --chown=$(whoami) ../jardinier_postgres_data/ ~/jardinier_postgres_save sudo chown -R $(whoami):$(whoami) ../jardinier_postgres_save # On machine: sudo rsync -avz --stats --delete $(whoami)@<server>:~/jardinier_postgres_save/ ../jardinier_postgres_data # On server: sudo rm -rf ~/jardinier_postgres_save
To run the backend, using poetry:
# Make sure you have poetry python -m pip install pipx python -m pipx install poetry # Install dependencies cd jardinier-backend poetry install --with docs,tests # Run tests cd src poetry run pytest # Get information about the virtual environment (to setup in your ide) poetry env info # Run cd src poetry run python main.py # Generate documentation cd docs poetry run sphinx-build . _build # If you want to remove your venv associated poetry env remove python
To generate a new database migration, use alembic:
poetry run alembic revision --autogenerate
Before using the frontend, make sure you have nvm installed. To run the frontend, using node:
# Check that nvm is ready to be used: nvm version # Install a running version of node: nvm install lts # Set the installed version as the one to use: nvm use lts # Check that node is ready to be used node --version npm --version # Install angular global library: npm install -g @angular/cli # Install frontend libraries cd jardinier-frontend npm install # Start the project: ng serve