|
1 |
| -# U-Bahn user interface |
| 1 | +# UBahn App |
2 | 2 |
|
3 |
| -This code base represents the user interface for the U-Bahn project. |
| 3 | +## Install software |
4 | 4 |
|
5 |
| -## Local Deployment |
| 5 | +- node 12.x |
| 6 | +- npm 6.x |
| 7 | +- docker |
| 8 | +- S3 |
6 | 9 |
|
7 |
| -Before you deploy, you need to configure the following in the application: |
| 10 | +## Deployment |
8 | 11 |
|
9 |
| -```text |
10 |
| -REACT_APP_API_URL => The endpoint from which the application retrieves the users (and groups and most of the data) as well as to which the updates are pushed to |
| 12 | +There are two apps involved - a front end build using create react app and a backend which is a nodejs api |
11 | 13 |
|
12 |
| -REACT_APP_SEARCH_UI_API_URL => The endpoint from which the user can download the bulk upload template files as well as upload the bulk user upload file to |
| 14 | +When working locally, you will run the following commands (after setting the necessary environment variables): |
13 | 15 |
|
14 |
| -REACT_BULK_UPLOAD_TEMPLATE_ID => The id of the database record which is associated with the bulk upload template file. You would need to query the endpoint under REACT_APP_SEARCH_UI_API_URL to get the id and then set it against this variable |
| 16 | +- npm install |
| 17 | +- cd client && npm install |
| 18 | +- cd .. && npm run dev |
15 | 19 |
|
16 |
| -REACT_APP_EMSI_SKILLPROVIDER_ID => The skill provider id with name 'EMSI'. Denotes that the skills with an externalId are using EMSI as the skill provider. |
| 20 | +The front end proxies request (some of them) to localhost:3001, which is the backend api code base. This configuration is located in `client/package.json` file itself |
17 | 21 |
|
18 |
| -REACT_APP_ATTRIBUTE_ID_LOCATION |
19 |
| -REACT_APP_ATTRIBUTE_ID_COMPANY |
20 |
| -REACT_APP_ATTRIBUTE_ID_TITLE |
21 |
| -REACT_APP_ATTRIBUTE_ID_ISAVAILABLE |
22 |
| - => All 4 of the above are the ids of the attributes with name "location", "company", "title" and "isAvailable" respectively. These are used to filter attributes for display under a dedicated section named company attributes. Since these already have UI elements of their own, they are filtered from the list of company attributes |
23 |
| -REACT_APP_AUTH0_DOMAIN => The Auth0 login domain |
24 |
| -REACT_APP_AUTH0_CLIENTID => The Auth0 clientId |
25 |
| -``` |
| 22 | +## Local database deployment |
26 | 23 |
|
27 |
| -You can create a `.env.local` file and provide the above configuration. Note that there's more configuration that you can change and you can find this under `src/config.js`. The above configurations are the minimum ones, that you need to launch the app successfully. |
| 24 | +1. Navigate to docker-db run `docker-compose up -d` |
| 25 | +2. Follow *Configuration* section to update config values |
| 26 | +3. Run `npm i` and `npm run lint` |
| 27 | +4. Create table, `npm run create-tables`, this will create tables (if you need this) |
| 28 | +5. Startup server `npm run start` |
28 | 29 |
|
29 |
| -Once the configuration is set, you can proceed to deploy |
| 30 | +## Configuration |
30 | 31 |
|
31 |
| -The code base has been setup using [Create React App](https://github.com/facebook/create-react-app). Thus, to start the application locally, you need to first (and only once) run the following command: |
| 32 | +Configuration for the application is at `config/default.js` and `config/production.js`. The following parameters can be set in config files or in env variables: |
32 | 33 |
|
33 |
| -```bash |
34 |
| -$ npm install |
35 |
| -// Will install the dependenceis |
36 |
| -``` |
| 34 | +- LOG_LEVEL: the log level |
| 35 | +- PORT: the server port |
| 36 | +- API_VERSION: the API version |
| 37 | +- AUTH_SECRET: TC Authentication secret |
| 38 | +- VALID_ISSUERS: valid issuers for TC authentication |
| 39 | +- AMAZON.AWS_ACCESS_KEY_ID: The AWS access key |
| 40 | +- AMAZON.AWS_SECRET_ACCESS_KEY: The AWS secret key |
| 41 | +- AMAZON.AWS_REGION: The Amazon region to use when connecting. For local dynamodb you can set fake value. |
| 42 | +- AMAZON.IS_LOCAL_DB: Use local or AWS Amazon DynamoDB |
| 43 | +- AMAZON.DYNAMODB_URL: The local url, if using local Amazon DynamoDB |
| 44 | +- AMAZON.DYNAMODB_READ_CAPACITY_UNITS: the AWS DynamoDB read capacity units, if using local Amazon DynamoDB |
| 45 | +- AMAZON.DYNAMODB_WRITE_CAPACITY_UNITS: the AWS DynamoDB write capacity units, if using local Amazon DynamoDB |
| 46 | +- AMAZON.DYNAMODB_UPLOAD_TABLE: DynamoDB table name for upload |
| 47 | +- AMAZON.DYNAMODB_TEMPLATE_TABLE: DynamoDB table name for template |
| 48 | +- AUTH0_URL: Auth0 URL, used to get TC M2M token |
| 49 | +- AUTH0_AUDIENCE: Auth0 audience, used to get TC M2M token |
| 50 | +- TOKEN_CACHE_TIME: Auth0 token cache time, used to get TC M2M token |
| 51 | +- AUTH0_CLIENT_ID: Auth0 client id, used to get TC M2M token |
| 52 | +- AUTH0_CLIENT_SECRET: Auth0 client secret, used to get TC M2M token |
| 53 | +- AUTH0_PROXY_SERVER_URL: Proxy Auth0 URL, used to get TC M2M token |
| 54 | +- BUSAPI_URL: the bus api, default value is `https://api.topcoder-dev.com/v5` |
| 55 | +- KAFKA_ERROR_TOPIC: Kafka error topic, default value is 'common.error.reporting' |
| 56 | +- KAFKA_MESSAGE_ORIGINATOR: the Kafka message originator, default value is 'ubahn-search-ui-api' |
| 57 | +- UPLOAD_CREATE_TOPIC: the upload create Kafka topic, default value is 'ubahn.action.create' |
| 58 | +- TEMPLATE_FILE_MAX_SIZE: the template file restrict size, default value is '2MB' |
| 59 | +- TEMPLATE_FILE_MIMETYPE: the template file accept type, default value is 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
| 60 | +- TEMPLATE_S3_BUCKET: the template s3 bucket name, default value is 'ubahn' |
| 61 | +- UPLOAD_S3_BUCKET: the upload s3 bucket name, default value is 'ubahn' |
| 62 | +- S3_OBJECT_URL_EXPIRY_TIME: the s3 url expiry time, default value is '1 hour' |
| 63 | +- EMSI_CLIENT_ID: emsi oAuth 2.0 client id, used to get emis oAuth 2.0 token |
| 64 | +- EMSI_CLIENT_SECRET: emsi oAuth 2.0 client secret, used to get emsi oAuth 2.0 token |
| 65 | +- EMSI_GRANT_TYPE: emsi oAuth 2.0 grant_type, used to get emsi oAuth 2.0 token, should always be the string 'client_credentials' |
| 66 | +- EMSI_SCOPE: emsi oAuth 2.0 scope, used to get emsi oAuth 2.0 token, default value is 'emsi_open' |
| 67 | +- EMSI_AUTH_URL: emsi oAuth 2.0 auth url, used to get emsi oAuth 2.0 token, default value is 'https://auth.emsicloud.com/connect/token' |
| 68 | +- EMSI_BASE_URL: emsi base url, used to get emsi skills, default value is 'https://skills.emsicloud.com/versions/latest' |
37 | 69 |
|
38 |
| -followed by: |
39 |
| - |
40 |
| -```bash |
41 |
| -$ npm start |
42 |
| -// Will start the application at http://localhost:3000 |
43 |
| -``` |
| 70 | +Also check out the client folder's README file for additional configurations to set for the front end |
0 commit comments