A modern, location-based attendance management system built with Next.js 14 and Firebase, designed for educational institutions. Features multi-organization support, GPS-verified attendance, AI-powered notes generation, and a beautiful modern UI.
- Create Organizations: Set up your educational institution with custom settings
- Invite Teachers: Share unique 8-character invite codes for easy onboarding
- Role-Based Access: Organization admins vs teachers with different permissions
- Data Isolation: Complete separation of data between organizations
- GPS-based verification using the Haversine formula
- Configurable radius validation (default: 700 meters)
- Real-time location tracking and distance calculation
- Organization-specific location settings
- Firebase Authentication: Email/password and Google sign-in
- Secure Sessions: Managed through Firebase Auth
- Organization Scoping: All data queries scoped to user's organization
- Activity Logging: Track all user actions for audit purposes
- Digital Attendance Marking: Secure attendance recording with GPS verification
- Schedule Management: View and manage daily/weekly class schedules
- Statistics Dashboard: Comprehensive attendance analytics and reports
- Todo List: Personal task management for teachers
- Important Dates: Interactive event calendar for academic milestones
- Admin Panel: Manage users, schedules, and tasks (for admins)
- PDF Text Extraction: Upload PDFs and extract text using OCR.Space API
- Smart Summarization: Generate concise notes using Google Gemini AI
- Document Repository: Store and manage teaching materials
- Formatted Output: Well-structured notes with bullet points
- Dark/Light Theme: Beautiful theme switcher with smooth transitions
- Responsive Design: Mobile-first approach with Tailwind CSS
- Component Library: Built with shadcn/ui components
- Smooth Animations: Engaging user experience with custom animations
- Glassmorphism & Gradients: Modern, premium design aesthetic
- Vercel Analytics: Page view tracking and user analytics
- Speed Insights: Web Vitals monitoring (LCP, FID, CLS)
- Activity Logs: Comprehensive user action tracking
Before you begin, ensure you have:
- Node.js (v18.0.0 or higher)
- npm or pnpm (package manager)
- Git (for version control)
- Firebase Project (for authentication and database)
-
Clone the repository
git clone https://github.com/Stranger1298/teacher-attendance-system--1-.git cd teacher-attendance-system--1- -
Install dependencies
npm install # or pnpm install -
Set up environment variables
cp .env.example .env.local
-
Configure Firebase (see Environment Configuration below)
-
Run the development server
npm run dev
-
Open http://localhost:3000 in your browser
Create a .env.local file in the root directory:
# Firebase Config (get from Firebase Console > Project Settings)
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id# Google Gemini AI (for notes generation)
GEMINI_API_KEY=your_gemini_api_key
# OCR.Space API (for PDF text extraction)
OCR_API_KEY=your_ocr_api_key# Default College Location (can be overridden per organization)
COLLEGE_LATITUDE=13.072204074042398
COLLEGE_LONGITUDE=77.50754474895987The application uses the following Firestore collections:
{
uid: "user_id",
email: "[email protected]",
displayName: "John Doe",
photoURL: "https://...",
role: "teacher",
organizationId: "org_id",
organizationRole: "admin" | "teacher",
organizationName: "Springfield School",
createdAt: Timestamp,
lastLoginAt: Timestamp
}{
id: "org_id",
name: "Springfield School",
slug: "springfield-school-a1b2",
address: "123 Main St",
city: "Springfield",
state: "IL",
country: "USA",
inviteCode: "ABC12345",
adminId: "user_id",
adminEmail: "[email protected]",
memberCount: 25,
locationRadius: 700,
settings: {
attendanceEnabled: true,
locationVerification: true,
workingHours: { start: "09:00", end: "17:00" }
},
createdAt: Timestamp,
updatedAt: Timestamp
}{
userId: "user_id",
organizationId: "org_id",
records: [{
date: "2024-01-15",
timeIn: "9:00:00 AM",
status: "present",
location: { latitude: 13.07, longitude: 77.50, distance: 150 }
}],
presentDays: 20,
absentDays: 2,
totalDays: 22,
lastMarked: Timestamp
}{
userId: "user_id",
organizationId: "org_id",
action: "attendance_marked",
details: { date: "2024-01-15", time: "9:00 AM" },
timestamp: Timestamp,
date: "2024-01-15"
}Add these rules to your Firestore:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users can read/write their own data
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Organization members can read org data
match /organizations/{orgId} {
allow read: if request.auth != null;
allow write: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.organizationRole == 'admin';
}
// Attendance scoped to user
match /attendance/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}teacher-attendance-system/
βββ app/ # Next.js 14 App Directory
β βββ api/ # API Routes
β β βββ attendance/mark/ # Attendance marking (Firebase)
β β βββ config/location/ # College location config
β β βββ notes/ # Notes processing APIs
β βββ admin/ # Admin panel pages
β β βββ users/ # User management
β β βββ schedule/[userId]/ # Schedule editor
β β βββ tasks/ # Task management
β βββ dashboard/ # Main dashboard
β βββ onboarding/ # Organization onboarding
β βββ org/ # Organization management
β β βββ settings/ # Org settings (admin)
β β βββ members/ # Member management (admin)
β βββ join/[code]/ # Join organization via invite
β βββ important-dates/ # Events calendar
β βββ notes/ # AI notes generation
β βββ schedule/ # Schedule view
β βββ statistics/ # Attendance stats
β βββ page.tsx # Login page
βββ components/ # Reusable React components
β βββ ui/ # shadcn/ui components
β βββ header.tsx # Navigation header
β βββ admin-sidebar.tsx # Admin navigation
β βββ important-dates-calendar.tsx
β βββ todo-list.tsx
βββ lib/ # Utility functions
β βββ firebase/ # Firebase modules
β β βββ config.ts # Firebase configuration
β β βββ auth.ts # Authentication functions
β β βββ AuthContext.tsx # Auth context provider
β β βββ firestore.ts # Firestore CRUD operations
β β βββ organizations.ts # Organization management
β βββ distance-calculator.ts # Haversine formula
β βββ utils.ts # General utilities
βββ .env.local # Environment variables
βββ middleware.ts # Next.js middleware
βββ package.json # Dependencies
-
Sign Up / Login
- Use email/password or Google sign-in
- First-time users are redirected to onboarding
-
Create or Join Organization
- Create: Set up your school/college as admin
- Join: Enter invite code from your admin
-
Mark Attendance
- Click "Verify My Location" on dashboard
- Must be within organization's defined radius
- Click "Mark Attendance" when verified
-
Explore Features
- View your schedule
- Check attendance statistics
- Generate AI-powered notes from PDFs
- Manage important dates and todos
-
Access Organization Settings
- Click "Organization" in header menu
- Manage settings, invite code, and members
-
Invite Teachers
- Copy your organization's invite code
- Share with teachers to join
- Regenerate code if needed for security
-
Manage Members
- View all organization members
- Promote teachers to admin
- Remove members if needed
-
Configure Attendance
- Set location radius for verification
- Configure working hours
- Enable/disable location verification
- User Management: View and manage all users
- Schedule Editor: Assign/modify teacher schedules
- Task Management: Create tasks and notices
- Statistics: View organization-wide stats
- Handled entirely by Firebase Auth
- Supports email/password and Google OAuth
- Session managed via Firebase tokens
POST /api/attendance/mark
{
userId: string,
timestamp: string,
location: { latitude, longitude, distance },
organizationId: string
}
// Saves to Firebase Firestore with activity loggingPOST / api / notes / ocr; // Extract text from PDF
POST / api / notes / generate; // Generate notes with Gemini AI-
Connect Repository
- Import project to Vercel
- Connect your GitHub repository
-
Configure Environment Variables
- Add all
.env.localvariables to Vercel dashboard
- Add all
-
Deploy
- Automatic deployment on push to main branch
The app includes built-in Vercel Analytics and Speed Insights:
- Page view tracking
- Web Vitals monitoring
- Works automatically when deployed to Vercel
| Issue | Solution |
|---|---|
| Firebase auth not working | Check Firebase config in .env.local |
| Location not verifying | Ensure HTTPS and location permissions |
| Organization not loading | Check Firestore rules and user's organizationId |
| Build errors | Run npm install and check TypeScript errors |
The app includes console logging for development:
- Auth state changes
- Organization loading
- API responses
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License.
Aman Raj
- GitHub: @Stranger1298
- Project: Teacher Attendance System
- Next.js - React framework
- Firebase - Authentication & database
- shadcn/ui - Component library
- Tailwind CSS - Styling
- Google Gemini AI - Notes generation
- OCR.Space - PDF text extraction
- Vercel - Hosting & analytics
Made with β€οΈ for Education
Modernizing attendance tracking in educational institutions with security, multi-tenancy, and ease of use.