Skip to content

Architecture

  • src/main.jsx: Application initialization point

    • Mounts React app to DOM
    • Wraps app in ThemeProvider for global theme state
    • Wraps app in HelmetProvider for SEO meta tag management
    • Initializes HashRouter for 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)
  • Uses HashRouter instead of BrowserRouter for static hosting compatibility
  • All routes prefixed with #/ (e.g., #/attendance, #/grades)
  • Enables deployment on static hosts like GitHub Pages, Vercel, etc.
/ (root)
├── /login (unauthenticated only)
└── (authenticated routes)
├── /attendance
├── /grades
├── /exams
├── /subjects
├── /profile
├── /academic-calendar
├── /timetable
├── /fee
├── /feedback
└── /gpa-calculator
  • Authentication guard checks isAuthenticated state
  • Redirects to /login when not authenticated
  • Auto-login attempt on app load using stored credentials
  • Fallback to offline mode if cache exists but login fails
  • 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
  • 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
  • Managed via ThemeContext (src/context/ThemeContext.jsx)
  • Provides themeMode, darkTheme(), lightTheme() functions
  • Persists to localStorage.defaultTheme
  • Applies CSS classes to document element
  • Uses WebPortal class 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
  • ArtificialWebPortal class (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
  • 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
  • Powered by vite-plugin-pwa in vite.config.js
  • Workbox strategies for different resource types
  • Precaching of critical assets
  • Runtime caching with custom strategies
  1. CacheFirst: Pyodide WASM, Python wheels, static assets
  2. StaleWhileRevalidate: JavaScript bundles, CSS, API responses
  3. NetworkFirst: HTML documents
  4. CacheOnly: Offline fallback pages
  • Auto-registered via Vite plugin
  • Update prompts when new version available
  • Skip waiting for immediate activation
  • Claims clients for instant control
  • Client-side Python execution for PDF processing
  • Used for marks card download and manipulation
  • Enables offline PDF generation
  • Loader in src/lib/pyodide.js
  • Lazy loading - only when needed (marks download)
  • Python packages:
    • jiit_marks: Custom marks processing package
    • PyMuPDF: PDF manipulation library
  • Wheels stored in public/artifact/ and precached
  • CDN fallback for Pyodide core: https://cdn.jsdelivr.net/pyodide/v0.24.1/full/
  1. User requests marks download
  2. Load Pyodide if not already loaded
  3. Install required wheel packages
  4. Run Python code for PDF processing
  5. Return processed PDF to user
  • 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
  • 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
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"]);
}
  • App must be served over HTTPS in production
  • JIIT API requires secure connections
  • CORS handled by WebPortal library
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
│ └── InstallPWA
  • Props for parent-child data flow
  • Callbacks for child-to-parent events
  • Context for deeply nested shared state (theme)
  • State lifting for sibling communication
  1. Container/Presentational: Feature pages fetch data, sub-components display
  2. Compound Components: Dialog, Sheet, Tabs use composition
  3. Render Props: Calendar, Charts accept render functions
  4. Hooks: Custom hooks for theme, cache, and data fetching
  • React Transition Group for route changes
  • CSS transitions in src/styles/transitions.css
  • Fade and slide effects
  • Framer Motion for micro-interactions
  • Hover, tap, and entrance animations
  • Layout animations for dynamic lists
  • Gesture recognition for swipe navigation
  • CSS transforms for smooth animations (GPU-accelerated)
  • will-change hints for frequently animated elements
  • Reduced motion support via media queries
  1. Vite builds and bundles JavaScript/CSS
  2. PWA plugin generates service worker
  3. Assets hashed for cache busting
  4. Code splitting for optimal loading
  5. Tree shaking removes unused code
  • Vercel: Recommended (see vercel.json)
  • GitHub Pages: Works with HashRouter
  • Netlify: Compatible
  • Static Hosting: Any static host works
  • No environment variables required
  • All configuration in code or localStorage
  • API endpoints hardcoded (JIIT WebKiosk)
  • Top-level error boundary catches component errors
  • Fallback UI shown on critical errors
  • Logs errors to console for debugging
  • Try-catch blocks around all API calls
  • User-friendly error messages
  • Offline fallback when API fails
  • Retry mechanisms for transient failures
  • Form validation with error messages
  • Input sanitization before API calls
  • Type checking with PropTypes (some components)