Tech Stack
- Framework: Next.js 15.5.9 (App Router)
- UI Library: React 19.0.0
- Language: TypeScript 5.x
- Styling: Tailwind CSS 3.4.1
- Components: Radix UI Accordion
- Analytics: Vercel Analytics
Project Structure
Development Workflow
Start the development server
http://localhost:3000 with hot module replacement enabled.Make your changes
Edit files in the
app/ directory. Changes will be reflected immediately in the browser.Key Components
BuildingsContent
The main component that fetches and displays classroom data. Location:app/components/BuildingsContent.tsx
Responsibilities:
- Fetches data from
/api/open-classrooms - Manages search state and filtering
- Renders building accordions with classroom availability
BuildingAccordion
Displays classrooms for a specific building using Radix UI Accordion. Location:app/components/BuildingAccordion.tsx
Props:
- Building data (code, name, classrooms)
- Availability information for each classroom
RefreshButton
Handles manual data refresh with cooldown management. Location:app/components/RefreshButton.tsx
Features:
- Calls
/api/refreshendpoint - Checks cooldown status via
/api/cooldown-status - Displays remaining cooldown time
- Shows success/error notifications
SearchBar
Provides filtering by building code and room number. Location:app/components/SearchBar.tsx
Features:
- Real-time search filtering
- Supports building codes (CAS, CGS)
- Supports room numbers
API Routes
The frontend includes API routes that proxy requests to the backend.GET /api/open-classrooms
Location: app/api/open-classrooms/route.ts
Fetches classroom availability data from the backend.
Response:
POST /api/refresh
Location: app/api/refresh/route.ts
Triggers a manual refresh of classroom data.
Response:
GET /api/cooldown-status
Location: app/api/cooldown-status/route.ts
Checks if the refresh cooldown is active.
Response:
Styling with Tailwind CSS
Configuration
Location:tailwind.config.ts
Global Styles
Global styles and CSS variables are defined inapp/globals.css.
Component Styling
Use Tailwind utility classes directly in components:TypeScript Configuration
Location:tsconfig.json
The project uses strict TypeScript settings:
Environment Variables
Create a.env.local file in the frontend/ directory:
Variables prefixed with
NEXT_PUBLIC_ are exposed to the browser. Use this prefix for any variables needed in client-side code.Adding New Components
Working with the Backend API
Fetching Data
Use the nativefetch API or create API route handlers:
Environment-Based API URLs
Use environment variables for different environments:Building for Production
Best Practices
Performance
- Use Next.js Image component for optimized images
- Implement proper loading states
- Minimize client-side JavaScript with Server Components
- Use dynamic imports for code splitting
Type Safety
- Define TypeScript interfaces for all API responses
- Use strict type checking
- Avoid
anytypes
Component Organization
- Keep components small and focused
- Extract reusable logic into custom hooks
- Use composition over inheritance
- Separate server and client components clearly
Common Tasks
Adding a New Page
/about.
Adding a New API Route
Debugging
- Use React DevTools browser extension
- Check the browser console for errors
- Use
console.log()for debugging (remove before committing) - Check Network tab for API request/response issues