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.
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).
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 Unauthorizedstrict proxy-prevention alert.
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.
- 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
- .NET 8.0 SDK (or higher)
- PostgreSQL running locally or a Neon DB connection string.
- Clone the repository.
- Update the
appsettings.Development.jsonwith 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;"
The schema is code-first. Apply the migrations to build your database:
dotnet ef database update
dotnet run
The API will be available at https://localhost:7042. Test endpoints via the automatically generated Swagger UI.
| 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) |
- 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.