2.3 KiB
2.3 KiB
Copilot Instructions for Exam Manager
Architecture Overview
- Backend: TypeScript (Node.js) located in /backend. Uses
rjweb-serverfor the web server andmongodbfor the database. - Frontend: React (Vite) located in /frontend. Uses Tailwind CSS for styling and React Router for navigation.
- Database: MongoDB. Database connection string is managed via
.envfile. - Deployment: Backend serves the frontend's built files from
/frontend/dist. API routes are prefixed with/api.
Core Patterns & Conventions
Backend (Node.js/TypeScript)
- Server Framework:
rjweb-server. Routes are defined usingfileRouter.Path. - Database Access: Use the exported
dbobject from backend/src/index.ts. - Models & Types: Defined in backend/src/types.ts.
- Authentication: Session-based using a cookie named
exams_sessionor anapi-authenticationheader. UseauthCheckfrom backend/src/lib/Auth.ts to protect routes. - Static Files: The backend serves the frontend's built files from
/frontend/dist. API routes are prefixed with/api.
Frontend (React)
- API Calls: Axios-based. Authentication is handled automatically via cookies. API paths start with
/api/. - Types: Always keep frontend/src/types.ts in sync with backend types.
- Routing: Managed in frontend/src/App.tsx. Protected routes should verify authentication with the backend.
- Icons: Use
lucide-reactfor iconography.
Developer Workflows
- Running with Docker: Use
docker-compose up --buildto build both stacks and the DB. - Local Backend Dev:
cd backend npm install npm run dev - Local Frontend Dev:
cd frontend npm install npm run dev
Important Files
- backend/src/index.ts: Entry point and server configuration.
- backend/src/routes/: Directory containing all API endpoints.
- backend/src/types.ts: Shared TypeScript interfaces for models.
- frontend/src/App.tsx: Frontend routing and auth state.
- frontend/src/types.ts: Type definitions for the frontend.