A full-stack web application built with Python Flask and PostgreSQL for managing a college's departments, staff, students, and parents. Includes a companion Android mobile app.
π Live Demo: https://smart-department.onrender.com
Note: The app is hosted on Render's free tier and may take 30β60 seconds to wake up on the first visit.
Use these to explore the live demo without setting anything up locally.
| Login URL | /public_login |
| Username | admin |
| Password | admin |
| Endpoint | Description |
|---|---|
/admin/admin_home |
Admin dashboard |
/admin/admin_manage_batches |
Add, edit, delete batches |
/admin/admin_manage_subjects |
Manage subjects per batch |
/admin/admin_manage_timetable |
Build timetables |
/admin/admin_manage_staff |
Register and manage staff |
/admin/admin_manage_fees |
Set fee amounts and due dates |
/admin/admin_manage_notification |
Send notifications |
/admin/admin_view_students1 |
Browse students by batch |
/admin/admin_view_reports |
Reports overview |
/admin/admin_view_attendance_report |
Full attendance report |
/admin/admin_view_mark_report |
Full marks report |
/admin/admin_view_payments_report |
Full payments report |
/admin/admin_view_students_report |
Full student list report |
| Login URL | /public_login |
| Username | staff |
| Password | staff |
| Endpoint | Description |
|---|---|
/staff/staff_home |
Staff dashboard |
/staff/staff_manage_parents |
Register and manage parents |
/staff/staff_manage_students |
Register and manage students |
/staff/staff_manage_attendance |
Mark and update attendance |
/staff/staff_scheduling_exams1 |
Schedule exams |
/staff/staff_updating_marks |
Enter and update student marks |
/staff/staff_view_messages |
View and reply to student messages |
/staff/staff_view_notifications |
View admin notifications |
Students and parents access the system via the Android companion app, which connects to the REST API below. They log in with the credentials created by staff.
| Sample credentials | Username | Password |
|---|---|---|
| Parent | p1 |
p1 |
| Student | s1 |
s1 |
All endpoints accept GET or POST. Parameters are passed as query strings.
| Endpoint | Parameters | Description |
|---|---|---|
/api/login |
username, password |
Authenticate any user |
/api/parent_view_students |
login_id |
Get children linked to a parent |
/api/parent_view_attendance |
stid |
Get a student's attendance |
/api/parent_view_marklist |
stid |
Get a student's marks |
/api/parent_view_exam_dates |
β | Get all exam schedules |
/api/parent_view_fees |
β | Get fee details |
/api/parent_make_payment |
login_id, fee_ids, fee_amounts |
Record a fee payment |
/api/student_view_attendance |
login_id |
Get own attendance |
/api/student_view_marklist |
login_id |
Get own marks |
/api/student_view_exam_details |
β | Get exam schedule |
/api/student_view_timetable |
login_id |
Get own timetable |
/api/student_view_stdy_materials |
β | Get study materials |
/api/student_message_staff |
loginid, staff_id, messages |
Send a message to staff |
/api/student_view_message_staff |
loginid, staff_id |
View message thread |
- Manage batches, subjects, and timetables
- Register and manage staff accounts
- View student lists, attendance reports, mark reports, and payment reports
- Send notifications to all users
- Register parents and students (auto-sends login credentials via email β requires SMTP credentials in environment variables)
- Manage and view student attendance (parents are notified by email when a student is absent β requires SMTP credentials in environment variables)
- Schedule exams and update student marks
- View and reply to messages from students
- Students: view attendance, exam details, marks, timetable, study materials, and message staff
- Parents: view their children's attendance, marks, exam dates, fees, and make payments
- All Android app functionality is served by a JSON API (
/api/...) - Replaces the original
demjsondependency with Flask's nativejsonify
| Layer | Technology |
|---|---|
| Backend | Python 3.10+, Flask 3.0 |
| Database | PostgreSQL (via psycopg2) |
| Gmail SMTP (via smtplib) β disabled on free tier | |
| Deployment | Railway / Render (Gunicorn) |
| Mobile | Android (Java), Volley HTTP |
| Frontend | Jinja2 templates, Bootstrap |
This project was originally built during my bachelor's degree. When revisiting it, I identified and fixed several security issues:
- SQL Injection (OWASP A03:2021): All raw string-formatted queries were replaced with parameterised queries using
psycopg2's%splaceholders. - Hardcoded credentials: Gmail passwords and database credentials were removed from source code and moved to environment variables via
python-dotenv. - Secret key: Flask's
secret_keyis now loaded from the environment, never committed to Git. - Debug mode:
debug=Trueis now only enabled whenFLASK_ENV=developmentis set.
# 1. Clone the repository
git clone https://github.com/Chithranjaly/smart-department.git
cd smart-department
# 2. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Set up environment variables
cp .env.example .env
# Edit .env with your database URL, secret key, and Gmail app password
# 5. Create the database schema
psql $DATABASE_URL < schema.sql
# 6. Run the application
python main.pyVisit http://localhost:5000
| Variable | Description |
|---|---|
SECRET_KEY |
Random secret for Flask session signing |
DATABASE_URL |
PostgreSQL connection string |
MAIL_USERNAME |
Gmail address used to send credential emails |
MAIL_PASSWORD |
Gmail App Password (not your regular password) |
Note on email in the live demo: Render's free tier blocks outbound SMTP connections. Email notifications are fully implemented in the code but disabled on the live demo. To enable locally, configure
MAIL_USERNAMEandMAIL_PASSWORDin your.envfile. In a production environment, a transactional email service such as SendGrid would be used instead.
- Push this repo to GitHub
- Go to Render and create a PostgreSQL database
- Add a PostgreSQL plugin β Railway auto-sets
DATABASE_URL - Add your other environment variables (
SECRET_KEY,MAIL_USERNAME,MAIL_PASSWORD) - Deploy β Railway reads the
Procfileand runsgunicorn main:app
smart-department/
βββ main.py # App entry point, blueprint registration
βββ database.py # PostgreSQL connection helpers (select/insert/update/delete)
βββ public.py # Public routes: home page, login
βββ admin.py # Admin blueprint
βββ staff.py # Staff blueprint
βββ api.py # REST API for the Android app
βββ templates/ # Jinja2 HTML templates
βββ static/ # CSS, JS, fonts, images
βββ schema.sql # Database schema (import this to set up PostgreSQL)
βββ requirements.txt
βββ Procfile # For Railway/Render deployment
βββ .env.example # Template for environment variables
βββ .gitignore
The Android app (in the /Android folder of the original project) connects to the Flask REST API. It supports:
- Configurable server IP/port from within the app settings
- Student and parent login flows
- All read and write operations listed in the API section above
This project was developed as an academic final-year project. Feel free to use it as a reference.
The Android companion app is for students and parents. It connects to the live Flask API.
- Download the APK from the
android/app-debug.apkfile in this repo - Transfer it to your Android device
- Enable "Install from unknown sources" in your device settings
- Install the APK
- Open the app β it will show an IP Settings screen first
- Enter the live server URL:
https://smart-department.onrender.com - Tap Save and proceed to login
Use the credentials created by staff via the Staff Portal. Sample credentials from the demo database:
| Role | Username | Password |
|---|---|---|
| Student | s1 |
s1 |
| Parent | p1 |
p1 |
Students:
- View attendance records
- View exam schedule and marks
- View timetable
- Download study materials
- Message staff and view replies
Parents:
- View their children's profiles
- View attendance and marks
- View exam dates and fee details
- Make fee payments
The full Android source code (Java) is in the android/ folder of this repository.