# Developer Documentation [toc] ## Setup ### Setup Mannually Note: The backend part can only be run on [**NixOS**](https://nixos.org/) operating system, which is a powerful Linux distribution based on the Nix package manager. - **Setup postgresql service**: Add following to `/etc/nixos/configuration.nix`. Add then run `nixos-rebuild switch` to apply the configuration to system. ```nix { ... # postgresql service services.postgresql = { enable = true; package = pkgs.postgresql_15; enableTCPIP = true; authentication = pkgs.lib.mkOverride 10 '' local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 trust ''; initialScript = pkgs.writeText "backend-initScript" '' CREATE ROLE nixcloud WITH LOGIN PASSWORD 'nixcloud' CREATEDB; CREATE DATABASE nixcloud; GRANT ALL PRIVILEGES ON DATABASE nixcloud TO nixcloud; ''; }; # List packages installed in system profile. environment.systemPackages = with pkgs; [ postgresql_15 ]; programs.nix-ld.enable = true; environment.sessionVariables = { NIX_LD = toString (pkgs.runCommand "ld.so" {} '' ln -s "$(cat '${pkgs.stdenv.cc}/nix-support/dynamic-linker')" $out ''); NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [ zlib zstd stdenv.cc.cc curl openssl attr libssh bzip2 libxml2 acl libsodium util-linux xz systemd ]); }; # Enable Flake nix.settings.experimental-features = [ "nix-command" "flakes" ]; } ``` - **Clone project**: `git clone https://github.com/sustech-cs304/team-project-111.git` - **Nix develop**: Enter into project root directory and run `nix develop .` Then a new bash shell with all the dependencies setup well should be started ### Dcoker ## Run - **Frontend** - `cd kerbal-dashboard` - `npm install` - `npm start` You should also set up the proxy policy in `src/setupProxy.js` to handle backend request forward and solve CORS problem <img src="https://raw.githubusercontent.com/zephyrszwc/zephyrs-image/master/202305312129926.png" alt="carbon" style="zoom:50%;" /> - **Backend** - Run `nix develop .` - Run `mix deps.get` in the opened bash shell - Run `GPU_IDS="[]" iex --sname [sname] -S mix phx.server`. You should export all your gpu ids as enviroment variable. ## APIs Run codes below to generate API doc - `cd kerbal-backend` - `mix docs` Then docs can be found <img src="https://github.com/VSEJGFB/Cnblogs-Theme-SimpleMemory/assets/29839623/dbf8e22b-d3d5-40cb-9640-866e5876d4fe" alt="image" style="zoom:80%;" /> ![image](https://github.com/VSEJGFB/Cnblogs-Theme-SimpleMemory/assets/29839623/5a67a9a4-04df-4f3b-8507-8186f72a46f5) <img src="https://github.com/VSEJGFB/Cnblogs-Theme-SimpleMemory/assets/29839623/490eb916-ca86-4848-8c6a-e733ecdfc00f" alt="image" style="zoom:80%;" /> Describe: For every module in the project, the develop documentation contains: - A summary of the module, typically sourced from the module's `@moduledoc` attribute. - A list of all functions, macros, and types defined in the module. This list includes a brief summary of each item, typically sourced from the item's `@doc` or `@typedoc` attribute. - Detailed documentation for each function, macro, and type. This documentation includes the item's full doc attribute, along with any relevant metadata (such as the function's parameters and return type).