Deployed here: https://django-template-qa.ag.purdue.edu/ (requires WebVPN 2 or Ag IT Devs VPN). Production deployment coming soon!
This is a starter template for web applications that can be easily hosted and maintained at Purdue, with Purdue authentication and branding, using:
Together, they enable modern web applications that can start simple, grow in complexity with your needs, and are well-supported by AI coding assistants.
Note: This is an early-stage template that will evolve based on feedback and real-world use. The authors welcome comments, contributions, and ticket requests β see Support below.
π Ready to build your own app? See the Forking Guide for step-by-step instructions to extend this template.
- Purdue branding and visual standards
- Proven technology stack approved for use on campus
- Authentication via Purdue career accounts (SAML integrated but not tested or deployed)
A solid foundation for developers and researchers:
- Only 2 tools required: Docker Desktop and Git
- Works with AI assistants: Optimized for Claude, Copilot, ChatGPT
- Start quickly: Run it on your laptop in 15 minutes
- Immediate feedback: Changes appear instantly with hot-reload
- Docker Desktop β Manages your development environment
- Git β Version control
- Task β Run common commands easily (
task test,task lint) - VS Code β Editor with great Docker integration
- Pre-commit β Automated code quality checks
- Clone the repository:
git clone https://github.itap.purdue.edu/AgIT/django-react-template
cd django-react-template- Copy the environment file and customize it:
cp .env.example .env
# Edit .env to set DEFAULT_SUPERUSER_PASSWORD and other settings- Start the development environment:
docker compose up- Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000/api
- API Documentation: http://localhost:8000/api/swagger/
- Django Admin: http://localhost:8000/admin/
The application handles setup automatically:
- β Runs database migrations
- β Creates an admin user (if none exists)
- β
Uses password from
DEFAULT_SUPERUSER_PASSWORDin.env
No manual setup required! Just start and go.
π For Decision Makers
- Purdue SAML authentication ready to configure
- Multi-database support (PostgreSQL, MySQL, Oracle, SQL Server, SQLite)
- Modern tech stack that recruits want to work with
- Clear path from prototype to production
- Python 3.11+ server (provided by most Purdue servers)
- Database (or use SQLite for simple apps)
- No Node.js required in production
Pros:
- Django's mature authentication system
- React for modern, interactive UIs
- Multi-database support out of the box
- Can migrate to other architectures if needs change
- No Node.js required in production (simpler deployment)
Cons:
- Not ideal for SEO or server-side rendering (Next.js would support that at the cost of complexity)
π¬ For Researchers & Professors
- Build data dashboards and research tools
- Integrate with Purdue authentication automatically
- Deploy to Purdue servers without IT tickets
- AI assistants can help you code
- Lab data management systems
- Research participant portals
- Course project showcases
- Department resource schedulers
- Grant tracking dashboards
When using AI assistants (Claude, ChatGPT, Copilot), try prompts like:
- "Help me add a data upload feature to this Django-React app"
- "Create an API endpoint for storing survey responses"
- "Add a chart to display lab measurements over time"
The template includes a CLAUDE.md file that provides context to AI assistants automatically.
Need to reset everything and start over?
./reset-project.shπ» For Developers
# All development happens in Docker
docker compose up # Start everything
task test # Run tests (optional: install Task)
task lint # Check code quality
task format # Auto-fix code style| Task | Command | What it does |
|---|---|---|
| Start dev environment | docker compose up |
Starts all services |
| Run tests | task test or docker compose exec backend pytest |
Tests frontend & backend |
| Format code | task format |
Auto-fixes code style |
| Create migration | docker compose exec backend python manage.py makemigrations |
Updates database schema |
| Apply migrations | docker compose exec backend python manage.py migrate |
Applies database changes |
| Create superuser | docker compose exec backend python manage.py createsuperuser |
Creates admin user |
| Install package (backend) | docker compose exec backend pip install <package> |
Adds Python package |
| Install package (frontend) | docker compose exec frontend npm install <package> |
Adds npm package |
For testing with Gunicorn hot-reload (mimics production):
docker compose -f docker-compose.hot-reload.yml uppip install pre-commit
pre-commit install- Backend: Django (Python) β Handles authentication, database, APIs
- Frontend: React (TypeScript) β User interface, compiles to static files
- Development: Docker Compose for consistent local environment
- Production: Django serves both API and compiled React files
- Caching: Redis for sessions and caching
- Database: PostgreSQL (default), supports MySQL, MS SQL, Oracle, SQLite
django-react-template/
βββ backend/ # Django backend
β βββ config/ # Django settings & configuration
β β βββ settings/ # Environment-specific settings
β β βββ urls.py # URL configuration
β β βββ wsgi.py # WSGI configuration
β βββ apps/ # Django applications
β β βββ authentication/ # Auth backends (SAML/Email)
β β βββ api/ # API endpoints
β β βββ core/ # Core functionality
β βββ requirements/ # Python dependencies
βββ frontend/ # React frontend
β βββ src/ # Source code
β β βββ api/ # API client & hooks
β β βββ components/ # React components
β β βββ contexts/ # React contexts
β β βββ pages/ # Page components
β β βββ styles/ # CSS files
β βββ package.json # Node dependencies
βββ compose.yml # Development environment
- Django 5.1 backend with REST API
- React 18 frontend with TypeScript
- Responsive design for mobile and tablet
- Multiple database support (PostgreSQL, MySQL, MS SQL, Oracle, SQLite)
- Dual authentication modes (Purdue SAML SSO / Email with verification)
- Contact form with spam protection and email notifications
- TailwindCSS with Purdue branding
- Docker Compose for development
- Hot reloading in development
- Health checks ensure services start in correct order
- API documentation with Swagger/OpenAPI
- Production-ready configuration
βοΈ Database Configuration
Set the DATABASE_ENGINE environment variable in .env:
postgresql(recommended for production)mysql/mariadbmssql(MS SQL Server)oraclesqlite(template/development only)
When creating a real application from this template:
- Contact your database team for database credentials
- Update
.envwith the provided credentials:DATABASE_ENGINE=postgresql DB_NAME=your_app_db DB_HOST=db.server.edu DB_USER=your_app_user DB_PASSWORD=<provided_by_db_team> - Run migrations:
python manage.py migrate
- Export data if needed:
python manage.py dumpdata > data.json - Update
.envwith new database settings - Run migrations:
python manage.py migrate - Import data if needed:
python manage.py loaddata data.json
π Authentication Configuration
Set the AUTH_METHOD environment variable:
emailβ Email/password authentication (default for development)samlβ Purdue SAML SSO (for production)
Both modes use the same API interface, making development easier.
Note: SAML integration is implemented but not yet tested in production.
- Apply for SAML access through the Purdue Authentication Options page
- Once approved, obtain SAML certificates and metadata URL from Purdue IT
- Update SAML settings in
.env:AUTH_METHOD=saml SAML_ENTITY_ID=https://yourapp.purdue.edu/saml/metadata/ SAML_METADATA_URL=https://www.purdue.edu/apps/account/saml/metadata.xml
π§ Contact Form Configuration
The template includes a built-in contact form with spam protection and email notifications.
- Rate limiting (5 submissions per hour per IP address)
- Audit trail in database (all submissions are saved)
- Email notifications to configured recipient
- Form validation and error handling
- Responsive design
Set the recipient email in .env:
CONTACT_EMAIL=yourteam@purdue.eduThe contact form is accessible at /contact and requires no authentication. You can customize the page content by editing frontend/src/pages/ContactPage.tsx.
Contact form submissions are viewable in the Django admin panel at /admin/contact/contactmessage/. This allows you to:
- View all contact submissions
- Check email delivery status
- Filter by date and email sent status
- Search by name, email, or content
Edit backend/config/settings/base.py to adjust throttling:
"DEFAULT_THROTTLE_RATES": {
"contact": "5/hour", # Change to "10/hour", "20/day", etc.
}For production, consider setting up email properly (see .env.example for SMTP settings).
π§ Environment Variables
Key environment variables (see .env.example for full list):
# Django
SECRET_KEY=your-secret-key
DEBUG=True
AUTH_METHOD=email
# Database
DATABASE_ENGINE=postgresql
DB_NAME=purdue_app
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
DB_PORT=5432
# CORS
CORS_ALLOWED_ORIGINS=http://localhost:5173π οΈ Development Tools & Workflow
This project includes a Taskfile for common development tasks. Install Task to use it:
# Run all linters
task lint
# Format code
task format
# Run tests
task test
# Run all checks before committing
task pre-commit
# View all available tasks
task --listBackend (Python):
- Black β Code formatting
- isort β Import sorting
- Flake8 β Linting
- mypy β Type checking
Frontend (TypeScript/React):
- ESLint β Linting and code quality
- TypeScript β Type checking
Pre-commit hooks automatically check code quality before each commit:
# Install pre-commit
pip install pre-commit
# Install the git hooks
pre-commit install
# Run hooks manually on all files
pre-commit run --all-filesTo skip hooks temporarily: git commit --no-verify
π¨ Customization Guide
Edit the Tailwind configuration in frontend/tailwind.config.js:
- Update colors in
theme.extend.colors.purdue - Modify fonts in
theme.extend.fontFamily
- Create serializers in
backend/apps/api/serializers.py - Create views in
backend/apps/api/views.py - Register URLs in
backend/apps/api/urls.py - Add TypeScript types in
frontend/src/api/ - Create React Query hooks for the endpoints
If you prefer to work without Docker:
Backend:
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements/development.txt
python manage.py runserverFrontend:
cd frontend
npm install
npm run devFor complete deployment instructions, see deployment/README.md.
Development/QA deployment:
# Push to branch and auto-deploy (if GitOps is configured):
git push origin main # or qa, prod branches
# Manual deployment:
ssh server "cd ~/source/django-react-template && ./deployment/gitops-lite.sh"Local testing with production-like setup:
docker compose -f docker-compose.hot-reload.yml upSee deployment/new-server-setup.md for detailed server setup and production deployment instructions.
π§ͺ Running Tests
# Run all tests
task test
# Or without Task:
docker compose exec backend pytest
docker compose exec frontend npm test# Backend tests only
task test:backend
task test:backend:coverage # With coverage report
# Frontend tests only
task test:frontend
task test:frontend:watch # Watch mode
task test:frontend:coverage # With coverage report- Backend: See
backend/apps/api/test_example.pyfor Django REST API testing patterns - Frontend: See
frontend/src/components/*.test.tsxfor React component testing patterns
Both include examples of:
- Unit tests
- Authentication testing
- API endpoint testing
- Component rendering tests
- User interaction tests
-
Getting Started
- Django Tutorial β Build your first Django app
- React Tutorial β Interactive React basics
- Docker Getting Started β Container basics
-
For This Template
- Deployment Guide β Deploy to production
- Developer Guide β Detailed development instructions
- API Documentation: http://localhost:8000/api/swagger/ (when running)
-
Languages & Frameworks
- Python | Django | Django REST Framework
- TypeScript | React | Vite
-
Tools
- Docker | Docker Compose
- Task | Git
-
Purdue Resources
β οΈ Common Issues
If you see database connection errors:
- Ensure the database service is running:
docker compose ps - Check database credentials in
.env - Verify the database engine matches your setup
If you encounter CORS errors:
- Check
CORS_ALLOWED_ORIGINSin.env - Ensure the frontend URL is included
- Restart the backend service
For SAML authentication problems (SAML not yet tested in production):
- Check metadata URL is accessible
- Ensure entity ID matches Purdue's configuration
- Verify SAML settings in
.env
If Docker containers won't start:
- Check Docker Desktop is running
- Try
docker compose downthendocker compose up - Check for port conflicts (5173, 8000, 5432, 6379)
- No server-side rendering (affects SEO, initial load)
- Requires knowledge of both Python and JavaScript
- Still experimental, not battle-tested
This template doesn't lock you into specific choices. You could:
- Add server-side rendering with Next.js
- Replace React with another framework
- Split into microservices
- Add WebSocket support for real-time features
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
MIT License β See LICENSE file for details.
This is an evolving template. For questions or suggestions:
- Contact a member of the development team via Microsoft Teams
- Email the RHTS web development team, wbbaker@purdue.edu, deshunz@purdue.edu, brooksa@purdue.edu
- Create a ticket in the Purdue IT Service Portal β include the phrase Please assign to RHTS Research Solutions at the top of your request.
- Purdue University IT for SAML integration support
- Django and React communities for excellent documentation
