A web application for the Bangladesh University of Engineering and Technology (BUET) Civil Engineering Department to manage the allocation of Major, Minor, and Thesis Supervisor for 4th-year students.
Students submit ranked preferences for (Major+Minor) combinations and supervisors. A rank-based greedy algorithm allocates seats fairly β higher-ranked students get priority.
The 4th-year Civil Engineering curriculum is divided into 4 specialities:
| Code | Speciality |
|---|---|
| S | Structure |
| T | Transport |
| E | Environment |
| G | Geotech |
Each student selects two specialities β one Major and one Minor. The student must complete all coursework in their Major. They also choose a supervisor under whom they will perform their thesis.
| Constraint | Source |
|---|---|
| Each (Major+Minor) combo has a fixed number of seats | List Two (admin uploads) |
| Each supervisor takes a fixed number of students | List One (admin uploads) |
| Students are ranked by merit | List Three (admin uploads) |
- Students are sorted by merit rank (ascending)
- Each student's combo preferences are iterated in priority order
- For each combo, the system checks seat availability AND supervisor availability
- The first available combo + supervisor pair is assigned
- Unranked combos are treated as equal-lowest priority (sorted alphabetically)
- Login / Registration β Student ID + password. New IDs auto-register.
- β
Student ID Validation β IDs must be exactly 7 digits and start with a configurable prefix (default:
2104). - π My Allocation β Real-time view of your assigned combo and supervisor.
- βοΈ Preferences β Interactive dropdowns to rank combos (1β12) and supervisors per major.
- π Results Table β Searchable, sortable table of all students' allocations with autocomplete suggestions.
- Secure Login β Username/password authentication.
- π€ Supervisors (List One) β Add/edit/delete supervisor assignments per major. CSV import/export.
- π Combo Seats (List Two) β Configure seat limits for each major+minor combination. CSV import (
ST,27format) / export. - π Merit List (List Three) β Upload ranked student list via CSV (
rank,student_id). Manual add/remove. Auto-creates student accounts. - π₯ Student Management β View all registered students, reset passwords.
βΆοΈ Auto-Allocation β Runs automatically whenever data changes (preferences, seats, or ranks update).
- Python 3.10+
- pip
# 1. Clone the repository
git clone <repo-url> && cd MajorSelectionBUET
# 2. Install dependencies
pip install -r requirements.txt
# 3. Configure environment
cp .env.example .env
# Edit .env to set your SECRET_KEY, admin credentials, and STUDENT_ID_PREFIX
# 4. Run (development)
python app.pyThe app will be available at http://127.0.0.1:5000.
- Username:
admin - Password:
admin123
β οΈ Change these immediately in.envfor any production deployment.
# Direct
gunicorn wsgi:app -c gunicorn_config.py
# With custom workers / port
GUNICORN_WORKERS=8 GUNICORN_BIND=0.0.0.0:8000 gunicorn wsgi:app -c gunicorn_config.pysudo cp deploy/buet-major-selection.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable buet-major-selection
sudo systemctl start buet-major-selection
# View logs
sudo journalctl -u buet-major-selection -fchmod +x deploy/deploy.sh
./deploy/deploy.sh- Set
PRODUCTION=truein.env - Set a strong
SECRET_KEY - Change default admin password
- Set
DATABASE_URIto an absolute path:sqlite:////absolute/path/to/instance/major_selection.db - Set
STUDENT_ID_PREFIXto match your department's intake (e.g.,2104for 2021 intake, dept 04) - Configure
SERVER_NAMEto your domain - Set up nginx reverse proxy (see below)
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /static/ {
alias /home/hamim-mahmud/Workspace/MajorSelectionBUET/static/;
expires 30d;
}
}MajorSelectionBUET/
βββ app.py # Flask app factory, entry point
βββ wsgi.py # WSGI entry point for gunicorn/uvicorn
βββ config.py # Configuration (reads from .env)
βββ gunicorn_config.py # Gunicorn production settings
βββ Procfile # Platform deploy (Heroku, etc.)
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (git-ignored)
β
βββ models/
β βββ __init__.py # SQLAlchemy models (7 tables)
β
βββ routes/
β βββ auth_bp.py # Student login/signup
β βββ admin_bp.py # Admin CRUD + CSV import/export
β βββ dashboard_bp.py # Student dashboard (3 sections)
β βββ api_bp.py # AJAX endpoints (preferences, search)
β
βββ services/
β βββ allocator.py # Greedy rank-based allocation algorithm
β
βββ templates/
β βββ base.html # Base layout (Tailwind CSS)
β βββ login.html # Student login page
β βββ admin/
β β βββ login.html # Admin login
β β βββ dashboard.html # Admin dashboard with stats
β β βββ supervisors.html # List One CRUD
β β βββ combos.html # List Two CRUD
β β βββ merit.html # List Three CRUD
β β βββ students.html # Student management
β βββ dashboard/
β βββ index.html # Student dashboard (3 sections)
β
βββ static/
β βββ js/
β βββ preferences.js # Combo + supervisor preference saving
β βββ search.js # Real-time search with autocomplete
β
βββ deploy/
βββ buet-major-selection.service # systemd service unit
βββ deploy.sh # One-shot deployment script
| Table | Purpose | Key Columns |
|---|---|---|
admin |
Admin accounts | username, password_hash |
student |
Student accounts | id (student_id PK), password_hash, rank |
supervisor |
List One β supervisor capacity | name, major_code (S/T/E/G), seats |
combo_seat |
List Two β combo seat limits | major_code, minor_code, seats |
student_combo_pref |
Student combo rankings | student_id, major_code, minor_code, priority |
student_supervisor_pref |
Student supervisor rankings | student_id, supervisor_id, major_code, priority |
allocation |
Final allocation results | student_id, major_code, minor_code, supervisor_id |
| Variable | Default | Description |
|---|---|---|
SECRET_KEY |
dev-secret-key |
Flask session signing key |
FLASK_ENV |
development |
development or production |
ADMIN_USERNAME |
admin |
Default admin username |
ADMIN_PASSWORD |
admin123 |
Default admin password |
DATABASE_URI |
sqlite:///major_selection.db |
SQLAlchemy database URI |
STUDENT_ID_PREFIX |
2104 |
First 4 digits all student IDs must start with |
PRODUCTION |
false |
Enables secure cookies, disables debug |
SERVER_NAME |
β | Production domain name |
PORT |
5000 |
Dev server port |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/preferences/combo |
Save combo priority list |
POST |
/api/preferences/supervisor |
Save supervisor priority list for a major |
GET |
/api/allocation/status |
Get current user's allocation as JSON |
GET |
/api/search?q=...&filter=... |
Search allocations (student_id or combo) |
GET |
/api/search/suggestions?q=...&filter=... |
Autocomplete suggestions |
-
Admin Setup
- Login as admin (
admin/admin123) - Go to Supervisors β add supervisors with seat counts
- Go to Combos β add major-minor combos with seat limits
- Go to Merit List β upload a CSV of ranked students
- Login as admin (
-
Student Registration
- Go to login page β enter a valid 7-digit Student ID starting with the prefix
- Set a password β redirected to dashboard
- Use dropdowns to rank combo and supervisor preferences β save
-
Verify Allocation
- The allocation runs automatically on save
- Check "My Allocation" section to see assigned combo + supervisor
- Check the "Allocation Results" table to see all students
Supervisors (List One):
name,major,seats
Amanat Sir,S,4
Tahsin Sir,S,4
Shamsul Sir,T,4Combos (List Two):
ST,27
SG,27
SE,27
TS,13Merit List (List Three):
1,2104065
2,2104053
3,2104122- Allocation Algorithm: Greedy by rank (simplest, matches real-world "higher rank gets priority").
- Auto-Allocation: Runs on every data change β preferences, seats, or ranks update.
- Supervisor per Major: One supervisor preference list per major, shared across all combos containing that major.
- Partial Preferences: If a student ranks only 3 out of 12 combos, the remaining 9 get equal-lowest priority (sorted alphabetically).
- Tailwind CSS: Via CDN (no build step needed).
- Vanilla JavaScript: Keeps the frontend lightweight β no framework overhead.
This project is licensed under the terms included in the LICENSE file.