Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📍 Mobile Attendance System (Geofencing-Based)

Node.js Express.js MongoDB Expo TypeScript License

A location-aware mobile attendance system that uses GPS Geofencing to automatically verify whether a student is physically present within an authorized zone before marking attendance. Built with Node.js + Express backend and Expo (React Native + TypeScript) frontend.


🚀 Features

  • 📡 GPS-Based Geofencing — Attendance is only marked when the user is within a predefined geographic radius
  • 🔐 Role-Based Access Control — Separate dashboards for Admins, Teachers, and Students
  • 🕐 Real-Time Attendance Tracking — Live status updates with timestamps
  • 📊 Attendance Reports — View attendance history by date, user, or department
  • 🔔 Push Notifications — Alerts for attendance windows opening/closing
  • 🌐 RESTful API Backend — Clean, documented API endpoints for all operations
  • 📱 Cross-Platform Mobile App — Works on both Android and iOS via Expo

🛠️ Tech Stack

Layer Technology
Frontend React Native + Expo (TypeScript)
Routing Expo Router (file-based)
Backend Node.js + Express.js
Database MongoDB + Mongoose
Auth JWT (JSON Web Tokens)
Location Expo Location API
Geofencing Haversine Formula
Language TypeScript (frontend), JavaScript (backend)

📁 Project Structure

MOBILE-APP/
├── attendance-backend/
│   ├── controllers/
│   │   ├── authController.js
│   │   ├── attendanceController.js
│   │   └── userController.js
│   ├── models/
│   │   ├── User.js
│   │   ├── Attendance.js
│   │   └── Zone.js
│   ├── routes/
│   │   ├── auth.js
│   │   ├── attendance.js
│   │   └── user.js
│   ├── middleware/
│   │   └── authMiddleware.js
│   ├── utils/
│   │   └── geofence.js
│   └── server.js
│
├── attendance-frontend/
│   ├── app/
│   │   ├── (student-tabs)/       # Student tab navigation
│   │   ├── teacher/              # Teacher screens
│   │   ├── _layout.tsx
│   │   ├── all-students.tsx
│   │   ├── edit-profile.tsx
│   │   ├── index.tsx
│   │   ├── login.tsx
│   │   └── register.tsx
│   ├── assets/
│   ├── components/
│   ├── constants/
│   │   └── api.ts                # API base URL config
│   ├── context/
│   ├── hooks/
│   ├── scripts/
│   ├── app.json
│   ├── expo-env.d.ts
│   └── package.json
│
└── README.md

⚙️ Getting Started

Prerequisites

  • Node.js v18+
  • MongoDB (local or Atlas)
  • Expo CLI: npm install -g expo-cli
  • Expo Go app on your phone or Android Studio / Xcode for emulator

1. Clone the Repository

git clone https://github.com/singh5679/Mobile-Attendance-App.git
cd Mobile-Attendance-App

2. Backend Setup

cd attendance-backend
npm install

Create a .env file:

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
GEOFENCE_RADIUS_METERS=100

Start the server:

npm run dev

3. Frontend Setup

cd attendance-frontend
npm install

Update the API base URL in constants/api.ts:

export const API_URL = "http://<your-local-ip>:5000";

⚠️ Use your machine's local IP (e.g., 192.168.x.x), not localhost, so the mobile device/emulator can reach the backend.

Start the Expo app:

npx expo start

Scan the QR code with Expo Go on your phone, or press a for Android emulator / i for iOS simulator.


🔌 API Endpoints

Auth Routes /api/auth

Method Endpoint Description Auth Required
POST /register Register a new user No
POST /login Login and get JWT token No
GET /me Get current user profile Yes

Attendance Routes /api/attendance

Method Endpoint Description Auth Required
POST /mark Mark attendance (with GPS validation) Yes
GET /my Get current user's attendance history Yes
GET /report/:userId Get attendance report for a user Admin/Teacher
GET /today Get today's attendance list Admin/Teacher

User Routes /api/users

Method Endpoint Description
GET / Get all users
PUT /:id Update user info
DELETE /:id Delete a user

👥 Role Permissions

Feature Student Teacher
Mark Attendance
View Own History
View All Attendance
View All Students
Manage Users
Define Geofence Zones
Export Reports

🗺️ How Geofencing Works

  1. Admin defines an authorized zone with a center coordinate (lat/lng) and a radius in meters.
  2. When a user taps "Mark Attendance", the app captures their current GPS coordinates via Expo Location API.
  3. The backend calculates the Haversine distance between the user's location and the zone center.
  4. If the distance is within the allowed radius → attendance marked ✅; otherwise rejected ❌.
Distance = 2R × arcsin(√(sin²(Δlat/2) + cos(lat1) × cos(lat2) × sin²(Δlng/2)))

📸 Screenshots

Add screenshots of Login, Mark Attendance, Student Dashboard, and Teacher Panel here.


🤝 Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.


👨‍💻 Author

Himanshu Singh
B.Tech CSE | Integral University, Lucknow
🔗 GitHubLinkedIn


⭐ If you found this project useful, please consider giving it a star!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages