Skip to content

Backend Explanation

Frank Matranga edited this page Jul 6, 2019 · 2 revisions

a. Structure

The backend of LATE is a Koa server (NodeJS) that serves the LATE API for the frontend to communicate back and forth with. It connects to a remote MongoDB server with the Node package Mongoose, which allows us to create schemas for the documents LATE uses: assignments, exams, students, courses, etc. Native MongoDB does not have this structure.

Since LATE is a single page application (SPA), the server responds to every non API request by sending the single index.html file which serves the compiled and combined HTML, Sass (CSS), and Javascript from Webpack. VueJS takes over the page routing and everything once the page loads.

The backend resides in the /server folder and is organized into subfolders:

  • /server
    • /api
      • /[model name]
        • /[model name].controller.js Defines all of the API functions for interacting with the model (usually CRUD)
        • /[model name].model.js Defines the schema for the model and any virtual properties, hooks, etc.
        • /index.js Defines the routes that match urls to controller functions.
      • /index.js Defines ALL API routes by connecting base urls like '/assignments' to their proper routes and controllers.
    • /integrations
      • /[integration name].js Defines functions for the specific integration.
    • /modules
      • /[module name].js
    • /scripts
    • /db.js Sets up Mongoose connection.
    • /index.js Creates the server, sets up all Koa plugins, provides a middleware for all requests.
    • /routes.js Sets up all server routes including the API, CAS auth, Discord auth, and Google auth.