EvalX is a Next.js frontend with a FastAPI backend for extracting marks from uploaded PDF result sheets.
- Frontend: Next.js 16.1.6 (App Router), React 19, TypeScript
- Backend: FastAPI, PyMuPDF
- Data/Auth/Email integrations: MongoDB, JWT, Resend, Vercel Blob
- UI: Tailwind CSS, AG Grid, Framer Motion
- Node.js 20+
- npm 10+
- Python 3.10+
npm installpython3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtCreate .env.local in project root with values like:
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
RESEND_API_KEY=your_resend_api_key
RESEND_FROM="EvalX <onboarding@resend.dev>"Notes:
MONGODB_URIandJWT_SECRETare needed for login/auth flows.RESEND_API_KEYis needed for OTP and email result routes.RESEND_FROMis optional. Set it to your verified sender/domain in Resend.- PDF extraction route itself is handled by FastAPI (
/api/extract).
- Signup: email + password
- First-time verification: OTP via email
- Subsequent logins: email + password only
Use two terminals from the project root.
source venv/bin/activate
uvicorn api.index:app --host 127.0.0.1 --port 8000 --reloadnpm run devOpen http://localhost:3000.
In development, Next.js rewrites /api/* to http://127.0.0.1:8000/api/*, so the frontend can call backend endpoints directly.
npm run build
npm run start- Student List Endpoint (
/api/results/students): Uses MongoDB aggregation pipeline instead of loading full arrays into Node.js memory- Aggregation stages:
$match→$sort→$unwind→$group→$sort - Returns only
{usn, name, latestRunAt}instead of full result objects - Impact: 10-100x faster for users with 1000+ student records, 80% less memory usage
- Aggregation stages:
- Student Detail Endpoint (
/api/results/students/[usn]): Aggregation pipeline to filter specific student records server-side- Filters by USN on MongoDB before transferring data
- Impact: ~5-10x faster for large datasets
- Student Results Pages: Memoized components prevent unnecessary re-renders
StudentListButton: Only re-renders when that student's data changesSavedRunCard: Only re-renders when that run's data changesSemesterCard: Only re-renders when semester data changesEmailInput,PasswordInput,OTPInput(Login/Signup): Prevent form re-renders on parent state changes- Uses React.memo() for efficient re-render prevention
- Student Details Caching: Session-level cache for fetched student details
- First load from API (~0.5s), subsequent loads instant
- Eliminates redundant API calls when toggling between students
- Impact: ~50% reduction in API calls during typical usage
- AG Grid Configuration: Pagination (20 rows/page), lazy loading, virtual scrolling
- Custom Scrollbars: Optimized scroll experience for large lists
- Modal Lazy Loading: Excel viewer modal loads only when opened
- Local extraction endpoint:
POST http://127.0.0.1:8000/api/extract - Frontend calls extraction as
POST /api/extract(rewritten to FastAPI in dev) - On Vercel,
vercel.jsonroutes/api/extracttoapi/index.py, rest handled by filesystem routing
EvalX is configured for seamless Vercel deployment:
vercel.json: Routes PDF extraction to Python backend, auth/data endpoints to Node.jsmiddleware.ts: JWT authentication validation on protected routes- Automatic environment variable injection for MongoDB, JWT, Resend API keys
- Set all required environment variables in Vercel project settings
- Ensure MongoDB Atlas IP whitelist includes Vercel IPs
- Test locally with
npm run build && npm run start - Verify auth flow with OTP emails from Resend
evalx/
├── app/
│ ├── api/ # Next.js API routes
│ │ ├── auth/ # JWT auth endpoints
│ │ ├── results/ # Student results endpoints (optimized)
│ │ ├── email/ # Email delivery routes
│ │ └── blob/ # File storage routes
│ ├── components/ # Reusable React components
│ ├── extract-marks/ # PDF extraction multi-step UI
│ ├── login/ # Login page (optimized)
│ ├── signup/ # Signup page (optimized)
│ └── student-results/ # Main results dashboard (optimized)
├── lib/
│ ├── auth.ts # JWT signing/verification
│ ├── mongodb.ts # MongoDB connection pool
│ ├── server-auth.ts # Server-side auth helpers
│ └── results.ts # Data extraction utilities
├── models/ # MongoDB schemas
├── api/ # FastAPI Python backend
│ └── index.py # PDF extraction service
├── middleware.ts # JWT validation middleware
├── next.config.mjs # Next.js config
├── tsconfig.json # TypeScript config
└── vercel.json # Vercel routing config