ClassPulse System Architecture¶
Overview¶
ClassPulse is a real-time audience interaction platform that allows presenters to engage with their audience through interactive questions. The system follows a modular architecture with clear separation of concerns, built using the FastHTML framework.
System Components¶
1. Core Components¶
+-------------------+ +------------------+ +----------------+
| | | | | |
| Web Frontend |<---->| Backend Server |<---->| Database |
| (HTML/CSS/JS) | | (FastHTML/Python)| | (SQLite) |
| | | | | |
+-------------------+ +------------------+ +----------------+
^ ^
| |
v v
+-------------------+ +------------------+
| | | |
| WebSocket |<---->| Real-time |
| Communication | | Events |
| | | |
+-------------------+ +------------------+
2. Architectural Patterns¶
ClassPulse employs several architectural patterns:
- Model-View-Controller (MVC)
- Models: Database schema and data access layer
- Views: HTML templates and FastHTML components
-
Controllers: Route handlers that process requests
-
Service-Oriented Architecture
- Modular utilities that provide specific services
-
Clear interfaces between components
-
Real-time Event Processing
- WebSocket connections for live updates
- Event-driven architecture for question responses
Data Flow¶
+----------------+ +-----------------+ +------------------+
| | | | | |
| Audience Member|------->| Join Session |------>| View Questions |
| | | | | |
+----------------+ +-----------------+ +------------------+
|
v
+----------------+ +-----------------+ +------------------+
| | | | | |
| Presenter |<-------| Real-time |<------| Submit Responses |
| | | Results Update | | |
+----------------+ +-----------------+ +------------------+
|
v
+----------------+
| |
| Export Results |
| |
+----------------+
Module Breakdown¶
Frontend Layer¶
- Static Assets
- CSS: Custom styling and layouts
- JavaScript: Client-side interactivity and chart rendering
-
Images: Icons and visual elements
-
Templates
- Presenter views: Dashboard, session management, results
- Audience views: Join page, question answering interfaces
Backend Layer¶
- Controllers
auth_routes.py
: Authentication and user managementaudience_routes.py
: Audience-facing interfacespresenter_routes.py
: Presenter dashboard and managementquestion_routes.py
: Question creation and result display-
websocket_routes.py
: Real-time communication -
Utils
auth.py
: Authentication helpers and securitycomponents.py
: Reusable UI componentsqrcode.py
: QR code generation for easy session joining-
session_manager.py
: Session and question management logic -
Models
schema.py
: Database tables, relationships, and data models
Database Schema¶
+----------------+ +----------------+ +----------------+
| Users | | Sessions | | Questions |
+----------------+ +----------------+ +----------------+
| id |<----->| id |<----->| id |
| username | | code | | session_id |
| password_hash | | name | | type |
| email | | created_at | | title |
| display_name | | user_id | | options |
+----------------+ | active | | active |
+----------------+ | created_at |
| order |
+----------------+
|
v
+----------------+
| Responses |
+----------------+
| id |
| question_id |
| session_id |
| response_value |
| respondent_id |
| created_at |
+----------------+
Technology Stack¶
- Backend
- Python 3.x
- FastHTML framework (Based on Starlette)
- Uvicorn ASGI server
-
FastLite (SQLite ORM)
-
Frontend
- HTML/CSS
- Vanilla JavaScript
- Chart.js for data visualization
-
jQCloud for word cloud rendering
-
Data Storage
-
SQLite database
-
Real-time Communication
- WebSockets for live updates
Security Considerations¶
- Authentication
- Password hashing with salt using PBKDF2
-
Session-based authentication
-
Data Protection
- Anonymous audience responses
- Session ownership verification
-
Input validation and sanitization
-
Access Control
- Route protection via middleware
- Session-based authorization
Scalability Considerations¶
The current architecture can handle small to medium-sized classrooms or presentation scenarios. For larger deployments, consider:
- Database Scaling
- Migrate from SQLite to PostgreSQL or MySQL
-
Implement connection pooling
-
Performance Optimization
- Implement caching for frequent queries
-
Optimize WebSocket connections for high concurrency
-
Deployment Options
- Containerize with Docker
- Deploy with Gunicorn workers behind Nginx