How shirakuyanai/comp1640 works
Main Components
• Frontend (Web Client): Located in the “web” folder. It contains presentation elements (pages, components, UI libraries), state management (GlobalStateContext), and actions for API calls (getData, postData). It uses Vite for bundling.
• Backend (Server): Found in the “server” folder. This comprises:
• Configuration and Setup: Includes environment variables (.env.example), database configuration (db_config.js, drizzle.config.js), and migration scripts.
• API Routes: In “server/src/routes” (e.g., class.js) handling HTTP requests.
• Business Logic & Utilities: Library functions (auth.js, encrypt.js, logger.js, mailer.js) and controllers interact with the database.
• Data Models/Schema: Located in “server/src/schema” and “server/src/db” representing entities like User, Class, Meeting, Role, etc.
• Database: A PostgreSQL database (configured via migration steps and the “demo_data” folder containing demo files) that holds the persistent data needed by the backend.
Relationships and Interactions
• The Frontend sends HTTP requests (and possibly socket messages, as suggested by “web/src/lib/socket.tsx”) to the Backend API endpoints.
• The Backend receives these requests via its routing modules, applies business logic (with help from the libraries in “lib”), and performs read/write operations using the database.
• The utilities (authentication, encryption, logger, mailer) support secure and reliable data processing and communication.
• Environment and configuration files (both in “server” and “web”) ensure proper setup and separation of concerns (e.g., API_KEY management).
Architectural Patterns & Design Principles
• Separation of Concerns: Clear split between frontend and backend components.
• API-Driven Communication: The client and server interact via well-defined REST (or potentially socket) endpoints.
• Modular Structure: Backend code is organized into configuration, routes, database models, and utility libraries. Similarly, the frontend has a modular component structure (pages, UI components, actions, and schemas).
• Data Migration/Seeding: The server includes migration scripts and demo data which are crucial for setting up the database schema.
Relevant Technologies & Frameworks
• Node.js for the backend, with packages managed via npm.
• Drizzle ORM (as suggested by “drizzle.config.js”) for database interaction.
• PostgreSQL as the underlying database.
• React (and potentially TypeScript) for the front-end application.
• Vite as the build tool for the web client.
• Additional libraries for UI components, routing, and utility functions.