Skip to content

Latest commit

Β 

History

History
239 lines (185 loc) Β· 7 KB

File metadata and controls

239 lines (185 loc) Β· 7 KB
# 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