Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🎓 Attend-ED | Core API & Geospatial Backend

.NET PostgreSQL Neon JWT

The robust, highly secure ASP.NET Core backend powering the Attend-ED student portal. Designed to solve modern academic challenges like proxy-attendance and location-spoofing, this API leverages PostGIS spatial querying and hardware-level device binding to ensure absolute academic integrity.

✨ Core System Architecture

1. Geospatial Verification Engine

Built on top of NetTopologySuite and PostgreSQL's PostGIS extension, the system utilizes high-accuracy coordinate math (SRID 4326) to enforce physical attendance.

  • Evaluates incoming mobile GPS coordinates against dynamically generated lecture geofences.
  • Accommodates GPS jitter and indoor signal degradation with configurable margin-of-error radii (e.g., 50-100m).

2. Hardware-Level Device Binding

Eliminates proxy sign-ins (students logging in for their friends) by permanently binding a user's database record to a unique cryptographic hardware token generated by their primary device.

  • First-time logins silently register the device's hardware UUID.
  • Subsequent logins from unrecognized devices are blocked at the middleware level with a 401 Unauthorized strict proxy-prevention alert.

3. Role-Based Access Control (RBAC)

Secured via short-lived JSON Web Tokens (JWT). The API strictly segregates endpoints using [Authorize(Roles = "Student")] and [Authorize(Roles = "Lecturer")] attributes, ensuring zero cross-pollution of data or capabilities.


🛠️ Tech Stack & Infrastructure

  • Framework: ASP.NET Core Web API (C#)
  • ORM: Entity Framework Core
  • Database: Serverless PostgreSQL via Neon DB
  • Spatial Data: Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite
  • Deployment: Render / AWS

🚀 Local Setup & Development

Prerequisites

  • .NET 8.0 SDK (or higher)
  • PostgreSQL running locally or a Neon DB connection string.

Configuration

  1. Clone the repository.
  2. Update the appsettings.Development.json with your database connection string.

Note on Neon DB / Pooling: Use the ADO.NET standard Key-Value format to ensure EF Core CLI compatibility: "DefaultConnection": "Host=ep-...;Database=neondb;Username=...;Password=...;Ssl Mode=Require;"

Database Migrations

The schema is code-first. Apply the migrations to build your database:

dotnet ef database update

Running the Server

dotnet run

The API will be available at https://localhost:7042. Test endpoints via the automatically generated Swagger UI.


📡 Key API Endpoints

Method Endpoint Description Auth Required
POST /api/Auth/login Authenticates user & validates hardware token No
POST /api/Student/attendance Verifies GPS coordinates against class geofence Yes (Student)
GET /api/Student/schedule Fetches active classes created in the last 24h Yes (Student)
GET /api/Student/reports/summary Aggregates attendance data for dashboard Yes (Student)

🛡️ Edge Cases Handled

  • PostGIS Coordinate Trap: Correctly maps incoming front-end (Lat, Lng) data to the NetTopologySuite (X: Longitude, Y: Latitude) standard to prevent spatial translation errors.
  • Database Compute Sleep: Configured resilience for Neon DB's serverless cold-starts during EF Core Migrations.

About

A high-performance ASP.NET Core Web API built to ensure absolute academic integrity. It leverages a serverless PostgreSQL database (Neon DB) with PostGIS spatial querying to process high-accuracy GPS geofences in real-time.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages