A modern full-stack application template featuring:
Clone the repository
git clone https://github.com/stedonnelly/svelteapp-fastapi-template.git
cd svelteapp-fastapi-template
Start the development environment
docker compose -f docker-compose.dev.yaml up
This will:
543280005173Access the application
The project uses .env.dev for development configuration. Key variables include:
POSTGRES_USER: Database username (default: postgres)POSTGRES_PASSWORD: Database password (default: postgres)POSTGRES_DB: Database name (default: app_db)POSTGRES_HOST: Database host (default: db for Docker)SECRET_KEY: Secret key for sessions (change in production!)ALLOWED_ORIGINS: CORS allowed originsSECURE_COOKIES: Set to true in productionSESSION_MAX_AGE_SECONDS: Session duration (default: 7 days)PUBLIC_API_BASE_URL: Backend API URL (default: http://localhost:8000/api/v1)PUBLIC_APP_NAME: Application nameBoth frontend and backend support hot reload:
backend/app/ are automatically reloadedweb/src/ trigger instant updates in the browserMigrations run automatically on container startup, but you can run them manually:
# Create a new migration
docker compose -f docker-compose.dev.yaml exec backend alembic revision --autogenerate -m "Description"
# Apply migrations
docker compose -f docker-compose.dev.yaml exec backend alembic upgrade head
# Rollback one migration
docker compose -f docker-compose.dev.yaml exec backend alembic downgrade -1
GET /api/v1/health/healthz - Health check endpointPOST /api/v1/auth/login - User loginPOST /api/v1/auth/logout - User logoutGET /api/v1/auth/me - Get current userGET /api/v1/users/ - List users (authenticated)POST /api/v1/users/ - Create userGET /api/v1/users/{id} - Get user by ID# Stop containers (keeps data)
docker compose -f docker-compose.dev.yaml down
# Stop and remove volumes (deletes database data)
docker compose -f docker-compose.dev.yaml down -v
If ports 5432, 8000, or 5173 are already in use, you can either:
docker-compose.dev.yamlEnsure the database container is healthy:
docker compose -f docker-compose.dev.yaml ps
Check backend logs:
docker compose -f docker-compose.dev.yaml logs backend
Check if node_modules are properly installed:
docker compose -f docker-compose.dev.yaml exec web npm ci
Before deploying to production:
Generate a secure SECRET_KEY:
python -c "import secrets; print(secrets.token_urlsafe(32))"
Update environment variables:
ENV=productionSECURE_COOKIES=trueALLOWED_ORIGINS to your production domainConsider creating a separate docker-compose.prod.yaml with:
This project is licensed under the MIT License - see the LICENSE file for details.
The pre-commit CI was adapted from the Alan Turing Institute's Python Project Template repo.