A comprehensive web-based platform for managing college event participation and tracking loyalty points. The system enables administrators to create events, volunteers to mark attendance, and participants to join teams and compete on a leaderboard.
- Requirements Analysis: We listed down all the requirements in SRS, adding the function and non-functional requirements, UML diagrams.
- Design Phase: We designed the low level and high level architecture of the project using architecture diagrams and planned possible design patterns which can be used.
- Implementation Phase: We implemented the project which follows a three tier client-server-database architecture, by implementing the frontend in ReactJS + Typescript, backend in FAST API (Python) and using MongoDB as the data store.
- Testing Phase: The frontend was testing visually by clicking and testing all features for functionality, responsivness and UI completeness, the backend was tested using pytest which enabled us to test the backend API endpoint functionalities.
- Event Management: Create, update, and delete events with custom points and secret codes.
- Volunteer Management: Add or remove volunteers who can mark attendance
- Dashboard: View comprehensive statistics including total events, participants, and leaderboard
- Event Control: Mark events as expired to prevent further participation
- Full Access: Access to all administrative endpoints and data
- Event Authorization: Authenticate for specific events using secret codes
- QR Code Scanning: Scan team QR codes to mark attendance and award points
- Event Selection: Choose which event they are working on
- Limited Access: Can only access assigned events and attendance marking features
- Team Management: Create or join teams (max 3 members per team)
- Team Dashboard: View team details, points, and participated events
- Join Options: Join teams using join codes or QR codes
- Leaderboard: Track team rankings and compare with other teams
- Event Participation: Earn points by participating in events through team attendance
- Team Actions: Leave team before deadline, view team QR code and join code
- Framework: React 18.3.1 with TypeScript
- Build Tool: Vite 5.4.2
- Styling: Tailwind CSS 3.4.18
- Routing: React Router DOM 7.9.1
- QR Code:
qrcode.reactfor QR generation@yudiel/react-qr-scannerfor QR scanninghtml5-qrcodefor additional scanning support
- HTTP Client: Axios 1.12.2
- Icons: Lucide React 0.344.0
- Framework: FastAPI (Python)
- Database: MongoDB with Motor (async driver)
- Authentication:
- Microsoft OAuth 2.0 (Authlib)
- Session-based auth with Starlette SessionMiddleware
- Security:
- JWT tokens (Python-JOSE) for volunteer authorization
- AES-GCM encryption for secret codes
- Testing: Pytest
- Additional Libraries:
python-dotenvfor environment configurationhttpxfor async HTTP requests
The application follows a traditional 3-tier client-server architecture:
client/
├── public/
│ └── images/ # Static assets
├── src/
│ ├── components/ # React components organized by role
│ │ ├── admin/ # Admin-specific components
│ │ │ ├── AdminDashboard.tsx
│ │ │ ├── EventCard.tsx
│ │ │ ├── EventModal.tsx
│ │ │ ├── FilterModal.tsx
│ │ │ ├── LeaderboardPage.tsx
│ │ │ ├── Navbar.tsx
│ │ │ └── VolunteerModal.tsx
│ │ ├── participant/ # Participant-specific components
│ │ │ ├── ParticipantPortal.tsx
│ │ │ ├── ProfileDropDown.tsx
│ │ │ ├── TeamDashboard.tsx
│ │ │ └── TeamJoinCreate.tsx
│ │ ├── volunteer/ # Volunteer-specific components
│ │ │ ├── EventSelector.tsx
│ │ │ ├── QRScanner.tsx
│ │ │ └── VolunteerPortal.tsx
│ │ ├── shared/ # Shared components
│ │ │ └── ProtectedRoute.tsx
│ │ └── Login.tsx # Login component
│ ├── config/ # Configuration files
│ │ └── config.ts # API URLs and constants
│ ├── hooks/ # Custom React hooks (Business Logic Layer)
│ │ ├── useAuth.tsx # Authentication logic
│ │ ├── useEvents.ts # Event management logic
│ │ ├── useLeaderboard.ts
│ │ ├── useTeams.ts # Team management logic
│ │ ├── useVolunteerActions.ts
│ │ └── useVolunteers.ts
│ ├── models/ # TypeScript interfaces and API service
│ │ ├── props/ # Component prop interfaces
│ │ ├── API_Service.ts # API client wrapper
│ │ ├── Event.ts # Event interface
│ │ ├── Team.ts # Team interface
│ │ └── User.ts # User interface
│ ├── pages/ # Top-level page components
│ │ ├── AdminPage.tsx
│ │ ├── HomePage.tsx
│ │ ├── LeaderboardPage.tsx
│ │ ├── ParticipantPage.tsx
│ │ └── VolunteersPage.tsx
│ ├── service/ # API and utility services
│ │ ├── api.ts # Axios configuration
│ │ └── cryptography.ts # Encryption utilities
│ ├── App.tsx # Root component with routing
│ ├── main.tsx # Application entry point
│ └── index.css # Global styles (Tailwind)
├── index.html # HTML template
├── package.json # Dependencies
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite build configuration
└── tailwind.config.js # Tailwind CSS configuration
The frontend follows Martin Fowler's Presentation Domain Data Layering pattern adapted for React:
-
Presentation Layer (Components)
- Pure UI components focused on rendering
- Minimal business logic
- Organized by feature/role (admin, volunteer, participant)
- Reusable shared components
-
Domain/Business Logic Layer (Custom Hooks)
useAuth: Authentication state and operationsuseEvents: Event CRUD operationsuseTeams: Team management logicuseVolunteers: Volunteer managementuseLeaderboard: Leaderboard data fetching- Encapsulates business rules and state management
-
Data Access Layer (Services)
api.ts: Axios instance with interceptorsAPI_Service.ts: Centralized API callscryptography.ts: Encryption/decryption utilities- Abstracts HTTP communication
-
Models (TypeScript Interfaces)
- Type definitions for data structures
- Prop interfaces for component contracts
- Ensures type safety across layers
Benefits:
- Clear separation of concerns
- Testable business logic
- Reusable hooks across components
- Easy to maintain and scale
| Endpoint | Purpose | Access |
|---|---|---|
/ |
Login home page | All (Unauthenticated) |
/admin |
Admin page | Admin |
/volunteer |
Volunteers' page | Admin,Volunteers |
/participant |
Participants' page | Admin,Volunteers,Participants |
/leaderboard |
Leaderboard page | Admin,Volunteers,Participants |
server/
├── routes/ # API route handlers (Controller Layer)
│ ├── AuthRouter.py # Authentication endpoints
│ ├── EventRouter.py # Event management endpoints
│ ├── VolunteerRouter.py # Volunteer management endpoints
│ ├── AttendanceRouter.py # QR scanning and attendance
│ ├── TeamRouter.py # Team management endpoints
│ └── dependencies.py # Shared dependency functions (NEW)
├── models.py # Pydantic models for request/response
├── database/ # Data Access Layer
│ └── DB.py # Database class with CRUD operations
├── helpers/ # Utility functions and strategies
│ ├── DateTimeSerializer.py # Visitor pattern for datetime serialization
│ ├── QRCodeGenerator.py # QR code generation utilities
│ └── SecretCodeEncryptionStrategy.py # Strategy pattern for encryption
├── config/ # Configuration management
│ └── config.py # Environment variables and settings
├── tests/ # Test suite
│ ├── conftest.py # Pytest fixtures
│ └── test_basic.py # Unit tests
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
└── pyproject.toml # Pytest configuration
File: database/DB.py
Benefits:
- Single MongoDB connection pool
- Prevents resource exhaustion
- Centralized database access
File: helpers/DateTimeSerializer.py
Benefits:
- Separates serialization logic from data structures
- Easy to extend for other types
- Handles nested objects recursively
File: helpers/SecretCodeEncryptionStrategy.py
Benefits:
- Interchangeable encryption algorithms
- Encapsulates encryption logic
- Easy to swap strategies (e.g., RSA, AES-CBC)
File: routes/dependencies.py (Centralized dependencies)
Benefits:
- Automatic authentication/authorization
- Reusable across all routers
- Testable (can mock dependencies)
- Single source of truth
File: database/DB.py
Benefits:
- Abstracts MongoDB operations
- Easy to switch databases
- Consistent error handling
| Endpoint | Method | Purpose | Access | Route File |
|---|---|---|---|---|
| Authentication & Session | ||||
/api/login |
GET | Initiate Microsoft OAuth flow | Public | AuthRouter.py |
/api/auth |
GET | OAuth callback, create session | Public | AuthRouter.py |
/api/health |
GET | Health check endpoint | Public | AuthRouter.py |
/api/user/profile |
GET | Get current user info | Authenticated | AuthRouter.py |
/api/logout |
GET | Clear session, logout | Authenticated | AuthRouter.py |
/api/debug/session |
GET | Debug session data (dev) | Authenticated | AuthRouter.py |
| Event Management | ||||
/api/events |
GET | List all events | Authenticated | EventRouter.py |
/api/events?ids={id1,id2} |
GET | Get specific events by IDs | Authenticated | EventRouter.py |
/api/events |
POST | Create new event | Admin | EventRouter.py |
/api/events/{event_id} |
PUT | Update event details | Admin | EventRouter.py |
/api/events/{event_id} |
DELETE | Delete event | Admin | EventRouter.py |
| Volunteer Management | ||||
/api/volunteer |
GET | List all volunteers | Admin, Volunteer | VolunteerRouter.py |
/api/volunteer |
POST | Add new volunteer | Admin | VolunteerRouter.py |
/api/volunteer/{roll_number} |
GET | Get volunteer by roll number | Admin, Volunteer | VolunteerRouter.py |
/api/volunteer/{roll_number} |
DELETE | Remove volunteer | Admin | VolunteerRouter.py |
/api/volunteer/authorize |
POST | Authorize volunteer for event (returns JWT) | Admin, Volunteer | VolunteerRouter.py |
| Attendance & QR Scanning | ||||
/api/volunteer/scan |
POST | Scan team QR, award points | Admin, Volunteer (JWT) | AttendanceRouter.py |
| Team Management | ||||
/api/create_team |
POST | Create new team | Participant | TeamRouter.py |
/api/my_team |
GET | Get user's current team | Participant | TeamRouter.py |
/api/join_team_by_code |
POST | Join team using join code | Participant | TeamRouter.py |
/api/leave_team |
POST | Leave current team | Participant | TeamRouter.py |
/api/leaderboard/full |
GET | Get sorted leaderboard | Authenticated | TeamRouter.py |
Authentication Mechanisms:
- Session-based: Used for main user authentication (stored in secure cookies)
- JWT tokens: Used for volunteer event authorization (short-lived, event-specific)
Location: server/tests/
tests/
├── conftest.py # Pytest fixtures and configuration
└── test_basic.py # Unit tests for backend
- Health check endpoint
- Authentication requirements
- Leaderboard access
- 404 error handling
- DateTime Serialization (Visitor Pattern)
- Nested dictionary serialization
- List serialization with datetime objects
- Encryption/Decryption (Strategy Pattern)
- Secret code encryption
- Decryption and roundtrip testing
- QR Code Generation
- Team QR ID generation
- Join code generation
- ID format validation
- Authenticated endpoints return 401 for unauthenticated users
- Role-based access control validation
- Node.js (v18 or higher)
- Python (v3.9 or higher)
- MongoDB (local installation or MongoDB Atlas account)
- Git
git clone https://github.com/Humanoid2005/Loyalty_Program_Management_System.git
cd Loyalty_Program_Management_SystemFill in the values for the environment variables in frontend and backend by following the .env.example present in both client, server folders
cd serverpip install -r requirements.txtuvicorn main:app --reload --host 0.0.0.0 --port 8000cd ../client # From project routenpm installnpm run dev