How matthewsong18/csc337-final-project works
Main Components
• Frontend: Found under the “frontend” directory, it contains HTML files (e.g., auth.html, chat.html, profile.html, etc.), JavaScript scripts for each view (e.g., auth.js, chat.js), and CSS files for styling. This part of the system handles user interaction and presentation.
• Backend: Under the “backend” folder, several key sub-components emerge:
• Server Entry Point: “server.js” (and “app.js”) kick off the backend server.
• Controllers: Contain files like chatController.js, message_controller.js, pollController.js, and userController.js. They manage incoming HTTP requests and orchestrate responses.
• Routes: Define the URL endpoints that the controllers respond to (e.g., authRouter.js, chatRouter.js, indexRouter.js).
• Models: Located in the “models” directory (Chat.js, Message.js, Poll.js, PollOption.js, User.js) represent the data structures and possibly the interactions with a database.
• Services: Under “services”, with files such as ChatService.js and UserService.js. These typically encapsulate business logic and interact with models.
• (Implied) Database: Although there’s no explicit database configuration in the tree, the presence of models implies database interactions. You might represent it as an external component that the Models layer communicates with.
Relationships and Data Flow
• The Frontend makes AJAX (or fetch) calls to the Backend API endpoints defined in the Routes.
• The Routes pass requests to Controllers, which then may call Services for processing the core business logic.
• Services in turn interact with Models for data persistence (fetching, updating, deleting records).
• The Controllers send back responses to the Frontend based on the results.
Architectural Patterns and Design Principles
• Model-View-Controller (MVC): The separation into Controllers, Models, and the use of views (HTML/JS/CSS) on the frontend suggests use of an MVC-like pattern in the backend.
• Separation of Concerns: The division into “controllers”, “routes”, “models”, and “services” makes it easier to handle maintenance, testing, and scalability.
Technologies, Frameworks, and Libraries
• Backend is based on Node.js/Express (hinted by the file names and structure).
• Frontend consists of HTML, CSS, and plain JavaScript.
• The test directories suggest use of a testing framework (likely Jest or Mocha) though the specific framework isn’t explicitly mentioned.