A modern, full-featured starter template featuring FastAPI backend and React 19 frontend with TypeScript, Tailwind CSS, and shadcn/ui components.
Backend (FastAPI)
Frontend (React 19)
use
hookfastapi-react-starter/
├── backend/
│ ├── app/
│ │ ├── __init__.py
│ │ ├── main.py # FastAPI application entry
│ │ ├── config/ # Configuration management
│ │ │ ├── __init__.py
│ │ │ └── config.py # Environment settings
│ │ ├── db/ # Database
│ │ │ ├── __init__.py
│ │ │ ├── database.py # Database connection
│ │ │ └── models.py # SQLAlchemy models
│ │ ├── routes/ # API routes
│ │ │ ├── __init__.py
│ │ │ ├── auth.py # Authentication endpoints
│ │ │ └── health.py # Health check endpoint
│ │ ├── schemas/ # Pydantic models
│ │ │ ├── __init__.py
│ │ │ └── auth.py # Authentication schemas
│ │ ├── services/ # Business logic
│ │ │ ├── __init__.py
│ │ │ └── auth.py # Authentication services
│ │ └── utils/ # Utilities
│ │ ├── __init__.py
│ │ └── logger.py # Logging configuration
│ ├── .env # Environment variables
│ └── requirements.txt # Python dependencies
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ │ └── ui/ # shadcn/ui components
│ │ │ ├── button.tsx
│ │ │ ├── card.tsx
│ │ │ └── status-dot.tsx
│ │ ├── features/ # Feature modules
│ │ │ ├── auth/ # Authentication feature
│ │ │ │ ├── LoginForm.tsx
│ │ │ │ └── RegisterForm.tsx
│ │ │ └── health/ # Health check feature
│ │ │ └── HealthStatus.tsx
│ │ ├── hooks/ # Custom React hooks
│ │ │ ├── useAuth.ts
│ │ │ └── useHealthStatus.ts
│ │ ├── layouts/ # Page layouts
│ │ │ └── MainLayout.tsx
│ │ ├── lib/ # Utility functions and configurations
│ │ │ └── utils.ts
│ │ ├── routes/ # Route components and configurations
│ │ │ └── root.tsx
│ │ ├── types/ # TypeScript type definitions
│ │ │ └── index.d.ts
│ │ └── App.tsx # Main React component
│ ├── .env # Frontend environment variables
│ └── package.json # Node.js dependencies
└── README.md # Project documentation
Clone the repository:
git clone https://github.com/raythurman2386/fastapi-react-starter.git
cd fastapi-react-starter
Create environment files:
Create .env
file in the root directory:
# Database Configuration
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=fastapi_db
Start the application with Docker:
docker compose up --build
This will:
The Swagger docs will be available at http://localhost:8000/docs
For your convenience, this project includes automated setup scripts for both Windows and Linux/Mac:
.\setup.ps1
This script will:
chmod +x setup.sh
./setup.sh
This script performs the same setup steps as the Windows version but is adapted for Unix-based systems.
Backend Setup:
a. Install PostgreSQL and create a database:
# macOS with Homebrew
brew install postgresql
brew services start postgresql
# Create database
createdb fastapi_db
b. Create a .env
file in the backend directory:
# Database Configuration
DB_NAME=fastapi_db
DB_USER=postgres # your database user
DB_PASSWORD=postgres # your database password
DB_HOST=localhost
DB_PORT=5432
CORS_ORIGINS=["http://localhost:5173"]
ENVIRONMENT=development
c. Install Python dependencies and run migrations:
cd backend
pip install -r requirements.txt
python manage.py reset_db # This will reset the database and apply migrations
uvicorn app.main:app --reload
Frontend Setup:
cd frontend
npm install
npm run dev
The project includes several database management commands:
# Reset the database (drop, recreate, and apply migrations)
python manage.py reset_db
# Generate new migrations
python manage.py makemigrations "description of changes"
# Apply pending migrations
python manage.py migrate
# Check migration status
python manage.py db_status
# Rollback last migration
python manage.py downgrade
If you encounter database errors:
python manage.py reset_db
or through Docker with docker compose up --build
Backend Status shows "error":
.env
python manage.py reset_db
User Registration fails:
.env
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.