A comprehensive Django project demonstrating various Redis integration patterns including caching, session storage, Celery task queue, pub/sub messaging, rate limiting, analytics, and event sourcing.
This project showcases 7 different Redis use cases integrated with Django:
- Authentication (
auth_app) - PostgreSQL with JWT tokens - Caching (
cache_app) - Redis for data caching - Sessions (
session_app) - Redis session backend - Task Queue (
celery_app) - Redis as Celery broker - Real-time Messaging (
pubsub_app) - Redis Pub/Sub - Rate Limiting (
ratelimit_app) - Redis counters - Analytics (
analytics_app) - Redis sorted sets & counters - Event Sourcing (
stream_app) - Redis Streams
- Docker & Docker Compose installed
# Clone and navigate
cd redis_django_project
# Start all services (automated)
./start.sh# Copy environment file
cp .env.example .env
# Build and start
docker compose up --build -d
# Run migrations
docker compose exec web python manage.py migrate
# Create superuser
docker compose exec web python manage.py createsuperuser- API: http://localhost:8000
- Admin: http://localhost:8000/admin
- Nginx: http://localhost
POST /api/auth/register/- User registrationPOST /api/auth/login/- User login
POST /api/cache/set/- Set cache valueGET /api/cache/get/{key}/- Get cache valueGET /api/cache/stats/- Cache statistics
GET /api/session/info/- Session informationPOST /api/session/set/- Set session data
/api/celery/- Celery task management/api/pubsub/- Real-time messaging/api/analytics/- Metrics and analytics/api/stream/- Event sourcing
docker compose logs -f web
docker compose logs -f redis
docker compose logs -f celery# Django shell
docker compose exec web python manage.py shell
# PostgreSQL
docker compose exec postgres psql -U postgres -d redis_django_db
# Redis CLI
docker compose exec redis redis-clidocker compose down| Service | Port | Purpose |
|---|---|---|
| Django Web | 8000 | Main application |
| PostgreSQL | 5432 | Primary database |
| Redis | 6379 | Cache, sessions, Celery |
| Celery Worker | - | Background tasks |
| Celery Beat | - | Task scheduler |
| Nginx | 80 | Reverse proxy |
# Run all tests
docker compose exec web python manage.py test
# Specific app
docker compose exec web python manage.py test auth_appFor detailed Docker instructions, see: docker_instructions.md
- Backend: Django 4.2, Django REST Framework
- Database: PostgreSQL
- Cache/Broker: Redis
- Task Queue: Celery
- Authentication: JWT (SimpleJWT)
- Containerization: Docker, Docker Compose
- Proxy: Nginx
- JWT-based authentication
- Rate limiting middleware
- CORS protection
- Environment-based configuration
- Non-root Docker containers
Made with ❤️ for learning Redis integration patterns with Django!