Overview
ESP Website is a Django-based web application designed to manage large-scale educational programs. The platform supports multiple concurrent programs, each with customizable workflows for student registration, teacher class submission, and onsite operations.Technology Stack
Backend
- Framework: Django 2.2
- Language: Python 3.7
- Database: PostgreSQL 14
- Cache: Memcached with pylibmc
- Task Queue: Custom email queue system
Frontend
- Templates: Django templates with custom tags
- JavaScript: jQuery and custom scripts
- CSS: Less stylesheets with theme system
- Admin UI: django-admin-tools
Infrastructure
- Web Server: Apache with mod_wsgi (production)
- Development: Docker Compose
- Email: Exim4 + dbmail queue system
- File Storage: Local filesystem
Integrations
- Payments: Stripe, CyberSource
- SMS: Twilio
- Email: SendGrid (optional)
- Forms: Formstack integration
- Mailing Lists: Mailman
System Architecture
Request Flow
Database Architecture
The database uses Django ORM with several key patterns: Core Models:Program- Represents a program instance (e.g., “Splash Fall 2024”)ClassSubject- A class offering with title, description, teachersClassSection- Scheduled instance of a class with time and roomESPUser- Extended user model with student/teacher capabilitiesStudentRegistration- Tracks student enrollment and interest
ExpirableModel Pattern
ExpirableModel Pattern
Many models inherit from Used by:
ExpirableModel which adds start_date and end_date fields. This allows tracking historical data:StudentRegistration, Permission, Record, and many others.ArgCache Caching
ArgCache Caching
The custom See the Cache documentation for details.
argcache library provides function-level caching with automatic invalidation:Tag System
Tag System
The See the Tags documentation for details.
Tag model provides flexible key-value configuration that can be global or scoped to specific objects (usually Programs):Program Module System
The defining architectural feature of ESP Website is its modular program system. Programs are composed of independent modules that handle different aspects of registration and management.Module Architecture
-
Base Classes (
esp/esp/program/modules/base.py):ProgramModuleObj- Database model linking modules to programsCoreModule- Abstract base class for all modules
-
Module Types:
learn- Student-facing modules (registration, profile, etc.)teach- Teacher-facing modules (class creation, availability, etc.)manage- Admin modules (scheduling, reports, communications)onsite- Day-of operations (check-in, attendance)volunteer- Volunteer recruitment and managementjson- API endpoints
-
URL Routing:
Module Lifecycle
Module Selection
Administrators select which modules to enable for a program via the Django admin or program creation form.
Module Initialization
When a URL is accessed, Django loads the appropriate module handler class and calls its view method.
Permission Check
Modules use decorators like
@needs_student or @needs_admin to enforce access control.Email System Architecture
ESP Website includes a sophisticated email queuing system:- All emails queued in database before sending
- Template system with variable substitution
- HTML and plain text versions
- Recipient lists (students, teachers, filtered users)
- Unsubscribe handling
- Send-to-guardians for minor students
Template System
ESP Website uses a hierarchical template system:Template Inheritance
QSD (Quasi-Static Data)
Administrators can edit page content without code changes:Template Overrides
TheTemplateOverride model allows per-program customization of templates without modifying the codebase.
Caching Strategy
ArgCache (Application Level)
Function-level caching with automatic invalidation based on model changes.Usage: Expensive queries, permission checks, user lists
Memcached (Session Level)
Django’s cache framework for session data and template fragments.Usage: User sessions, rendered template blocks
- ArgCache uses “wildcard” tokens to invalidate groups of related data
- Model signal handlers trigger invalidation on save/delete
- Manual cache clearing available via management commands
Security Model
Permission System
ThePermission model provides fine-grained access control:
V/Administer- Full program administrationV/Administer/Edit- Edit program settingsV/Flags/UserRole/{Student,Teacher,etc}- User type roles
View Decorators
File Organization
See the Directory Structure page for a complete guide to the codebase layout.Deployment Architecture
Production Setup:Development Workflow
Access Development Server
Navigate to http://localhost:8000 in your browser.
Create Superuser
Run
docker compose exec web python esp/manage.py createsuperuser to create an admin account.Next Steps
Directory Structure
Explore the codebase organization
Models Reference
Learn about the data models
Program Modules
Understand the module system
Contributing
Start contributing to the project