A professional, opinionated boilerplate designed to jumpstart web applications. This repository provides a high-performance starting point by bridging a Django REST Framework backend with a Vite-powered React frontend.
- π Django-React Modern Stack Boilerplate
- Framework: Django 6.x
- API: Django REST Framework (DRF) & drf-spectacular
- Package Manager: Poetry 2.3+
- Admin UI: Django Unfold (Modern Tailwind-based Admin)
- Async Tasks: Celery + Celery Beat
- Testing: Pytest
- Build Tool: Vite
- Library: React
- Styling: Tailwind CSS v4 (Native CSS engine, no
tailwind.config.jsrequired)
.
βββ backend/ # Django Project Root
β βββ core/ # Main Application Domain
β β βββ admin/ # Modular Admin (User, dashboard, celery)
β β βββ api/ # DRF Serializers & ViewSets
β β βββ migrations/ # Database Migrations
β β βββ models/ # Modular Models (Base, User)
β β βββ settings/ # Split Settings (base.py, development.py, production.py)
β β βββ static/ # Global assets
β β βββ templates/ # Base HTML & Vite layouts
β βββ staticfiles/ # Additional static assets
β βββ manage.py # Dynamic manage.py (auto-detects environment)
βββ db/ # SQLite Database directory (auto-generated)
βββ docs/ # Documentation directory
β βββ README.md # The main project documentation
βββ frontend/ # Vite + React Project
β βββ src/
β β βββ index.css # Tailwind v4 @import
β β βββ App.jsx
β βββ vite.config.js # Vite & Tailwind plugin config
βββ scripts/ # DevOps & Cleanup Utilities
β βββ customize.py # Project initialization script
βββ tests/ # Pytest Suite
βββ .env.example # Environment variables template
βββ pyproject.toml # Poetry Configuration & Poe Tasks
βββ LICENSE # Open-source license
Before you begin, ensure you have the following installed on your system:
- Python (>= 3.12)
- Poetry (>= 2.3.x)
- Node.js (>= 20.x) and npm
- Git
Clone the boilerplate repository into your new project directory. Do not run any install commands yet.
git clone [https://github.com/git-evinci/django-react-boilerplate.git](https://github.com/git-evinci/django-react-boilerplate.git) my-new-project
cd my-new-projectRun the initialization script using your system Python. This script automatically rebrands pyproject.toml, the LICENSE, and generates a secure .env file:
python scripts/customize.py(Follow the interactive prompts to set your Project Slug, Author Name, etc.)
Install the Python dependencies using Poetry:
poetry installThe initialization script created a .env file for you based on .env.example. Ensure it looks like this:
DJANGO_ENV=development
PYTHONPATH=./backend
DEBUG=True
SECRET_KEY=<your_auto_generated_50_char_key>
ALLOWED_HOSTS=localhost,127.0.0.1
UNFOLD_STUDIO=0Because Git does not track empty folders, you must manually initialize your migrations directory before Django can detect your modular models.
-
Ensure the migrations module exists:
mkdir -p backend/core/migrations touch backend/core/migrations/__init__.py
-
Generate the migration files:
poetry run python backend/manage.py makemigrations core
-
Apply migrations to the SQLite database: (The
db/folder will be auto-created by settings if it doesn't exist)poetry run python backend/manage.py migrate
-
Create a Superuser for the Unfold Admin panel:
poetry run python backend/manage.py createsuperuser
Our frontend uses the new Tailwind CSS v4, which operates as a lightning-fast Vite plugin rather than a PostCSS wrapper.
-
Navigate to the frontend directory:
cd frontend -
Install Node dependencies:
npm install
-
Verify Environment Configuration: Ensure your frontend
.env(or.env.local) points to the Django API:VITE_API_URL=[http://127.0.0.1:8000/api/](http://127.0.0.1:8000/api/)
You will need two terminal windows to run both the frontend and backend simultaneously.
Terminal 1: Django Backend From the root directory, run our custom Poe task:
poe devTerminal 2: Vite Frontend
From the frontend directory:
npm run dev- React App:
http://localhost:5173/ - Django Unfold Admin:
http://127.0.0.1:8000/admin/ - API Endpoints:
http://127.0.0.1:8000/api/
The boilerplate includes drf-spectacular for OpenAPI 3.0 schema generation.
- Interactive Swagger UI:
http://127.0.0.1:8000/api/docs/ - Redoc UI:
http://127.0.0.1:8000/api/redoc/
Export Schema for Frontend (TypeScript Generation):
poe schema(This generates a schema.yml file in the root directory).
- Cause: You ran
createsuperuserbefore Django detected yourUserProfilemodel in thecoreapp. - Fix: Ensure
backend/core/migrations/__init__.pyexists. Runmakemigrations core, thenmigrate, and finally trycreatesuperuseragain.
- Cause: Django is looking for a production
manifest.jsonfile infrontend/dist/. - Fix: Ignore this during development. It is normal. To permanently clear the warning, run a production build once:
cd frontend && npm run build.
- Cause: SQLite cannot find the
db/parent folder. - Fix: If the
BASE_DIR.parent / "db".mkdir(...)fallback insettings.pyfails, manually runmkdir dbin the project root.
- Cause: Git ignores empty directories, so
backend/static/might be missing. - Fix: Manually create them:
mkdir -p backend/static backend/staticfiles.
- Cause: You are using the "SIDECAR" setting but haven't installed the sidecar package.
- Fix: Either run
poetry add drf-spectacular-sidecarOR removeSWAGGER_UI_DIST: 'SIDECAR'from yourSPECTACULAR_SETTINGSinbase.pyto fall back to the CDN.