A full-featured event ticketing platform backend built with Django, allowing organizers to create events and visitors to purchase tickets with QR code functionality.
๐ฅ User Management | Multi-role system (Admin, Organizer, Visitor) |
๐๏ธ Event Management | Create, update, and delete events |
๐๏ธ Ticket System | Purchase, verify, and check-in with QR codes |
๐ง Email Notifications | Send ticket confirmations with embedded QR codes |
๐ Real-time Notifications | WebSocket-based event reminders |
๐ Analytics | Track event views, purchases, and other interactions |
๐ GraphQL API | Flexible data querying and manipulation |
๐ REST API | Standard RESTful endpoints for events and tickets |
๐งฐ Backend Framework
- ๐ข Django 5.2.1
- ๐ด Django REST Framework 3.16.0
- ๐ฃ Graphene (GraphQL) 3.4.3
๐ Authentication
- ๐ Django OAuth Toolkit
- ๐ djangorestframework-simplejwt
- ๐ค Social Authentication
๐พ Database
- ๐๏ธ SQLite (development)
- ๐ Migrations support for other databases in production
โ๏ธ Asynchronous Processing
- ๐ Celery for background tasks
- ๐ Redis for message broker
- ๐ก Django Channels for WebSockets
๐ Media Handling
- ๐ผ๏ธ Pillow for image processing
- ๐ฑ QR Code generation
๐ง Email Service
- ๐จ SendGrid integration
๐ Documentation & Schemas
- ๐ DRF Spectacular for API documentation
event_ticket/backend/
โ
โโโ manage.py # Django management script
โโโ requirements.txt # Project dependencies
โโโ client.html # WebSocket test client
โ
โโโ ticket_system/ # Main Django project
โ โโโ __init__.py
โ โโโ asgi.py # ASGI config for async support
โ โโโ celery.py # Celery configuration
โ โโโ schedule.py # Task scheduling
โ โโโ settings.py # Project settings
โ โโโ urls.py # Main URL routing
โ โโโ views.py # Top-level views
โ โโโ wsgi.py # WSGI configuration
โ โ
โ โโโ core/ # Core app with models and base functionality
โ โ โโโ models.py # User, Event, Ticket, Stats models
โ โ โโโ serializers.py # Data serializers
โ โ โโโ permissions.py # Custom permission classes
โ โ โโโ admin.py # Admin interface
โ โ โโโ manager.py # Custom user manager
โ โ
โ โโโ events/ # Events app
โ โ โโโ views.py # Event and Ticket ViewSets
โ โ โโโ serializers.py # Event serializers
โ โ โโโ urls.py # Event URL routing
โ โ โโโ consumers.py # WebSocket consumers
โ โ โโโ tasks.py # Celery tasks
โ โ โโโ routing.py # WebSocket URL routing
โ โ โโโ middleware.py # WebSocket auth middleware
โ โ
โ โโโ services/ # Services app
โ โ โโโ email_service.py # SendGrid email service
โ โ โโโ qr_code.py # QR code generation
โ โ โโโ views.py # Service views
โ โ โโโ urls.py # Service URL routing
โ โ
โ โโโ graphql/ # GraphQL app
โ โโโ schema.py # GraphQL schema
โ โโโ query.py # GraphQL queries
โ โโโ mutation.py # GraphQL mutations
โ โโโ types.py # GraphQL types
โ
โโโ media/ # User-uploaded media
โ โโโ qr_codes/ # Generated ticket QR codes
โ
โโโ staticfiles/ # Static files
Step-by-Step Guide
-
Clone the repository ๐ฅ
git clone https://github.com/ahmed123456787/ticket-event.git cd event_ticket/backend
-
Create and activate a virtual environment ๐ฎ
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies ๐ฆ
pip install -r requirements.txt
-
Set up environment variables ๐
Create a
.env.dev
file in the project root with:SENDGRID_API_KEY=your_sendgrid_api_key
-
Run migrations ๐
python manage.py migrate
-
Create a superuser ๐
python manage.py createsuperuser
-
Run the development server ๐
python manage.py runserver
Start Required Services
-
Start Redis server ๐ด
redis-server
-
Run Celery worker ๐ง
celery -A ticket_system worker -l info
-
Run Celery beat โฐ
celery -A ticket_system beat -l info
Available Authentication Methods
-
JWT Authentication ๐
- Get token:
POST /api/token/
- Refresh token:
POST /api/token/refresh/
- Get token:
-
Session Authentication ๐ฅ๏ธ
- Login:
POST /api/login/
- Logout:
POST /api/logout/
- Check status:
GET /api/auth-status/
- Login:
-
OAuth2 Authentication ๐
- OAuth endpoints:
/auth/
- OAuth endpoints:
Role | Description |
---|---|
๐ Admin | Complete system access |
๐ญ Organizer | Create and manage events, verify tickets |
๐ Visitor | Browse events, purchase and use tickets |
Built with โค๏ธ by Ahmed