A modern full-stack web application template featuring Next.js (React) frontend and FastAPI (Python) backend, with Firebase/Firestore integration and a working email waitlist example.
If you're using Claude (claude.ai/code), here's the fastest way to get started:
# 1. Clone and setup your new project
git clone https://github.com/sunholo-data/nextjs-fastapi-bootstrap.git my-awesome-app
cd my-awesome-app
rm -rf .git && git init # Start fresh git history
# 2. Tell Claude to set up the project
# Just say: "Please set up this project for local development"
# Claude will:
# - Install all dependencies
# - Copy .env.example files
# - Help you configure Firebase
# - Start both frontend and backend
# 3. Start building!
# Say: "Help me create a new API endpoint for [your feature]"
# Or: "Add a new page for [your feature]"When working with Claude, you can use these helpful prompts:
- "Set up the project" - Claude will handle all initialization
- "Run all tests" - Claude will run both frontend and backend tests
- "Add a new feature for X" - Claude will create endpoints, pages, and tests
- "Deploy to Google Cloud Run" - Claude will guide you through deployment
- "Fix any linting errors" - Claude will clean up code formatting
The CLAUDE.md file contains detailed instructions that help Claude understand the codebase structure and best practices.
- Frontend: Next.js 14 with App Router, TypeScript, Tailwind CSS
- Backend: FastAPI with Python 3.11+, async/await support
- Database: Firebase/Firestore for NoSQL data storage
- Authentication: Google OAuth 2.0 integration (optional)
- Email: Mailgun integration for transactional emails
- Testing: Vitest (frontend) and Pytest (backend)
- Deployment: Google Cloud Run with Cloud Build CI/CD
- Development: Hot reload, type safety, linting, and formatting
- Node.js 18+
- Python 3.11+
- uv (Python package manager)
- Google Cloud account (for Firebase/Firestore)
cd backend
# Copy environment variables
cp .env.example .env
# Edit .env with your configuration
# Install dependencies
uv sync
# Run development server
uv run uvicorn main:app --reloadBackend will be available at http://localhost:8000
cd frontend
# Copy environment variables
cp .env.example .env
# Edit .env if needed
# Install dependencies
npm install
# Run development server
npm run devFrontend will be available at http://localhost:3000
├── backend/
│ ├── app/
│ │ ├── api/ # API endpoints
│ │ ├── core/ # Core functionality (Firebase, auth)
│ │ ├── schemas/ # Pydantic models
│ │ └── services/ # Business logic
│ ├── tests/ # Backend tests
│ ├── main.py # FastAPI application
│ └── pyproject.toml # Python dependencies
│
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js App Router
│ │ │ ├── api/ # API proxy routes
│ │ │ ├── components/
│ │ │ └── services/ # API client
│ │ └── __tests__/ # Frontend tests
│ ├── package.json # Node dependencies
│ └── next.config.mjs # Next.js configuration
│
└── cloudbuild.yaml # Google Cloud Build configuration
The frontend uses Next.js API routes to proxy requests to the backend, eliminating CORS issues:
// Frontend: /src/app/services/api.ts
fetch('/api/proxy', {
body: JSON.stringify({
endpoint: '/api/waitlist',
email
})
})
// Proxy route forwards to backend
// Backend receives at: http://127.0.0.1:8000/api/waitlistBoth frontend and backend use .env files. Copy .env.example to .env and configure.
npm run dev # Start development server
npm run build # Build for production
npm run lint # Run ESLint
npm run type-check # TypeScript type checking
npm test # Run testsuv run uvicorn main:app --reload # Development server
uv run pytest # Run tests
uv run black . # Format code
uv run mypy . # Type checkingThe template includes a complete test setup:
- Frontend: Vitest with React Testing Library
- Backend: Pytest with async support
Run all tests before committing:
# Frontend
cd frontend && npm test
# Backend
cd backend && uv run pytestThe included cloudbuild.yaml configures Google Cloud Build for automated deployment to Cloud Run.
Prerequisites (if not running on Sunholo Multivac)
- Enable required Google Cloud APIs
- Create service account with proper permissions
- Set up Firebase project
- Configure environment variables in Cloud Run
gcloud builds submit --config=cloudbuild.yaml- Remove Waitlist: Delete waitlist-related files and update routes
- Add Authentication: Uncomment Google OAuth code and configure
- Change Styling: Modify Tailwind configuration and globals.css
- Add Features: Follow the patterns in existing endpoints/components
- Create route in
/backend/app/api/endpoints/ - Add schemas in
/backend/app/schemas/ - Implement service in
/backend/app/services/ - Update frontend API client in
/frontend/src/app/services/api.ts - Write tests for both frontend and backend
- Create component in
/frontend/src/app/[page-name]/page.tsx - Add any needed components
- Connect to API if needed
- Write tests
If you're using Claude for the first time with this template:
-
Clone the repository:
git clone https://github.com/sunholo-data/nextjs-fastapi-bootstrap.git my-project cd my-project -
Open in Claude:
claude my-project
-
Ask Claude to set up the project:
"Please set up this project for local development. I need: 1. All dependencies installed 2. Environment variables configured 3. Firebase project connected (my project ID is: YOUR_PROJECT_ID) 4. Both frontend and backend running" -
Claude will automatically:
- Run
npm installin frontend - Run
uv syncin backend - Copy
.env.examplefiles - Help you configure Firebase
- Start development servers
- Run
# Development
"Start the development servers"
"Run all tests and fix any failures"
"Check for linting errors and fix them"
# Adding Features
"Create a new API endpoint for user profiles with CRUD operations"
"Add a dashboard page that shows user statistics"
"Implement authentication with Google OAuth"
# Database
"Add a new Firestore collection for products"
"Create a data model for blog posts"
# Deployment
"Help me deploy this to Google Cloud Run"
"Set up GitHub Actions for CI/CD"
"Configure environment variables for production"
# Debugging
"Debug why the API call is failing"
"Fix the TypeScript error in [file]"
"Why is my Firebase connection not working?"
-
Be specific: Instead of "add authentication", say "add Google OAuth authentication with a login button on the homepage"
-
Use the todo list: Say "Create a todo list for implementing a shopping cart feature" to help Claude plan complex features
-
Test as you go: After each feature, ask "Run all tests" to ensure nothing breaks
-
Review changes: Say "Show me what files you changed" to understand modifications
-
Use CLAUDE.md: The CLAUDE.md file helps Claude understand the project structure. You can update it with project-specific conventions.
MIT - Use this template for any project!