A production-ready full-stack application template combining Python FastAPI backend with React frontend, designed for rapid development and easy deployment.
- Modern Backend: FastAPI with async support, automatic API documentation, and type hints
- React Frontend: React 18+ with Vite for fast development and optimized builds
- Multi-Database Support: SQLite (default), PostgreSQL, MySQL, and MongoDB
- JWT Authentication: Secure token-based authentication ready to use
- Production Build: Nuitka compilation for standalone executables
- Tailwind CSS: Modern, responsive UI with Tailwind CSS
- Type Safety: Pydantic models for request/response validation
- CORS Configuration: Pre-configured for development and production
- Comprehensive Logging: Structured logging with file and console output
- Docker Support: Containerized deployment ready
- Python: 3.9 or higher
- Node.js: 16.x or higher (for frontend development)
- pnpm: Package manager for frontend dependencies (recommended) or npm/yarn
- PostgreSQL 12+ (if using PostgreSQL)
- MySQL 8+ (if using MySQL)
- MongoDB 4.4+ (if using MongoDB)
git clone https://github.com/skmercur/pyreact-fusion.git
cd pyreact-fusion# Create virtual environment (recommended)
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Linux/Mac:
source venv/bin/activate
# Install Python dependencies
pip install -r requirements.txtcd frontend
pnpm install
cd ..Copy the example environment file and configure it:
# Copy .env.example to .env
cp .env.example .envEdit .env file with your configuration:
ENVIRONMENT=development
DEBUG=true
DATABASE_TYPE=sqlite
JWT_SECRET_KEY=your-secret-key-change-in-productionFirst, run the interactive setup to configure your application:
python scripts/setup.pyThis will guide you through:
- Choosing between Desktop mode (pywebview) or Web mode (browser)
- Setting up your application name, description, and version
- Configuring author information
- Selecting database type
- Configuring server settings
Run the development server:
python scripts/dev.pyOr run the configured application:
python scripts/run.pyThis will start the application in the mode you selected during setup (Desktop or Web).
This will start:
- Backend server at
http://localhost:8000 - API documentation at
http://localhost:8000/api/docs - Frontend development server at
http://localhost:5173(if running separately)
Note: For full development experience, run frontend separately:
# Terminal 1: Backend
python -m uvicorn backend.main:app --reload
# Terminal 2: Frontend
cd frontend
pnpm run devpython scripts/build_frontend.pypython scripts/build_executable.pyThis will:
- Build the React frontend
- Copy assets to backend
- Compile Python backend to standalone executable using Nuitka
The executable will be in the dist/ directory.
pyreact-fusion/
βββ backend/ # Python FastAPI backend
β βββ __init__.py
β βββ main.py # Application entry point
β βββ api/ # API routes and middleware
β β βββ routes.py # API endpoints
β β βββ middleware.py # CORS, auth middleware
β βββ database/ # Database layer
β β βββ connection.py # Database factory
β β βββ models.py # ORM models
β β βββ migrations/ # Database migrations
β βββ services/ # Business logic
β β βββ auth.py # Authentication service
β βββ config.py # Configuration management
βββ frontend/ # React frontend
β βββ public/ # Static assets
β βββ src/ # Source code
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ services/ # API client
β β βββ utils/ # Utility functions
β βββ package.json
β βββ vite.config.js
βββ build_config/ # Build configuration
β βββ nuitka_build.py # Nuitka compilation script
β βββ requirements.txt
βββ config/ # Configuration files
β βββ database.yaml # Database config templates
β βββ app.yaml # Application config
βββ scripts/ # Build and dev scripts
β βββ dev.py # Development server
β βββ build_frontend.py # Frontend build
β βββ build_executable.py # Complete build pipeline
βββ .env.example # Environment variables template
βββ requirements.txt # Python dependencies
βββ README.md # This file
No additional setup required. Database file will be created at ./data/app.db.
- Install PostgreSQL and create a database:
CREATE DATABASE pyreact_fusion;- Update
.env:
DATABASE_TYPE=postgresql
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=pyreact_fusion
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password- Install MySQL and create a database:
CREATE DATABASE pyreact_fusion CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;- Update
.env:
DATABASE_TYPE=mysql
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DB=pyreact_fusion
MYSQL_USER=root
MYSQL_PASSWORD=your_password- Install MongoDB and start the service
- Update
.env:
DATABASE_TYPE=mongodb
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_DB=pyreact_fusion
MONGODB_USER= # Optional
MONGODB_PASSWORD= # OptionalThe template includes JWT-based authentication:
curl -X POST "http://localhost:8000/api/auth/register" \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"email": "test@example.com",
"password": "securepassword",
"full_name": "Test User"
}'curl -X POST "http://localhost:8000/api/auth/login" \
-H "Content-Type: multipart/form-data" \
-F "username=testuser" \
-F "password=securepassword"curl -X GET "http://localhost:8000/api/users" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"GET /api/health- Health checkPOST /api/auth/register- Register new userPOST /api/auth/login- Login and get access token
GET /api/auth/me- Get current user informationGET /api/users- Get list of users
When running in development mode, visit:
- Swagger UI:
http://localhost:8000/api/docs - ReDoc:
http://localhost:8000/api/redoc
pip install nuitka ordered-setpython build_config/nuitka_build.py onefilepython build_config/nuitka_build.py standaloneEdit build_config/nuitka_build.py to customize:
- Included packages
- Data directories
- Plugins
- Output name and location
docker build -t pyreact-fusion .docker run -p 8000:8000 \
-e DATABASE_TYPE=sqlite \
-e JWT_SECRET_KEY=your-secret-key \
pyreact-fusiondocker-compose up -d# Install test dependencies
pip install pytest pytest-asyncio httpx
# Run tests
pytest backend/tests/cd frontend
pnpm testKey environment variables (see .env.example for complete list):
| Variable | Description | Default |
|---|---|---|
ENVIRONMENT |
Environment mode (development/staging/production) | development |
DEBUG |
Enable debug mode | true |
DATABASE_TYPE |
Database type (sqlite/postgresql/mysql/mongodb) | sqlite |
JWT_SECRET_KEY |
Secret key for JWT tokens | (required) |
HOST |
Server host | 0.0.0.0 |
PORT |
Server port | 8000 |
- Set
ENVIRONMENT=productionandDEBUG=false - Change
JWT_SECRET_KEYto a strong random secret - Configure production database
- Set up proper CORS origins
- Configure logging
- Build frontend:
python scripts/build_frontend.py - Test the application
- Set up reverse proxy (nginx/Apache) if needed
- Configure SSL/TLS certificates
# Using uvicorn directly
uvicorn backend.main:app --host 0.0.0.0 --port 8000 --workers 4
# Using the executable
./dist/pyreact-fusionContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Sofiane Khoudour
- GitHub: @skmercur
- Email: khoudoursofiane75@gmail.com
- FastAPI - Modern Python web framework
- React - JavaScript library for building user interfaces
- Vite - Next generation frontend tooling
- Nuitka - Python compiler
- Tailwind CSS - Utility-first CSS framework
- Ensure Node.js 16+ is installed
- Delete
node_modulesandpnpm-lock.yaml, then runpnpm installagain - Check for version conflicts in
package.json
- Verify database service is running
- Check connection credentials in
.env - Ensure database exists (for PostgreSQL/MySQL)
- Check firewall settings
- Ensure all dependencies are installed
- Check Python version (3.9+)
- Try building in standalone mode first
- Check Nuitka documentation for platform-specific issues
- Change
PORTin.envfile - Or stop the process using the port:
- Windows:
netstat -ano | findstr :8000 - Linux/Mac:
lsof -i :8000
- Windows:
Happy Coding! π