A modern, production-ready full-stack template combining Django REST Framework with SvelteKit, featuring authentication, CRUD operations, dark mode, and a complete todo application demo.
π Live Demo | π Documentation
π Read the Architecture Guide for a detailed technical overview of the codebase
- Django 5.2.3 with REST Framework
- Svelte 5 with SvelteKit and TypeScript support
- Tailwind CSS with Typography plugin for styling
- Axios for API communication with CSRF handling
- Session-based authentication with secure defaults
- CSRF protection properly configured
- CORS configured for development and production
- Security headers for production deployments
- Dark mode support with system preference detection
- Responsive design with mobile-first approach
- Loading states and error handling
- Animated transitions and micro-interactions
- Celebration animations for todo completion
- Hot reload for both frontend and backend
- TypeScript support with strict configuration
- ESLint & Prettier for code formatting
- Black & isort for Python code formatting
- Pre-commit hooks for automated code quality
- VS Code workspace configuration included
- Docker support with multiple compose files
- SQLite default with PostgreSQL option
- Production-ready security configurations
- Static file handling and optimization
- Environment-based configuration management
- Complete Todo App with CRUD operations
- Priority levels and due dates
- Categories and tags support
- Real-time updates and optimistic UI
- Python 3.10+ (3.12 recommended)
- Node.js 18+
- npm or yarn
- Virtual environment (recommended)
-
Clone and install dependencies:
npm run setup
This will:
- Install frontend dependencies
- Create Python virtual environment with Python 3.12 (
django_svelte_env/
) - Install Django 5.2.3 and other Python dependencies in the virtual environment
On Windows, if Python command fails, try:
npm run install npm run setup:python-win
-
Set up environment variables:
cp .env.example .env # Edit .env with your settings
-
Run database migrations:
npm run migrate
On Windows:
npm run migrate:win
-
Create a superuser:
npm run createsuperuser
On Windows:
npm run createsuperuser:win
-
Start development servers:
npm run dev
The application will be available at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000/api
- Django Admin: http://localhost:8000/admin
Development:
npm run dev
- Start both frontend and backend development serversnpm run dev:backend
- Start only Django development servernpm run dev:frontend
- Start only SvelteKit development servernpm run setup
- Install all dependenciesnpm run setup:dev
- Install all dependencies including development tools
Database:
npm run migrate
- Run Django migrationsnpm run createsuperuser
- Create Django superuser
Building & Deployment:
npm run build
- Build frontend for productionnpm run collectstatic
- Collect static files
Code Quality:
npm run lint
- Lint both frontend and backend codenpm run lint:frontend
- Lint frontend code with ESLintnpm run lint:backend
- Lint backend code with flake8npm run format
- Format both frontend and backend codenpm run format:frontend
- Format frontend code with Prettiernpm run format:backend
- Format backend code with Black and isort
Testing:
npm run test
- Run backend testsnpm run test:backend
- Run Django tests
Windows-specific (if python3 command fails):
npm run setup:python-win
- Install Python dependencies on Windowsnpm run migrate:win
- Run Django migrations on Windowsnpm run createsuperuser:win
- Create Django superuser on Windowsnpm run collectstatic:win
- Collect static files on Windows
SQLite (Default):
docker-compose up
PostgreSQL:
docker-compose -f docker-compose.postgres.yml up
Production:
docker-compose -f docker-compose.prod.yml up
django-svelte-template/
βββ backend/ # Django application
β βββ django_svelte_template/
β β βββ settings.py # Django settings
β β βββ urls.py # URL configuration
β β βββ api/ # API application
β β βββ models.py # Data models
β β βββ views.py # API views
β β βββ serializers.py
β β βββ urls.py
β βββ templates/ # Django templates
β βββ manage.py
βββ frontend/ # SvelteKit application
β βββ src/
β β βββ routes/ # SvelteKit routes
β β βββ lib/
β β β βββ components/ # Svelte components
β β β βββ api.ts # API client
β β β βββ stores.ts # Svelte stores
β β βββ app.css
β βββ package.json
β βββ vite.config.js
βββ django_svelte_env/ # Python virtual environment
βββ requirements.txt # Python dependencies
βββ package.json # Node.js dependencies
βββ docker-compose.yml # Docker configuration
βββ README.md # Setup and usage guide
βββ ARCHITECTURE.md # Technical documentation
POST /api/login/
- User loginPOST /api/logout/
- User logoutGET /api/user/
- Get current user infoGET /api/csrf/
- Get CSRF token
GET /api/todos/
- List todosPOST /api/todos/
- Create todoGET /api/todos/{id}/
- Get todo detailPATCH /api/todos/{id}/
- Update todoDELETE /api/todos/{id}/
- Delete todo
-
Build frontend:
npm run build
-
Collect static files:
npm run collectstatic
-
Set environment variables:
- Set
DEBUG=False
- Configure proper
SECRET_KEY
- Set
ALLOWED_HOSTS
- Set
-
Use a production WSGI server like Gunicorn:
pip install gunicorn gunicorn django_svelte_template.wsgi:application
Python command not found:
- On macOS/Linux: Use
python3
instead ofpython
- On Windows: Use
python
or ensure Python is in your PATH - Try the Windows-specific scripts (
:win
suffix)
npm vulnerabilities or dependency conflicts:
npm run clean-install
# OR manually:
cd frontend
rm -rf node_modules package-lock.json
npm install
CORS issues:
- Ensure frontend is running on http://localhost:5173
- Check Django CORS_ALLOWED_ORIGINS in settings.py
Database issues:
# Reset database
rm backend/db.sqlite3
npm run migrate
npm run createsuperuser
Static files not loading:
npm run build
npm run collectstatic
Manual virtual environment activation:
# Activate virtual environment manually (if needed)
source django_svelte_env/bin/activate # macOS/Linux
# OR
django_svelte_env\Scripts\activate # Windows
# Your prompt should show: (django_svelte_env) $
- Fork the repository
- Read ARCHITECTURE.md to understand the codebase structure
- Create a feature branch
- Make your changes
- Run tests and ensure code quality
- Submit a pull request
MIT License - see LICENSE file for details.