@@ -13,59 +13,114 @@ processing.
1313## Code Organization
1414
1515The code base is made up of an Angular front end (stored in ` client/ ` folder)
16- and a Hapi backend (stored in ` server/ ` folder). A Dockerfile and Docker
17- compose file is provided for packing up the application.
18-
19- The Angular front end is heavily coupled to the Hapi backend. Most of the
16+ and a NestJS backend (stored in ` server/ ` folder). A Dockerfile and Docker
17+ compose file is provided for packing up the application, an official
18+ docker image is also stored in DockerHub. A break down of the top level folders
19+ is shown below.
20+
21+ * ` client/ ` : Angular client side code
22+ * ` cypress/ ` : E2E Testing
23+ * ` docs/ ` : Sphinx documentation
24+ * ` server/ ` : NestJS server side code
25+ * ` shared/ ` : Code shared between client and server, currently only DTOs
26+
27+ The Angular front end is heavily coupled to the NestJS backend. Most of the
2028logic is contained within the backend with the Angular front end acting
21- just as an interface to the backend. The system workes by having the Hapi
29+ just as an interface to the backend. The system workes by having the NestJS
2230backend serve the compiled Angular front end as a static webpage.
2331
24- The Hapi backend is based on a project [ Anchor] ( https://github.com/hicsail/anchor )
25- which provides a template for a Hapi + MongoDB server. Part of what is included
26- from Anchor is a system for managing users, user roles, user authentication,
27- MongoDB data access, static webpage serving, emailing service, and various
28- other helpful tools. All of these features are build using existing common
29- tools and just packaged up in a form that is easy to include in any backend.
32+ ## Environment Variables
33+
34+ The SignLab application can be configured via environment variables. Those
35+ environment variables can be supplied in a number of different ways.
36+
37+ For a complete list of configrations used by the server, refer to the file
38+ ` server/src/config/configuration.ts ` . That file has the SignLab wide settings
39+ and where they come from.
40+
41+ ### Locally
42+
43+ Locally, the easiest way to pass in the configuration is via ` .env ` files.
44+ Below is an example of the usage.
45+
46+ ``` bash
47+ cd server/
48+ export NODE_ENV=local
49+ npm run start:watch
50+ ```
51+
52+ The file ` .env.local ` in the top level will then be used for configruation.
53+ The server looks for a file ` .env.<NODE_ENV> ` so additional environments can
54+ be made based on testing needs.
55+
56+ By running ` npm run start:watch ` at the top level, the application will use the
57+ ` .env.local ` file.
58+
59+ ### Docker
60+
61+ The provided docker-compose file looks for a ` deployment.env ` file. The
62+ ` deployment.env ` file is setup identically to a ` .env ` and is the preferred
63+ method to insert configuration into the dockerized instance.
64+
65+ ## Object Storage ("Bucket Storage")
66+
67+ SignLab makes use of object storage for storing the response videos that
68+ are uploaded to the platform. Currently two platforms are supported.
69+
70+ First is an interace for storing the responses in a local folder. This is
71+ handy for testing locally quickly without the need to a dedicated bucket
72+ setup.
73+
74+ Second is S3 complient object storage endpoints. NERC's object storage is S3
75+ complient so can be used as well.
76+
77+ Each object storage has its own set of required configuration, you
78+ can refer to the ` bucket ` section of the configuration contained
79+ in ` server/src/config/configuration.ts ` . The user selects which bucket storage
80+ type they are using via the ` type ` value (which is evaluated from the
81+ environment variable ` BUCKET_TYPE ` . Setting ` BUCKET_TYPE ` to ` S3 ` will
82+ have SignLab look for S3 specific settings and use an S3 object container.
83+ Using ` LOCAL ` as the ` BUCKET_TYPE ` will result in a local folder being
84+ user for the object container.
85+
86+ GCP is not yet offically supported, but the functionality is stubbed out.
3087
3188## Running the Code for Development
3289
3390The following steps will get you setup so you can test SignLab locally and
3491test out changes in real time.
3592
36- 1 . (One time) Install packages for the client side and the server side.
93+ 1 . (One time) Install dependancies
3794
3895``` bash
39- cd client
40- npm install
41- cd ../server
42- npm install
96+ npm i
4397```
4498
45- 2 . (Each time) Start up a MongoDB instance using the ` mongod ` command. Below is
46- an example.
99+ 2 . Setup Object Storage
47100
48- ``` bash
49- mongod --dbpath ~ /data/signlab
50- ```
101+ For local testing, a folder can be used to emulate an actual object storage
102+ container. By default the provided ` .env.local ` file expects a folder
103+ ` server/bucket/Responses ` to exist. Make sure that folder exists when testing
104+ locally using a folder for obect storage emulation.
51105
52- 3 . (One time) Run the first time setup script for the Hapi backend.
106+ 3 . (Each time) Start up a MongoDB instance using the ` mongod ` command. Below is
107+ an example.
53108
54109``` bash
55- cd server/
56- node first-time-setup.js
110+ mongod --dbpath ~ /data/signlab
57111```
58112
59- 4 . (Each time) Start the Hapi backend
113+ 4 . Start up the frontend and backend
60114
61115``` bash
62- cd server/
63- npm start
116+ npm run start:watch
64117```
65118
66- 5 . (Each time) Have the Angular code build as changes take place
119+ The command above will build the Angular and NestJS components and watch
120+ for changes. The commands are run with the "concurrent" package so if reading
121+ the output is difficult, you can run the same command separatly for the
122+ ` server ` and ` client ` package in different terminals from the respective
123+ folders.
67124
68- ``` bash
69- cd client/
70- ng build --watch
71- ```
125+ Note: For the server, you need to specify an ` env ` file to load. The command
126+ above will run the server with ` NODE_ENV ` set to ` local ` .
0 commit comments