# Trinity Attend π A comprehensive university attendance tracking system built with Next.js 16, React 19, TypeScript, Tailwind CSS v4, and PostgreSQL. ## β¨ Features ### For Students - π± QR code scanning with geolocation validation (100m radius) - π Real-time attendance tracking - π Visual analytics and progress tracking - π Multi-semester course management - π Automatic session progression - π₯ Export attendance records - π Dark/Light mode support ### For Teachers - π QR code generation with location validation - π₯ Student enrollment management - π Comprehensive analytics dashboard - π Performance tracking and reporting - π₯ Export to Excel/PDF - π― Course management - π Advanced filtering and sorting ## π Tech Stack - **Framework**: Next.js 16 (App Router) - **UI Library**: React 19 - **Language**: TypeScript - **Styling**: Tailwind CSS v4 + Shadcn UI - **Authentication**: Better Auth - **Database**: PostgreSQL (Neon) - **ORM**: Prisma - **State Management**: TanStack Query + Zustand - **Forms**: React Hook Form + Zod - **Charts**: Recharts - **QR Codes**: qrcode.react ## π Prerequisites - Node.js 18.17.0 or higher - npm 9.0.0 or higher - PostgreSQL database (Neon recommended) ## π Getting Started ### 1. Install Dependencies ```bash cd c:\Users\HP\Desktop\trinity-attend npm install ``` ### 2. Environment Setup Create a `.env.local` file in the root directory: ```env # Database (Get from Neon: https://neon.tech) DATABASE_URL="postgresql://username:password@host/database?sslmode=require" # Better Auth (Generate using: node -e "console.log(require('crypto').randomBytes(32).toString('base64'))") AUTH_SECRET="your-super-secret-key-minimum-32-characters-long" AUTH_URL="http://localhost:3000" BETTER_AUTH_SECRET="your-better-auth-secret-key" # OAuth Providers (Optional) # Google: https://console.cloud.google.com/ GOOGLE_CLIENT_ID="your-google-client-id" GOOGLE_CLIENT_SECRET="your-google-client-secret" # Apple: https://developer.apple.com/ APPLE_CLIENT_ID="your-apple-client-id" APPLE_CLIENT_SECRET="your-apple-client-secret" # Email (Resend: https://resend.com/) RESEND_API_KEY="your-resend-api-key" FROM_EMAIL="noreply@trinityattend.com" # App Config NEXT_PUBLIC_APP_URL="http://localhost:3000" NEXT_PUBLIC_APP_NAME="Trinity Attend" # File Upload (Cloudinary: https://cloudinary.com/) NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="your-cloud-name" CLOUDINARY_API_KEY="your-api-key" CLOUDINARY_API_SECRET="your-api-secret" # QR Code Security (Generate using: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))") QR_CODE_SECRET="your-qr-code-hmac-secret-key" # Geolocation (for 100m radius validation) NEXT_PUBLIC_ENABLE_GEOLOCATION="true" NEXT_PUBLIC_MAX_DISTANCE_METERS="100" ``` ### 3. Database Setup ```bash # Push Prisma schema to database npm run db:push # Seed the database with sample data npm run db:seed # (Optional) Open Prisma Studio to view/edit data npm run db:studio ``` ### 4. Run Development Server ```bash npm run dev ``` Open [http://localhost:3000](http://localhost:3000) in your browser. ## π Environment Variables Setup Guide ### Required API Keys and How to Get Them: 1. **DATABASE_URL** (Required) - Sign up at [Neon](https://neon.tech) - Create a new project - Copy the connection string - Ensure it ends with `?sslmode=require` 2. **AUTH_SECRET & QR_CODE_SECRET** (Required) - Generate using Node.js: ```bash node -e "console.log(require('crypto').randomBytes(32).toString('base64'))" ``` 3. **GOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET** (Optional) - Go to [Google Cloud Console](https://console.cloud.google.com/) - Create a new project or select existing - Enable Google+ API - Create OAuth 2.0 credentials - Add authorized redirect URI: `http://localhost:3000/api/auth/callback/google` 4. **APPLE_CLIENT_ID & APPLE_CLIENT_SECRET** (Optional) - Go to [Apple Developer](https://developer.apple.com/) - Create a Services ID - Configure Sign in with Apple - Add return URL: `http://localhost:3000/api/auth/callback/apple` 5. **RESEND_API_KEY** (Optional, for emails) - Sign up at [Resend](https://resend.com/) - Get your API key from the dashboard - Verify your domain for production 6. **CLOUDINARY Credentials** (Optional, for file uploads) - Sign up at [Cloudinary](https://cloudinary.com/) - Get Cloud Name, API Key, and API Secret from dashboard ## π§ͺ Demo Credentials After running `npm run db:seed`, you can use: **Teacher Account:** - Email: `teacher@demo.com` - Password: `Demo@1234` **Student Account:** - Matric: `2022/1/12345` OR Email: `student@demo.com` - Password: `Demo@1234` ## π Available Scripts ```bash npm run dev # Start development server npm run build # Build for production npm run start # Start production server npm run lint # Run ESLint npm run db:push # Push schema changes to database npm run db:seed # Seed database with sample data npm run db:studio # Open Prisma Studio ``` ## π Project Structure ``` trinity-attend/ βββ prisma/ β βββ schema.prisma # Database schema β βββ seed.ts # Seed script βββ src/ β βββ app/ # Next.js App Router β β βββ (auth)/ # Authentication pages β β βββ (dashboard)/ # Protected dashboard pages β β βββ api/ # API routes β β βββ page.tsx # Landing page β βββ components/ # React components β βββ lib/ # Utility libraries β β βββ auth.ts # Better Auth config β β βββ db.ts # Prisma client β β βββ utils.ts # Utility functions β β βββ validations/ # Zod schemas β βββ actions/ # Server actions β βββ hooks/ # Custom React hooks βββ public/ # Static assets ``` ## π§ Next Steps This is the initial setup. To complete the application, you need to: 1. β Install dependencies 2. β Set up environment variables 3. β Initialize database 4. π Create authentication pages (login/signup) 5. π Build student dashboard 6. π Build teacher dashboard 7. π Implement QR code system with geolocation 8. π Add Excel/PDF export functionality 9. π Deploy to production ## π Security Features - Password hashing with bcrypt - HMAC-SHA256 QR code signatures - Geolocation validation (100m radius) - Time-limited QR codes (10 min default) - Better Auth session management - CSRF protection - Rate limiting (to be implemented) ## π Support For issues or questions: - Open an issue on GitHub - Email: support@trinityattend.com --- **Made with β€οΈ for educational institutions** # trinity-attend