A comprehensive university management system built with Next.js and TypeScript that integrates RFID card technology for student authentication, attendance tracking, library management, and canteen services.
- Admin Portal: Complete system administration, student & lecturer management
- Student Portal: Academic performance tracking, attendance view, GPA monitoring
- Lecturer Portal: Attendance management, class scheduling, student reports
- Library Portal: Book management, checkout/return system, member administration
- Canteen Portal: Payment processing, transaction management, menu administration
- Real-time RFID card reading and writing
- NFC-based attendance tracking
- Secure card authentication
- Device status monitoring
- User authentication with NextAuth
- Real-time data synchronization with Socket.IO
- PostgreSQL database integration
- File upload and storage with Azure Blob Storage
- Email notifications and password reset
- Responsive UI with Tailwind CSS and shadcn/ui
- Framework: Next.js 15.3.2 with App Router
- Language: TypeScript
- Styling: Tailwind CSS 4.0
- UI Components: Radix UI + shadcn/ui
- Animation: Framer Motion
- State Management: React Hook Form + Zod validation
- Runtime: Node.js
- Database: PostgreSQL
- Authentication: NextAuth
- Real-time: Socket.IO
- Email: Resend
- File Storage: Azure Blob Storage
- RFID/NFC: nfc-pcsc library
- Card Reading: Custom middleware service
- WebSocket: Real-time card communication
- Node.js 18+ and npm
- PostgreSQL database
- RFID/NFC card reader hardware
git clone https://github.com/viduwaa/uni-rfid.git
cd uni-rfid# Install main application dependencies
npm install
# Install middleware dependencies
cd middleware
npm install
cd ..
# Install socket server dependencies
cd socket-server
npm install
cd ..Create a .env.local file in the root directory:
# Database Configuration
PGUSER=your_postgres_user
PGPASSWORD=your_postgres_password
PGHOST=your_postgres_host
PGPORT=5432
PGNAME=your_database_name
# NextAuth Configuration
NEXTAUTH_SECRET=your_nextauth_secret
NEXTAUTH_URL=http://localhost:3000
# Email Configuration
SMTP_HOST=your_smtp_host
SMTP_PORT=587
SMTP_USER=your_smtp_user
SMTP_PASS=your_smtp_password
# Socket.IO Configuration
SOCKET_PORT=3001# Initialize the database with the provided SQL file
psql -U your_username -d your_database -f uni-nfc-final.sql
# Or run the initialization script
npm run db:init# Start the main Next.js application
npm run dev
# In separate terminals, start the additional services:
# Start the Socket.IO server
npm run socket
# Start the NFC middleware
npm run nfc# Build the application
npm run build
# Start the production server
npm startThe application will be available at:
- Main App: http://localhost:3000
- Socket Server: http://localhost:3001
- NFC Middleware: Connects to RFID readers
βββ src/
β βββ app/ # Next.js App Router pages
β β βββ admin/ # Admin portal pages
β β βββ student/ # Student portal pages
β β βββ lecturer/ # Lecturer portal pages
β β βββ library/ # Library portal pages
β β βββ canteen/ # Canteen portal pages
β β βββ api/ # API routes
β βββ components/ # Reusable React components
β β βββ ui/ # shadcn/ui components
β β βββ ... # Custom components
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utility functions and configurations
β βββ types/ # TypeScript type definitions
β βββ scripts/ # Database and utility scripts
βββ middleware/ # NFC/RFID middleware service
βββ socket-server/ # Socket.IO server
βββ public/ # Static assets
βββ ... # Configuration files
POST /api/auth/login- User loginPOST /api/auth/register- User registrationPOST /api/auth/reset-password- Password reset
GET /api/students- Get all studentsPOST /api/students- Create new studentPUT /api/students/[id]- Update studentDELETE /api/students/[id]- Delete student
POST /api/attendance- Mark attendanceGET /api/attendance/[studentId]- Get student attendance
GET /api/library/books- Get all booksPOST /api/library/checkout- Checkout bookPOST /api/library/return- Return book
POST /api/canteen/transaction- Process paymentGET /api/canteen/menu- Get menu items
// Example usage of NFC reader hook
const { cardData, isReading, error } = useNFCReader();// Socket.IO integration for real-time updates
useEffect(() => {
socket.on("cardRead", (data) => {
// Handle card read event
});
}, []);npm run dev- Start development server with Turbopacknpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run db:init- Initialize databasenpm run socket- Start Socket.IO servernpm run nfc- Start NFC middleware
- Authentication: Secured with NextAuth
- Authorization: Role-based access control
- Data Validation: Server-side validation
- SQL Injection Prevention: Parameterized queries
- HTTPS: SSL/TLS encryption support
- CORS: Configured for security
The application is fully responsive and works on:
- Desktop computers
- Tablets
- Mobile phones
- Various screen sizes and orientations
- Dark/Light Mode: Theme switching capability
- Animations: Smooth transitions with Framer Motion
- Accessibility: WCAG compliant components
- Loading States: Skeleton loaders and spinners
- Error Handling: User-friendly error messages
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
RFID Reader Not Working
# Check if the NFC middleware is running
npm run nfc
# Verify hardware connections
# Check system permissions for NFC devicesDatabase Connection Issues
# Verify PostgreSQL is running
sudo systemctl status postgresql
# Check environment variables
echo $PGUSER $PGHOST $PGPORTBuild Errors
# Clear Next.js cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm installThe application includes:
- Error Boundary: React error boundaries for graceful error handling
- Loading States: Skeleton components for better UX
- Caching: Next.js built-in caching strategies
- Optimization: Image optimization and lazy loading
Key tables include:
students- Student information and recordslecturers- Lecturer profiles and permissionsattendance- Attendance tracking datalibrary_books- Book catalog and availabilitycanteen_transactions- Payment and transaction recordsrfid_cards- Card assignments and status
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js for the amazing React framework
- Tailwind CSS for utility-first styling
- shadcn/ui for beautiful components
- Clerk for authentication services
- Socket.IO for real-time communication
- nfc-pcsc for NFC integration
Built for university management and RFID integration as the 2nd year project at university