Project submission for Modern Application Development II (January 2025).
A multi-user exam preparation platform where users can practice quizzes for different subjects and chapters.
The platform has two roles: Admin (Quiz Master) and Users.
The admin manages subjects, chapters, and quizzes, while users can register, take quizzes, and track their scores.
- User Management: Admin manages users, and users can register/login.
- Quiz Creation & Management: Admin creates subjects, chapters, and quizzes.
- Timed Quizzes: Users attempt quizzes with a countdown timer.
- Score Tracking: Users can view past quiz scores and performance analytics.
- Background Jobs: Celery handles CSV exports, reminders, and reports.
- Daily Reminders: Users get notified about new quizzes via email or chat.
- Monthly Reports: Users receive a summary of their quiz performance.
- CSV Export: Users and Admin can export quiz data.
- Caching & Performance Optimization: Redis improves API response times.
- ✅ Setup project structure
- ✅ Configure Flask API
- ✅ Implement user authentication
- ✅ Create database models
- ✅ Admin dashboard for quiz management
- ✅ User dashboard for quiz attempts
- ✅ Implement quiz timer
- ✅ Store and display quiz scores
- ✅ Implement background jobs with Celery
- ✅ Implement caching with Redis
- ✅ Add CSV export functionality
- ✅ Send daily quiz reminders
- ✅ Generate and send monthly reports
- ✅ Optimize API performance
- ✅ Final testing and deployment
├── backend/ # Server-side application code
│ ├── app.py # Flask application entry point and configuration
│ ├── cache.py # Redis cache configuration and helper functions
│ ├── celery_app.py # Celery task queue setup and worker config
│ ├── cleanup.sh # Script to reset database and clear cache
│ ├── db/ # Database related files
│ │ ├── models.py # SQLAlchemy model definitions and relationships
│ │ ├── seed.py # Database seeding logic and helper functions
│ │ ├── data_quizzes.py # Sample quiz data for database seeding
│ │ └── data_subjects.py # Sample subject data for database seeding
│ ├── routes/ # API route handlers
│ │ ├── admin_bp.py # Admin-specific endpoints (users, stats)
│ │ ├── auth_bp.py # Authentication endpoints (login, register)
│ │ ├── chapter_bp.py # Chapter CRUD operations
│ │ ├── question_bp.py # Question CRUD operations
│ │ ├── quiz_bp.py # Quiz CRUD and attempt operations
│ │ └── subject_bp.py # Subject CRUD operations
│ ├── static/ # Generated files (CSV exports, etc)
│ └── templates/ # HTML templates
│ └── email/ # Email notification templates
│
└── frontend/ # Client-side application code
├── index.html # Main HTML template
├── jsconfig.json # JavaScript/TypeScript configuration
├── package.json # NPM dependencies and scripts
├── vite.config.js # Vite bundler configuration
└── src/ # Source code directory
├── App.vue # Root Vue component
├── main.js # JavaScript entry point
├── assets/ # Static assets (images, styles)
│ └── base.css # Global CSS styles
├── router/ # Vue Router configuration
│ ├── index.js # Route definitions and guards
├── store/ # State management
│ ├── index.js # Vue store configuration
├── utils/ # Helper functions and utilities
└── views/ # Vue components by section
├── admin/ # Admin dashboard components
│ └── forms/ # Admin form components
├── auth/ # Authentication components
├── common/ # Shared/common components
└── user/ # User dashboard components
GET /whoami- Check current authentication statusPOST /login- Login with email and passwordPOST /register- Register new user accountPOST /logout- Logout current user
GET /users/<id>- Get single user detailsGET /users- Get all users listPUT /users/<id>/block- Block a userPUT /users/<id>/unblock- Unblock a userGET /statistics- Get platform statisticsPOST /repopulate- Reset and reseed database
GET /quiz-attempts- Get user's quiz attemptsPOST /quiz-attempts/<quiz_id>- Submit a quiz attemptGET /send-test-email- Send test email to userPOST /export-attempts- Export user's attempts to CSV
GET /get/<id>- Get single subjectGET /get-all- Get all subjectsPOST /create- Create new subjectPUT /update/<id>- Update a subjectDELETE /delete/<id>- Delete a subject
GET /get/<id>- Get single chapterGET /get-all- Get all chaptersPOST /create- Create new chapterPUT /update/<id>- Update a chapterDELETE /delete/<id>- Delete a chapter
GET /get/<id>- Get single quizGET /get-all- Get all quizzesPOST /create- Create new quizPUT /update/<id>- Update a quizDELETE /delete/<id>- Delete a quiz
GET /get/<id>- Get single questionGET /get-all- Get all questionsPOST /create- Create new questionPUT /update/<id>- Update existing questionDELETE /delete/<id>- Delete a question
The application uses reactive stores to manage state. Each store is responsible for a specific domain.
Properties:
isLoggedIn- Boolean indicating user's login staterole- User's role ('admin' or 'user')
Properties:
subjects- Map of subject objects indexed by ID
Methods:
fetch(id)- Get single subjectfetchAll()- Get all subjectscreate(data)- Create new subjectupdate(id, data)- Update existing subjectdelete(id)- Delete subjectgetChaptersForSubject(subject)- Get chapters for a subjecthandleChapterCreated(chapter)- Handle chapter creationhandleChapterDeleted(chapter)- Handle chapter deletion
Properties:
chapters- Map of chapter objects indexed by ID
Methods:
fetch(id)- Get single chapterfetchAll()- Get all chapterscreate(data)- Create new chapterupdate(id, data)- Update existing chapterdelete(id)- Delete chapterhandleSubjectDeleted()- Handle subject deletion
Properties:
quizzes- Map of quiz objects indexed by ID
Methods:
fetch(id)- Get single quizfetchAll()- Get all quizzescreate(data)- Create new quizupdate(id, data)- Update existing quizdelete(id)- Delete quizgetQuestionsForQuiz(quiz)- Get questions for a quizhandleQuestionCreated(question)- Handle question creationhandleQuestionDeleted(question)- Handle question deletionhandleChapterDeleted()- Handle chapter deletion
Properties:
questions- Map of question objects indexed by ID
Methods:
fetch(id)- Get single questionfetchAll()- Get all questionscreate(data)- Create new questionupdate(id, data)- Update existing questiondelete(id)- Delete questionhandleQuizDeleted()- Handle quiz deletion
Properties:
attempts- Map of quiz attempts indexed by IDanswerFeedbacks- Map of answer feedbacks indexed by attempt ID
Methods:
fetchAll()- Get all attempts for current usercreate(quizId, answers)- Create new quiz attempt
Each store uses the fetchHelper utility for API communication and maintains its data in a reactive Map structure. The stores also handle related entity changes through various handle methods to maintain data consistency.
This guide provides step-by-step instructions for setting up and running the application on both Linux and Windows.
Follow the sections in order.
- Git installed
- Python 3.x
- Node.js and npm
- VSCode (recommended for terminal restoration extension)
-
Clone the Repository
git clone https://github.com/k26rahul/mad2-project-rahul.git cd mad2-project-rahul -
Set Up Virtual Environment
- Linux:
python -m venv venv source venv/bin/activate - Windows:
python -m venv venv venv\Scripts\activate
- Linux:
-
Install Python Dependencies
pip install -r requirements.txt
-
Install Nodemon Globally
npm install -g nodemon
-
Install Redis
- Linux:
sudo apt-get update sudo apt-get install redis-server
- Windows:
- Download from https://github.com/microsoftarchive/redis/releases (e.g., MSI installer).
- During installation:
- Set port to 6380.
- Check "Add to PATH".
- If PATH not added, manually add "C:\Program Files\Redis" to system PATH.
Troubleshooting Redis on Windows:
- If fails to start: Run
& "C:\Program Files\Redis\redis-server.exe" --bind 127.0.0.1 --port 6380. - If port 6380 in use:
- Find process:
netstat -ano | findstr 6380. - Get details:
tasklist /FI "PID eq <PID>". - Kill:
taskkill /PID <PID> /For use Task Manager (Services tab, sort by PID).
- Find process:
- Linux:
-
Install MailHog
- Download from https://github.com/mailhog/MailHog/releases.
- Linux: Use MailHog_linux_amd64; make executable and add to PATH.
- Windows: Use MailHog_windows_amd64.exe; rename to MailHog.exe and add to PATH.
-
Install Frontend Dependencies
cd frontend npm install cd ..
Install VSCode extension: Restore Terminals by Ethan Sarif-Kattan.
For Windows Users: Delete .vscode/restore-terminals.json and rename .vscode/restore-terminals.windows.json to restore-terminals.json for Windows-specific commands.
- Open project in VSCode.
- Use extension: Press
Ctrl+Shift+P, type "Restore Terminals", and select it.
Note: If extension fails (common on Windows), manually open 6 terminals in VSCode and run commands below. This is more reliable.
-
Terminal 1: Flask Backend
cd backend # Linux: ./run.sh # Windows (PowerShell): ./run.ps1
-
Terminal 2: Frontend
cd frontend # Linux: ./run.sh # Windows (PowerShell): ./run.ps1
-
Terminal 3: Redis Server
cd backend redis-server --port 6380 # If Redis fails to start, refer to troubleshooting steps above.
-
Terminal 4: Celery Worker
cd backend # Linux: celery -A app.celery_app.celery worker --loglevel=info # Windows: celery -A app.celery_app.celery worker --loglevel=info --pool=solo
-
Terminal 5: Celery Beat
cd backend celery -A app.celery_app.celery beat --loglevel=info -
Terminal 6: MailHog Server
# Linux: MailHog # Windows: MailHog.exe or full path if not in PATH
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- MailHog UI: http://localhost:8025
