/backend

Backend of online learning environment Source Academy @ NUS (Elixir, Ecto, Phoenix, PostgreSQL)

Primary LanguageElixirApache License 2.0Apache-2.0

Cadet

Build Status Coverage Status Inline docs License

Cadet is the web application powering Source Academy.

  • master is the main development branch, and may be broken, buggy, unstable, etc. It may not work with the frontend, if there are frontend changes that have not yet been merged.
  • stable is the stable branch and should work with the stable branch of the frontend. Note that stable may not have stable history!

Developer setup

System requirements

  1. Elixir 1.13.3
  2. Erlang/OTP 23.2.1
  3. PostgreSQL 13 or 14

It is probably okay to use a different version of PostgreSQL or Erlang/OTP, but using a different version of Elixir may result in differences in e.g. mix format.

Setting up your local development environment

  1. Set up the development secrets (replace the values appropriately)

    $ cp config/dev.secrets.exs.example config/dev.secrets.exs
    $ vim config/dev.secrets.exs
  • To use LumiNUS authentication, specify a valid LumiNUS api_key. Note that the frontend will supply the ADFS client ID and redirect URL (so you will need that too, but not here).
  1. Install Elixir dependencies

    $ mix deps.get
  2. Initialise development database

    $ mix ecto.setup
  3. Run the server on your local machine

    $ mix phx.server
  4. You may now make API calls to the server locally via localhost:4000. The API documentation can also be accessed at http://localhost:4000/swagger.

Obtaining access_token in dev environment

You can obtain an access_token JWT for a user with a given role by simply running:

$ mix cadet.token <role>

For more information, run

$ mix help cadet.token

Style Guide

We follow this style guide: https://github.com/lexmag/elixir-style-guide and https://github.com/christopheradams/elixir_style_guide

Where there is a conflict between the two, the first one (lexmag) shall be the one followed.

Entity-Relationship Diagram

Generated with DBeaver on 17 October 2020

Entity-Relationship Diagram for cadet

License

License All sources in this repository are licensed under the Apache License Version 2.