Architecture
Application Bootstrap
Section titled “Application Bootstrap”Entry Points
Section titled “Entry Points”-
src/main.jsx: Application initialization point
- Mounts React app to DOM
- Wraps app in
ThemeProviderfor global theme state - Wraps app in
HelmetProviderfor SEO meta tag management - Initializes
HashRouterfor routing - Sets up React 18 concurrent features
-
src/App.jsx: Main application component
- Manages authentication flow and state
- Handles route configuration and navigation
- Implements offline fallback detection
- Coordinates global state (attendance goals, selected semesters, etc.)
- Manages page transitions with React Transition Group
- Implements swipe navigation (configurable)
Routing Architecture
Section titled “Routing Architecture”Router Choice
Section titled “Router Choice”- Uses
HashRouterinstead ofBrowserRouterfor static hosting compatibility - All routes prefixed with
#/(e.g.,#/attendance,#/grades) - Enables deployment on static hosts like GitHub Pages, Vercel, etc.
Route Structure
Section titled “Route Structure”/ (root)├── /login (unauthenticated only)└── (authenticated routes) ├── /attendance ├── /grades ├── /exams ├── /subjects ├── /profile ├── /academic-calendar ├── /timetable ├── /fee ├── /feedback └── /gpa-calculatorRoute Protection
Section titled “Route Protection”- Authentication guard checks
isAuthenticatedstate - Redirects to
/loginwhen not authenticated - Auto-login attempt on app load using stored credentials
- Fallback to offline mode if cache exists but login fails
State Management
Section titled “State Management”Global State (App.jsx)
Section titled “Global State (App.jsx)”- Authentication State:
isAuthenticated,w(WebPortal instance) - User Data: Profile, semesters, attendance, grades, exams, subjects
- UI State: Selected semesters, active tabs, dialog states
- Settings: Attendance goals, theme preferences, default tab
Local Component State
Section titled “Local Component State”- Each feature component manages its own loading, error, and view states
- Data fetched from global state or API calls
- State lifted when shared between components
Theme State
Section titled “Theme State”- Managed via
ThemeContext(src/context/ThemeContext.jsx) - Provides
themeMode,darkTheme(),lightTheme()functions - Persists to
localStorage.defaultTheme - Applies CSS classes to document element
Data Layer Architecture
Section titled “Data Layer Architecture”Online Mode
Section titled “Online Mode”- Uses
WebPortalclass from jsjiit library (CDN import) - ESM module:
https://cdn.jsdelivr.net/npm/jsjiit@0.0.24/dist/jsjiit.esm.js - Handles authentication and API calls to JIIT WebKiosk
- Session management with cookies and tokens
Offline Mode
Section titled “Offline Mode”ArtificialWebPortalclass (artificialW.js)- Mimics WebPortal API structure
- Reads from localStorage cache using cache helpers
- Returns cached data with same structure as online API
- Activated when login fails but sufficient cache exists
Cache Layer
Section titled “Cache Layer”- Implemented in cache.js
- Key-based caching with structured keys:
attendance-{username}-{semesterId}subjects-{username}-{semesterId}grades-{username}-{semesterId}profile-{username}examSchedule-{username}-{semesterId}
- TTL-aware with expiration timestamps
- Typed getter/setter functions for each data type
- Cache statistics and management utilities
- Automatic cleanup of expired entries
PWA & Service Worker
Section titled “PWA & Service Worker”Configuration
Section titled “Configuration”- Powered by
vite-plugin-pwain vite.config.js - Workbox strategies for different resource types
- Precaching of critical assets
- Runtime caching with custom strategies
Caching Strategies
Section titled “Caching Strategies”- CacheFirst: Pyodide WASM, Python wheels, static assets
- StaleWhileRevalidate: JavaScript bundles, CSS, API responses
- NetworkFirst: HTML documents
- CacheOnly: Offline fallback pages
Service Worker Registration
Section titled “Service Worker Registration”- Auto-registered via Vite plugin
- Update prompts when new version available
- Skip waiting for immediate activation
- Claims clients for instant control
Pyodide Integration
Section titled “Pyodide Integration”Purpose
Section titled “Purpose”- Client-side Python execution for PDF processing
- Used for marks card download and manipulation
- Enables offline PDF generation
Implementation
Section titled “Implementation”- Loader in src/lib/pyodide.js
- Lazy loading - only when needed (marks download)
- Python packages:
jiit_marks: Custom marks processing packagePyMuPDF: PDF manipulation library
- Wheels stored in
public/artifact/and precached - CDN fallback for Pyodide core:
https://cdn.jsdelivr.net/pyodide/v0.24.1/full/
Workflow
Section titled “Workflow”- User requests marks download
- Load Pyodide if not already loaded
- Install required wheel packages
- Run Python code for PDF processing
- Return processed PDF to user
Security Architecture
Section titled “Security Architecture”Credential Storage
Section titled “Credential Storage”- Username and password stored in
localStorage - Used for auto-login on app start
- Security Note: Only suitable for personal devices
- Can be disabled by removing auto-login logic
Fee Payload Encryption
Section titled “Fee Payload Encryption”- AES-CBC encryption in src/lib/jiitCrypto.js
- Date-based key generation using
generate_key() - IV (Initialization Vector): Fixed 16-byte value
- Payload serialization before API submission
- Base64 encoding of encrypted data
Key Generation Algorithm
Section titled “Key Generation Algorithm”function generate_date_seq(date) { // Generates: day[0] + month[0] + year[0] + weekday + day[1] + month[1] + year[1]}
async function generate_key(date) { const dateSeq = generate_date_seq(date); const keyData = "qa8y" + dateSeq + "ty1pn"; return crypto.subtle.importKey("raw", keyData, "AES-CBC", false, ["encrypt"]);}HTTPS & CORS
Section titled “HTTPS & CORS”- App must be served over HTTPS in production
- JIIT API requires secure connections
- CORS handled by WebPortal library
Component Architecture
Section titled “Component Architecture”Component Hierarchy
Section titled “Component Hierarchy”App├── ThemeProvider│ ├── Header│ │ ├── MessMenu│ │ ├── ThemeBtn│ │ └── SettingsDialog│ ├── Router│ │ ├── Login│ │ └── Authenticated Routes│ │ ├── Attendance│ │ │ └── AttendanceCard│ │ │ ├── CircleProgress│ │ │ └── Sheet (detail view)│ │ ├── Grades│ │ │ ├── GradeCard│ │ │ └── MarksCard│ │ ├── Subjects│ │ │ ├── SubjectInfoCard│ │ │ └── SubjectChoices│ │ └── Other Routes...│ └── Navbar│ └── InstallPWAComponent Communication
Section titled “Component Communication”- Props for parent-child data flow
- Callbacks for child-to-parent events
- Context for deeply nested shared state (theme)
- State lifting for sibling communication
Component Patterns
Section titled “Component Patterns”- Container/Presentational: Feature pages fetch data, sub-components display
- Compound Components: Dialog, Sheet, Tabs use composition
- Render Props: Calendar, Charts accept render functions
- Hooks: Custom hooks for theme, cache, and data fetching
Animation & Transitions
Section titled “Animation & Transitions”Page Transitions
Section titled “Page Transitions”- React Transition Group for route changes
- CSS transitions in
src/styles/transitions.css - Fade and slide effects
Component Animations
Section titled “Component Animations”- Framer Motion for micro-interactions
- Hover, tap, and entrance animations
- Layout animations for dynamic lists
- Gesture recognition for swipe navigation
Performance Considerations
Section titled “Performance Considerations”- CSS transforms for smooth animations (GPU-accelerated)
will-changehints for frequently animated elements- Reduced motion support via media queries
Build & Deployment
Section titled “Build & Deployment”Build Process
Section titled “Build Process”- Vite builds and bundles JavaScript/CSS
- PWA plugin generates service worker
- Assets hashed for cache busting
- Code splitting for optimal loading
- Tree shaking removes unused code
Deployment Targets
Section titled “Deployment Targets”- Vercel: Recommended (see vercel.json)
- GitHub Pages: Works with HashRouter
- Netlify: Compatible
- Static Hosting: Any static host works
Environment Variables
Section titled “Environment Variables”- No environment variables required
- All configuration in code or localStorage
- API endpoints hardcoded (JIIT WebKiosk)
Error Handling
Section titled “Error Handling”Error Boundaries
Section titled “Error Boundaries”- Top-level error boundary catches component errors
- Fallback UI shown on critical errors
- Logs errors to console for debugging
API Error Handling
Section titled “API Error Handling”- Try-catch blocks around all API calls
- User-friendly error messages
- Offline fallback when API fails
- Retry mechanisms for transient failures
Validation
Section titled “Validation”- Form validation with error messages
- Input sanitization before API calls
- Type checking with PropTypes (some components)