A full-stack, enterprise-grade college administration platform built for BMS College of Commerce & Management (Basavanagudi Campus). Featuring Cloud PostgreSQL, Smart Anti-Spoofing Attendance with GPS Geofencing, AI OCR Document Ingestion, Centralized 8-Event Email Dispatch, Master Workforce Control, and a Secure-by-Design Gemini AI Operations Assistant.
Key Features β’ System Architecture β’ RBAC Matrix β’ Notification Engine β’ AI Assistant β’ Installation & Setup β’ Deployment Guide
The BMS College ERP is designed to replace fragmented legacy college software with a single unified, secure, high-performance platform.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BMS COLLEGE ERP CENTRAL ENGINE β
β (Flask 3.1.3 + Supabase Cloud PostgreSQL DB) β
βββββββββββββββ¬ββββββββββββββββββββββββββββββββ¬ββββββββββββββ
β β
ββββββββββββββββββββββββββββ΄βββββββββββββββ ββββββββββββββ΄ββββββββββββββββββββββββββββ
β π‘οΈ Anti-Spoofing Attendance β β π€ Secure Operational AI Assistant β
β β’ Basavanagudi GPS Geofence (1000m) β β β’ Whitelisted Read-Only Functions β
β β’ 30s HMAC Rotating QR Kiosk β β β’ 3-Tier Security Role Gate β
β β’ Signed Hardware Device Binding β β β’ Zero Direct SQL / No DB Access β
βββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ
β β
ββββββββββββββββββββββββββββ΄βββββββββββββββ ββββββββββββββ΄ββββββββββββββββββββββββββββ
β π§ Centralized Email Engine (8 Events) β β π Master Workforce Directory β
β β’ Auto-Generated Payslip PDFs β β β’ Full Personnel Records & Demographicsβ
β β’ Fail-Safe PostgreSQL Audit Log β β β’ Live Edit Modal (PostgreSQL Save) β
βββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ
- Basavanagudi Campus GPS Perimeter: Mandatory GPS verification requiring staff to clock in within 1000m radius of BMSCCM Basavanagudi Campus (
12.9515Β° N, 77.5762Β° E). - 30-Second Rotating HMAC QR Tokens: Dynamic QR kiosk (
/qr_attendance) generating auto-refreshing TOTP/HMAC QR codes to defeat off-site screenshot sharing. - Hardware Device Binding: Tracks signed device cookies and hardware hashes in
RegisteredDevicetable; flags unrecognized devices for HR review. - Working-Hours Intelligence: Calculates work hours (09:00 AM β 05:00 PM), 10-minute grace period, late arrivals, early departures, and overtime hours.
- Dedicated Route:
/admin/staff_master(Restricted strictly toHR,Accountant,admin). - Complete Personnel View: Displays Name, Role, Username, Email, Phone, Address, Department, Dept ID, DOB, Joining Date, Caste, Religion, Status, and Net Payroll.
- Master Live Profile Edit: Interactive modal allowing Admin to update any staff member's complete profile directly in PostgreSQL.
- Restricted Route:
/digital_vault(Admin Department Only). - AI OCR Document Scanner: Uses
pytesseractand image fallback parsing to extract names, emails, phones, departments, and salaries from uploaded ID card or document images. - Instant "β Add Employee" Modal: Pre-fills extracted credentials into an interactive modal so Admin can register new staff to PostgreSQL in 1 click.
- Single Dispatch Engine:
notify(event, user, context)powered by Flask-Mail and Gmail SMTP. - PDF Payslip Attachments: Automatically generates and attaches official PDF payslips.
- Fail-Safe Guarantee: Dispatch errors log as
FAILEDinnotification_logwithout crashing application routes. - Diagnostic Self-Test Hub: Live diagnostic test page at
/notifications/selftest.
- Whitelisted Function Router: Gemini model selects from whitelisted Python functions only (never writes SQL or touches DB directly).
- 3-Tier Access Model:
- Tier 1 (All Staff): Presence, check-in times, lecture schedules, class rooms, headcount.
- Tier 2 (Management Only): Leave reasons, late arrivals, overtime, notification logs.
- Tier 3 (FORBIDDEN BY DESIGN): Salary, PF, Tax, DOB, address, and personal markers are absent from the whitelist menu. Refused politely.
- Audit Logging: Every AI query, selected tool, user role, and status recorded in
AuditLog.
| Portal Feature / Route | Faculty Member | HOD | Principal | Accountant | System Admin / HR |
|---|---|---|---|---|---|
| Personal Dashboard & Profile | β | β | β | β | β |
| GPS / QR Attendance Clock-In | β | β | β | β | β |
| View Individual Payroll | β (Own) | β (Own) | β (Own) | β (All) | β (All) |
| Leave Request Submission | β | β | β | β | β |
| Leave Approval System | β | β (Dept) | β (All) | β | β (All) |
| Add New Employee | β | β | β | β | β |
| Digital Document Vault & OCR | β | β | β | β | β |
| Master Workforce Directory | β | β | β | β | β |
| Notification Hub & Diagnostics | β | β | β | β | β |
| AI Operations Assistant | Tier 1 | Tier 1+2 | Tier 1+2 | Tier 1+2 | Tier 1+2 |
| # | Event Key | Trigger Location | Attachment | Event Email Content & Context |
|---|---|---|---|---|
| 1 | salary_credited |
/edit_salary/<uid> / Payroll |
π Payslip PDF | Salary credited notice with net amount & month |
| 2 | payslip_delivery |
/send_payslip_email/<uid> |
π Payslip PDF | Digital payslip delivery with verification code |
| 3 | leave_decision |
/leave/action/<id>/<action> |
β | Leave Approval / Rejection update with reason |
| 4 | expense_decision |
/approve_expense/<id>/<action> |
β | Expense Claim Approval / Rejection update with amount |
| 5 | task_assigned |
/assign_task |
β | New institutional task assignment notice with assigner name |
| 6 | new_device_login |
/login (New Device) |
β | Security Alert with IP address, browser & timestamp |
| 7 | missing_checkout |
/attendance/daily_close |
β | Evening check-out reminder nudge |
| 8 | monthly_attendance_summary |
/attendance/monthly_summary |
β | Monthly attendance statement (days present, lates, missing outs) |
ββββββββββββββββββββββββββββββββββββββββββ
β User Question (Natural Language) β
βββββββββββββββββββββ¬βββββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β Tier 3 Forbidden Keyword β
β Detection Gate β
βββββββββ¬ββββββββββββββββ¬ββββββββ
Contains Forbidden β β Allowed Query
(Salary, DOB, etc.)β β
βΌ βΌ
βββββββββββββββββββββ βββββββββββββββββββββββββββββ
β π POLITE DENIAL β β Gemini Whitelist Router β
β (No DB Execution)β β (Selects Python Tool) β
βββββββββββββββββββββ βββββββββββββββββ¬ββββββββββββ
β
βββββββββββββββββ΄ββββββββββββ
β Python Whitelist Engine β
β (Role Gate & Resolver) β
βββββββββββββββββ¬ββββββββββββ
β
βββββββββββββββββ΄ββββββββββββ
β Execute Read-Only Query β
β & Log to AuditLog β
βββββββββββββββββββββββββββββ
- Backend: Python 3.10+, Flask 3.1.3, Flask-SQLAlchemy 3.1.1, Flask-Login, Flask-SocketIO, Flask-Mail.
- Database: Supabase Cloud PostgreSQL (
psycopg2-binary) with local SQLite fallback. - AI & Computer Vision: Google Gemini API (
google-generativeai), Tesseract OCR (pytesseract), Pillow (PIL). - PDF & Barcode Generation: FPDF (
fpdf), QR Code (qrcode). - Frontend: Vanilla HTML5, Modern CSS Glassmorphic Design System (
professional-office-portal.css), JavaScript (ES6+), FontAwesome 6, Socket.IO Client.
- Python 3.10 or higher installed.
- Git installed.
- Tesseract OCR (Optional, for document vault scanning).
-
Clone the Repository:
git clone https://github.com/pk7745/erp.git cd erp -
Create and Activate Virtual Environment:
python -m venv venv # On Windows: .\venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment Variables (
.env): Create a.envfile in the root directory:SECRET_KEY=bms_erp_secret_key_2026 PORT=9000 # Supabase Cloud PostgreSQL URL DATABASE_URL=postgresql://postgres:BmsErp2026!@db.kjgxfdccvsecsyzcmost.supabase.co:5432/postgres # Gmail SMTP Email Dispatch Credentials MAIL_USERNAME=your_gmail@gmail.com MAIL_PASSWORD=your_16_char_gmail_app_password # Google Gemini AI API Key (Optional) GEMINI_API_KEY=your_gemini_api_key_here
-
Run the Application:
python app.py
-
Access the Portal: Open
http://127.0.0.1:9000in your web browser.
- Log in to Render Dashboard.
- Click New + β Web Service and connect repository
pk7745/erp. - Configure settings:
- Runtime:
Python 3 - Build Command:
pip install -r requirements.txt - Start Command:
gunicorn app:app
- Runtime:
- Add Environment Variables (
DATABASE_URL,MAIL_USERNAME,MAIL_PASSWORD,GEMINI_API_KEY). - Click Deploy Web Service.
- Import repository
pk7745/erpinto Vercel Dashboard. - The included
vercel.jsonwill automatically configure WSGI routing. - Set environment variables under Project Settings and click Deploy.
Developed with β€οΈ for BMS College of Commerce & Management (Basavanagudi Campus). Released under the MIT License.