Skip to content

Folder Structure

zechajw edited this page Jun 29, 2022 · 6 revisions

If you are new to the repo, do take some time reading this section in order to familiarize yourself with the structure of the project as well as the responsibilities of each folder so that you can quickly learn how to navigate the codebase.

/skylab-backend
├── ./github
├── /prisma
│   ├── /migrations
│   └── schema.prisma
└── /src
    ├── /environments
    ├── /errors
    ├── /helpers
    ├── /models
    ├── /routes
    ├── /utils
    ├── index.ts
    └── server.ts

1. .github/

  • Contains .yml files that are responsible for configuring GitHub actions
  • These actions help to run automated checks such as linting, formatting and testing to ensure code quality and consistency

2. prisma/

  • Contains all the files necessary to initialize and utilize Prisma, the ORM connector between Express and the PostgreSQL Database
  • The /migrations folder contains .sql files representing the migrations of the database as the schema changes
  • The prisma.schema file contains the schema definition of the current PostgreSQL Database

3. src/

  • Contains the source code powering the Skylab Backend Server
  • This directory is split into several subdirectories, with the main ones being models, helpers, and routes

3.1 src/models/

  • Contains methods that interface with the database directly
  • This involves generic implementations of SQL queries available via the Prisma Client (e.g. findMany, delete, update)
  • Helper methods interface with these methods using Prisma arguments that tailor the output to the specific use cases.

3.2 src/helpers/

  • Contains helper methods that are specific to each use case

3.3 src/routes/

  • Contains the Express routes that are exposed to the client
  • More information on the HTTP Request Documentation is available in the Endpoints section of the GitHub Wiki

3.4 src/utils

  • Contains utility files that are used throughout the application
  1. ApiResponseWrapper.ts: Abstracts the Express Response functionality for easier handling
  2. HTTP_Status_Codes.ts: A library of HTTP Status Codes to ensure consistency throughout the application
  3. Emails.ts: Constants used by our SendInBlue Email Service

3.5 src/errors

  • Contains custom error files that are used throughout the application
  1. SkylabError.ts is a custom error wrapper that allows HTTP status codes and error metadata to be passed alongside error information.

NUS Skylab v2 - Backend

Introduction

Project Organization

Project Requirements

Endpoints

Clone this wiki locally