Frontend stack
The client application is a React single-page application built with Vite.Core frameworks
React 19.2
UI library with hooks and context for state management
Vite 7.3
Build tool with hot module replacement
React Router 7.13
Client-side routing with protected routes
Tailwind CSS 4.1
Utility-first CSS framework for styling
UI components
CampusBite uses a shadcn/ui-inspired component architecture with Radix UI primitives:| Package | Purpose |
|---|---|
@radix-ui/react-dialog | Modal dialogs for confirmations |
@radix-ui/react-dropdown-menu | User profile and action menus |
@radix-ui/react-select | Styled select inputs |
@radix-ui/react-switch | Toggle switches for availability |
@radix-ui/react-tabs | Tab navigation in store dashboard |
@radix-ui/react-avatar | User profile avatars |
@radix-ui/react-checkbox | Form checkboxes |
@radix-ui/react-label | Accessible form labels |
@radix-ui/react-popover | Popover menus |
@radix-ui/react-scroll-area | Custom scrollbars |
@radix-ui/react-separator | Dividers |
All Radix components are wrapped in custom implementations at
frontend/src/components/ui/ to match the app’s design system.Utilities and styling
HTTP client
Axios 1.13.5 handles all API communication with advanced features:- Request interceptor: Auto-attach JWT tokens
- Response interceptor: Auto-refresh expired tokens (frontend/src/lib/api.js:28)
- FormData support: Automatic content-type handling for file uploads
Backend stack
The server is a Node.js application built with Express.js using ES modules.Core framework
Node.js 18+
JavaScript runtime (ES modules enabled)
Express 5.2
Web framework for REST APIs
Database and ODM
MongoDB with Mongoose 8.12:- Schema validation with Mongoose models
- Connection pooling and retry logic
- SRV DNS resolution with fallback guidance (backend/src/config/db.js:23)
- Auto-creation of collections on first server start
Database models
Database models
The system defines five main Mongoose schemas:
- User - Students, faculty, and store employees
- Store - Food outlets on campus
- MenuItem - Menu items with pricing and availability
- Order - Order records with status tracking
- RefreshToken - JWT refresh token whitelist
backend/src/models/.Authentication
- Access tokens: 1 hour expiry
- Refresh tokens: 7 days expiry
- Tokens signed with separate secrets from environment variables
Security middleware
Helmet 8.1
Sets secure HTTP headers
CORS 2.8
Cross-origin resource sharing
express-rate-limit 8.2
Rate limiting with custom strategies
Rate limiting uses three separate limiters: global (3000 req/15min), auth (80 req/15min), and per-user order actions (300 req/15min). See backend/src/index.js:84.
Email service
Nodemailer 8.0 for transactional emails:- Gmail SMTP integration with app passwords
- Email verification on registration
- Password reset links
- Order confirmation emails (optional)
File uploads
Multer 2.0 middleware handles image uploads:- Menu item images
- Store logos
- UPI QR codes
- Stored in
/public/uploads/(dev) or/data/uploads/(production)
Validation
Zod 4.3 for schema validation:- Request body validation
- Type-safe error messages
- Integration with Express via validation middleware (backend/src/middleware/validate.js)
Utilities
Development tools
Nodemon 3.1
Auto-restart server on file changes
Concurrently 8.2
Run frontend and backend in parallel
ESLint 9.39
Code linting and formatting
Package managers
The project uses npm as the primary package manager. Install all dependencies with:Environment variables
CampusBite requires several environment variables for configuration:Backend (.env)
Required variables
Required variables
| Variable | Description | Example |
|---|---|---|
PORT | Server port | 5000 |
NODE_ENV | Environment | development |
DATABASE_URL | MongoDB URI | mongodb://localhost:27017/campusbite |
JWT_SECRET | Access token secret | Random 32+ char string |
JWT_REFRESH_SECRET | Refresh token secret | Random 32+ char string |
SMTP_USER | Gmail address | [email protected] |
SMTP_PASS | Gmail app password | Generated from Google |
FRONTEND_URL | Frontend URL | http://localhost:5173 |
Optional variables
Optional variables
| Variable | Description | Default |
|---|---|---|
JWT_EXPIRES_IN | Access token expiry | 1h |
JWT_REFRESH_EXPIRES_IN | Refresh token expiry | 7d |
SMTP_HOST | SMTP server | smtp.gmail.com |
SMTP_PORT | SMTP port | 587 |
FROM_EMAIL | Sender email | [email protected] |
UPLOAD_DIR | Upload directory | backend/public/uploads |
Third-party integrations
CampusBite integrates with external services:Gmail SMTP
Used for sending verification and password reset emails. Requires a Google account with 2-Step Verification enabled and an App Password generated.Gmail App Passwords can be generated at: Google Account → Security → 2-Step Verification → App passwords.
UPI payment apps
Generates deep links for Indian UPI payment apps:- Google Pay (
gpay://) - PhonePe (
phonepe://) - Paytm (
paytmmp://) - BHIM UPI (
upi://)
UPI deep links only work on mobile devices with the respective apps installed. The system doesn’t integrate with payment gateways—store employees manually confirm payments.
Browser compatibility
The frontend targets modern browsers with:- ES2020+ JavaScript features
- CSS Grid and Flexbox
- Native FormData API
- LocalStorage for auth persistence
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Next steps
Project structure
Explore the codebase organization
Architecture overview
Understand the system design