A modern, full-stack web application template featuring FastAPI backend with database independence and React frontend with complete authentication system.
fastapi-react-vibe-coding-template/
โโโ ๐ backend/ # FastAPI backend
โ โโโ ๐ src/backend/ # Source code
โ โ โโโ ๐ services/ # Feature-based services
โ โ โ โโโ ๐ auth/ # Authentication (FastAPI-Users)
โ โ โ โโโ ๐ users/ # User management
โ โ โ โโโ ๐ email/ # Email verification service
โ โ โ โโโ ๐ example_service/ # Example service template
โ โ โโโ ๐ app.py # FastAPI app setup
โ โ โโโ ๐ db.py # Database configuration (SQLite/PostgreSQL)
โ โ โโโ ๐ main.py # Application entry point
โ โ โโโ ๐ settings.py # Configuration settings
โ โโโ ๐ migrations/ # Alembic database migrations
โ โโโ ๐ tests/ # Comprehensive test suite
โ โโโ ๐ pyproject.toml # Python dependencies (uv)
โ โโโ ๐ README.md # Backend documentation & contributing guide
โ โโโ ๐ Dockerfile # Backend container
โโโ ๐ frontend/ # React frontend with auth components
โ โโโ ๐ src/ # Frontend source code
โ โ โโโ ๐ components/ # React components (auth, UI)
โ โ โโโ ๐ contexts/ # React contexts (Auth)
โ โ โโโ ๐ lib/ # Utilities (API client)
โ โโโ ๐ README.md # Frontend documentation
โ โโโ ๐ package.json # Node.js dependencies
โโโ ๐ agent/ # AI assistant documentation
โ โโโ ๐ CURRENT_TASK.md # Current project status & ongoing work
โ โโโ ๐ CODEBASE.md # Technical implementation details
โ โโโ ๐ SCRATCHPAD.md # Development insights & discoveries
โโโ ๐ docker-compose.yml # Multi-service setup
โโโ ๐ env.example # Environment template
โโโ ๐ env.local.example # Local development template
โโโ ๐ env.production.example # Production template
โโโ ๐ README.md # This file - Complete project guide
Prerequisites: Python 3.12+, Node.js 18+, uv
# 1. Clone and setup
git clone <your-repo-url>
cd fastapi-react-vibe-coding-template
cp env.local.example .env # Use SQLite by default
# 2. Backend setup
cd backend
uv sync && uv run alembic upgrade head && uv run backend &
# 3. Frontend setup (new terminal)
cd frontend
npm install && npm run dev
# 4. Open in browser
open http://localhost:5173
๐ That's it! You now have a fully functional FastAPI-React application with authentication.
Choose your setup based on your needs:
cp env.local.example .env
# Edit .env if needed - defaults are fine for development
cp env.example .env
# Edit .env to configure PostgreSQL settings
docker-compose up -d db # Start PostgreSQL
cp env.production.example .env
# Configure production settings including:
# - Strong SECRET_KEY (32+ characters)
# - Secure admin password
# - Production database credentials
# - Email provider settings (Resend/Gmail)
# - Domain configuration for same-domain deployment
cd backend
uv sync # Install dependencies
uv run alembic upgrade head # Run database migrations
uv run backend # Start the backend server
Available at:
http://localhost:8000
http://localhost:8000/docs
http://localhost:8000/redoc
cd frontend
npm install # Install dependencies
npm run dev # Start the development server
Available at:
http://localhost:5173
This template supports seamless switching between databases:
Configuration:
DATABASE_TYPE=sqlite
SQLITE_DB_PATH=./data/app.db
Configuration:
DATABASE_TYPE=postgresql
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=secret
# 1. Update DATABASE_TYPE in your .env file
# 2. Configure the appropriate database settings
# 3. Run migrations
cd backend && uv run alembic upgrade head
# 4. Restart the application
# Start MailHog for email testing
docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog
# Environment configuration
EMAIL_PROVIDER=mailhog
MAIL_PORT=1025
MAIL_SERVER=localhost
Access email interface at http://localhost:8025
EMAIL_PROVIDER=resend
RESEND_API_KEY=your-resend-api-key
[email protected]
MAIL_FROM_NAME=Your App Name
EMAIL_PROVIDER=gmail
[email protected]
MAIL_PASSWORD=your-app-password
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_STARTTLS=true
cd backend
uv run pytest # Run all tests
uv run pytest -v # Verbose output
uv run pytest --cov # With coverage report
uv run pytest tests/test_auth.py # Specific test file
Test Coverage Includes:
cd frontend
npm run type-check # TypeScript compilation
npm run lint # ESLint checks
npm run lint -- --fix # Fix linting issues
# Start entire stack
docker-compose up -d
# Stop all services
docker-compose down
# Stop and remove volumes
docker-compose down -v
docker-compose up -d db # Database only
docker-compose up -d backend # Backend only
docker-compose up -d frontend # Frontend only
# Start PostgreSQL container manually
docker run --name local-postgres \
-e POSTGRES_DB=db \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=secret \
-p 5432:5432 \
-v pgdata:/var/lib/postgresql/data \
-d postgres
# Access PostgreSQL
docker exec -it local-postgres psql -U postgres -d db
# Check connection
docker exec -it local-postgres pg_isready -U postgres
cd backend
# Dependencies
uv sync # Install/update dependencies
uv add package-name # Add new dependency
uv add --dev package-name # Add dev dependency
# Database migrations
uv run alembic revision --autogenerate -m "Description"
uv run alembic upgrade head # Apply migrations
uv run alembic downgrade -1 # Rollback one migration
uv run alembic history # View migration history
# Development server
uv run backend # Start server
uv run uvicorn backend.main:app --reload --log-level debug # Debug mode
# Testing
uv run pytest # All tests
uv run pytest --cov --cov-report=html # With HTML coverage
uv run pytest -x # Stop on first failure
cd frontend
# Dependencies
npm install # Install dependencies
npm install package-name # Add dependency
npm install --save-dev package-name # Add dev dependency
# Development
npm run dev # Start dev server
npm run build # Production build
npm run preview # Preview production build
# Quality checks
npm run type-check # TypeScript check
npm run lint # ESLint
npm outdated # Check for updates
# Clear caches
rm -rf backend/.venv
rm -rf frontend/node_modules frontend/package-lock.json
rm -rf frontend/.vite
# Reset database (development only)
rm -rf backend/migrations/versions/*.py
cd backend && uv run alembic stamp head
cd backend && uv run alembic revision --autogenerate -m "Initial"
cd backend && uv run alembic upgrade head
# Test connectivity
curl http://localhost:8000/health # Backend health
curl http://localhost:5173/api/health # Frontend proxy
env.production.example
)npm run build
)# Environment setup
cp env.production.example .env
# Edit .env with production values
# Generate secure secret key
python -c "import secrets; print('SECRET_KEY=' + secrets.token_urlsafe(32))"
# Backend Docker build
cd backend && docker build -t fastapi-backend .
# Frontend production build
cd frontend && npm run build
# Apply migrations
cd backend && uv run alembic upgrade head
ENVIRONMENT=local
DATABASE_TYPE=sqlite
BACKEND_HOST=localhost
BACKEND_PORT=8000
FRONTEND_HOST=localhost
FRONTEND_PORT=5173
EMAIL_PROVIDER=mailhog
ENVIRONMENT=prod
DATABASE_TYPE=postgresql
DOMAIN=yourdomain.com
BACKEND_PATH=/api
FRONTEND_PATH=
USE_SSL=true
EMAIL_PROVIDER=resend
Database Connection Failed
# Check if PostgreSQL is running
docker ps | grep postgres
docker exec -it local-postgres pg_isready -U postgres
# Check SQLite permissions
mkdir -p ./data && chmod 755 ./data
Migration Errors
# Reset migrations (development only)
rm migrations/versions/*.py
uv run alembic stamp head
uv run alembic revision --autogenerate -m "Initial migration"
uv run alembic upgrade head
Import/Module Errors
# Reinstall dependencies
rm -rf .venv
uv sync
API Connection Failed
# Check backend is running
curl http://localhost:8000/health
# Verify Vite proxy configuration in vite.config.ts
# Ensure proxy target matches backend port
Build Errors
# Clear TypeScript cache
rm -rf node_modules/.cache
npm run type-check
# Clear and reinstall
rm -rf node_modules package-lock.json
npm install
Authentication Issues
# Clear browser storage
# Open Dev Tools โ Application โ Local Storage โ Clear
# Check JWT token format in localStorage
# Verify backend auth endpoints are working
Backend Slow
# Check database connections
# Review SQLAlchemy query performance
# Enable debug logging: --log-level debug
Frontend Slow
# Clear Vite cache
rm -rf .vite node_modules/.vite
npm run dev
# Check bundle size
npm run build && ls -la dist/
We welcome contributions! Here's how to get started:
git checkout -b feature/your-feature-name
cd backend && uv run pytest
cd frontend && npm run type-check && npm run lint
cd backend && uv run alembic revision --autogenerate -m "Description"
uv run pytest
and npm run type-check
)npm run lint
)src/backend/services/
src/components/
with clear namingtests/
directory๐ Happy coding! This template provides a solid foundation for building modern web applications with FastAPI and React.
๐ Documentation: This README contains all essential information for human developers. AI agents should refer to files in the
agent/
directory for technical implementation details.