Skip to content

Philaeux/templates-fullstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fullstack Website Template - Angular Frontend, Python FastAPI Backend

To use this template, rename all mentions of "templates" in the filenames and file content with the codename of your project.

Backend

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.

Frontend

Single Page App frontend using the following technologies:

Setup

You first need to create 2 configuration files:

  • Create ./docker/docker.env file with as structure similar to ./docker/docker.example.env
  • Create ./templates-backend/src/settings.ini file with a structure similar to ./templates-backend/src/settings.example.ini

Production

If everything is properly setup (configuration files), its only a git pull and restart:

cd docker
git pull
docker compose --env-file docker.env build
docker compose --env-file docker.env up --build -d

Development

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) ../templates_postgres_data/ ~/templates_postgres_save
sudo chown -R $(whoami):$(whoami) ../templates_postgres_save
# On machine:
sudo rsync -avz --stats --delete $(whoami)@<server>:~/templates_postgres_save/ ../templates_postgres_data
# On server:
sudo rm -rf ~/templates_postgres_save

To run the backend, using uv:

# Make sure you have uv
uv run main.py
# Run tests
uv run pytest
# Generate documentation
cd docs
uv run sphinx-build . _build

To generate a new database migration, use alembic:

uv 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 templates-frontend
npm install
# Start the project:
ng serve

About

Template repository with Python fastapi (backend) and Angular (frontend).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published