Skip to content

Repository files navigation

Automated Hostel Entry/Exit Logging System

This project is a Minimum Viable Prototype (MVP) for an automated student entry and exit logging system designed for university hostels. It features a geolocation-secured gate terminal, role-based access control, and a real-time tracking admin dashboard, all wrapped in a modern, premium Glassmorphism UI.

🚀 Features & Implementation Details

1. Secure Authentication & Role-Based Access

  • Students: Secure login with ID and password. First-time login requires users to reset their password and configure a recovery PIN.
  • Admin: Dedicated admin portal to monitor hostel activity, export reports, and resolve alerts.
  • Passwords: Securely hashed using PBKDF2 with SHA256 (werkzeug.security).

2. Geolocation-Based Security (Geofencing)

To prevent proxy attendance or remote entries, the system ensures the student is physically present at the gate before allowing a scan.

  • Implementation: The frontend captures the user's current GPS location (Latitude & Longitude) and sends it with the scan request.
  • Algorithm: The backend uses the Haversine Formula to calculate the distance between the user's coordinates and the fixed gate coordinates.
  • Distance Threshold: 50 meters. If the distance is > 50 meters, the API returns a 403 Forbidden error.

3. Automated State Toggling

The system intelligently switches between "Entry" and "Exit" actions without requiring the user to specify their intent.

  • Implementation: When a valid scan hits the /api/scan endpoint, the system checks the student's current status (Inside or Outside).
  • Logic:
    • If Inside ➔ Marks as Outside and logs as Exit.
    • If Outside ➔ Marks as Inside and logs as Entry.

4. Real-Time Admin Dashboard & Alerts

The admin panel offers live monitoring of the hostel occupancy without needing page refreshes.

  • Implementation: The dashboard utilizes frontend JavaScript polling to continuously fetch updates from the /api/dashboard REST endpoint.
  • Data Provided:
    • Live Occupancy Counter: Real-time count of students currently inside the hostel.
    • Activity Feed: Recent entries and exits with formatted timestamps.
    • Curfew Alerts: Automated flagging of movements during curfew hours (10:00 PM to 6:00 AM). Admins can resolve alerts with custom remarks.
    • CSV Exports: Admins can export detailed activity logs and violation reports between specific dates.

5. Relational Database Management (SQLite3)

A lightweight SQLite database (hostel.db) handles data persistence. The backend (app.py) automatically initializes and prepopulates this database on first run if it doesn't exist.

6. Premium Glassmorphism UI

To provide a highly polished, aesthetic user experience, the system utilizes a unified modern CSS design.

  • Implementation: Uses a dynamic mesh gradient background and semi-transparent 'glass' containers using CSS backdrop-filter: blur(16px).

🛠️ Tech Stack

  • Backend: Python 3, Flask
  • Database: SQLite3
  • Frontend: HTML5, Vanilla JavaScript, CSS3
  • Security: Werkzeug Security (Password Hashing)

⚙️ How to Run

  1. Make sure you have Python 3 installed.
  2. Install the required dependencies:
    pip install -r requirements.txt
  3. (Optional) Reset the admin account password to the default if you are locked out:
    python reset_admin.py
  4. Run the application:
    python app.py
  5. Endpoints accessible at port 5001:
    • Login Flow: http://localhost:5001/login
    • Gate Terminal: http://localhost:5001/gate
    • Admin Dashboard: http://localhost:5001/admin

(Note: To successfully test a scan on localhost, you may need to either be physically close to the hardcoded coordinates, spoof your browser's geolocation, or temporarily modify GATE_LAT and GATE_LON in app.py to match your actual location.)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages