A modern, production-ready template for building web applications with FastAPI backend and Tailwind CSS + DaisyUI frontend.
- FastAPI Backend: Modern Python web framework with automatic OpenAPI documentation
- Tailwind CSS: Utility-first CSS framework for rapid UI development
- DaisyUI: Component library built on Tailwind CSS
- Custom Dark Theme: Professional dark theme with custom color scheme
- Jinja2 Templates: Server-side rendering with component-based architecture
- Docker Support: Containerized deployment with multi-stage builds
- uv Package Manager: Fast Python package management
- Modular Architecture: Clean separation of concerns with organized project structure
βββ app/ # FastAPI application
β βββ api/ # API routes
β βββ core/ # Core configuration and settings
β βββ models/ # Database models
β βββ schemas/ # Pydantic schemas
β βββ services/ # Business logic
β βββ views/ # Frontend view controllers
β βββ main.py # FastAPI app entry point
βββ frontend/ # Frontend assets and templates
β βββ static/ # Static files (CSS, JS, images)
β β βββ css/ # Tailwind CSS files
β β βββ js/ # JavaScript files
β β βββ images/ # Image assets
β βββ templates/ # Jinja2 templates
β βββ components/ # Reusable components
β βββ pages/ # Page templates
β βββ base.html # Base template
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker image configuration
βββ pyproject.toml # Python project configuration
βββ Makefile # Development commands
- Python 3.13+
- Node.js 18+
- uv (Python package manager)
- Docker (optional, for containerized deployment)
git clone <your-repo-url>
cd <your-project-name>
# Install Python dependencies
uv sync
# Start the FastAPI development server
uv run fastapi dev --host 0.0.0.0 --port 8000
The backend will be available at http://localhost:8000
# Navigate to frontend directory
cd frontend
# Install Node.js dependencies
npm install
# Start Tailwind CSS watch mode
npm run dev
This will watch for changes in your CSS and automatically rebuild the output CSS file.
# Build and start the application
docker compose up --build
# Or use the Makefile
make run-docker
The application will be available at http://localhost:8000
The Tailwind CSS configuration is located in frontend/static/css/input.css
. The template includes:
- Custom DaisyUI Theme: A professional dark theme called "broadcast-pro"
- Google Fonts: PT Sans font family
- Custom Color Scheme: Dark backgrounds with electric blue accents
To customize the theme, modify the @plugin "daisyui/theme"
section in input.css
.
- Create a new template in
frontend/templates/pages/
- Add a new route in
app/views/
or create a new router file - Include the router in
app/main.py
Example:
# app/views/about.py
from fastapi import APIRouter, Request
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse
from app.core import settings
router = APIRouter()
templates = Jinja2Templates(directory=settings.TEMPLATES_DIR)
@router.get('/about', response_class=HTMLResponse)
def about(request: Request):
return templates.TemplateResponse(
'pages/about.html',
{
'title': 'About',
'request': request,
}
)
Create reusable components in frontend/templates/components/
and include them in your pages:
<!-- frontend/templates/components/my-component.html -->
<div class="my-component">
<!-- Component content -->
</div>
<!-- Usage in pages -->
{% include 'components/my-component.html' %}
The project includes a Makefile with common development commands:
# Start development server with uv
make run-uv
# Start with Docker
make run-docker
# Stop Docker containers
make down-docker
# Clean cache files
make clean
# Watch mode for development
npm run dev
# Build for production
npm run build
The project includes a multi-stage Dockerfile optimized for production:
- Builder Stage: Installs dependencies and builds the application
- Runtime Stage: Minimal image with only the application and runtime dependencies
Configure the application using environment variables:
PROJECT_NAME
: Application name (default: "FastAPI Project")LOG_LEVEL
: Logging level (default: "INFO")BACKEND_CORS_ORIGINS
: List of allowed CORS origins
Create a .env
file in the project root:
PROJECT_NAME=My Awesome App
LOG_LEVEL=DEBUG
BACKEND_CORS_ORIGINS=["http://localhost:3000", "https://myapp.com"]
FastAPI automatically generates interactive API documentation:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
- OpenAPI JSON:
http://localhost:8000/openapi.json
- Click "Use this template" button on the GitHub repository page
- Create your new repository with your desired name
- Clone your new repository:
git clone https://github.com/yourusername/your-new-project.git cd your-new-project
-
Clone this template:
git clone https://github.com/original-owner/fastapi-tailwind-template.git cd fastapi-tailwind-template
-
Remove the original git history:
rm -rf .git git init
-
Create your own repository on GitHub and add it as origin:
git remote add origin https://github.com/yourusername/your-new-project.git
-
Make your initial commit:
git add . git commit -m "Initial commit from template" git branch -M main git push -u origin main
-
Update project configuration:
- Edit
pyproject.toml
to change the project name and description - Update
app/core/config.py
to set yourPROJECT_NAME
- Modify the custom theme in
frontend/static/css/input.css
if desired
- Edit
-
Follow the Quick Start guide above to run your new project
-
Build the Docker image:
docker build -t my-app .
-
Run the container:
docker run -p 8000:8000 my-app
-
Or use Docker Compose:
docker compose up --build
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Modern web framework for Python
- Tailwind CSS - Utility-first CSS framework
- DaisyUI - Component library for Tailwind CSS
- uv - Fast Python package manager
Happy coding! π