You'll find two sister products in this repository:
Both are created, run and managed by ReDI School of Digital Integration. We're a non-profit school in Germany (in Berlin, Hamburg, Munich and NRW) with a community of hundreds of professionals from the digital industry volunteering to teach and mentor students. Our students are tech-interested locals and newcomers to Germany.
First of all, ReDI Connect / Talent Pool connect to a Salesforce instance via the nestjs-api app. You'll need to set a number of environment variables in your .env
file to make the Salesforce connection work. Reach out to @helloanil, @katamatata or @ericbolikowski to get set up.
After you've set up .env
, make sure to update NX_DEV_MODE_EMAIL_RECIPIENT
to your own email address to receive emails from the platform.
yarn
in project root to install dependencies.yarn start:all
to boot all apps, or a subset of apps using the start:x
commands in package.json.You can open these in your browser:
If you're using VsCode, make sure you:
explorer.fileNesting.enabled
) to collapse React component .graphql
, .generated.ts
and .scss
files. This makes it easier to use the file explorer.yarn graphql:codegen
.We use Nx Dev Tools to manage this monorepo. Find all the apps/products under apps/
and all libraries they consume under libs/
.
Use trunk-based branching - create feature/bugfix/docs/refactor/blabla branches directly off master
and file PRs to merge back into master
. Name branches <type>/short-hyphenated-title
, where type
is feat
, fix
, docs
, style
, refactor
, test
or chore
.
The GraphiQL playground is a tool that allows you to test the GraphQL API. It is available at http://localhost:3333/graphql.
The playground is a great tool to test the API, but it is not meant to be used in production. It is a development tool only.
Use it to view all the available GraphQL queries and mutations. Most queries and mutations require authentication. To authenticate, you need to provide a valid JWT token. You can get a valid JWT token by logging in to the ReDI Connect application. Use your browser's developer tools to view network requests. Once you are logged in, find the POST /api/redUsers/login
request. There, copy the jwtToken
. Then, in the GraphiQL playground, click on the HTTP HEADERS
tab. Paste the following:
{
"Authorization": "Bearer <your-jwt-token>"
}
Alternatively, use Loopback's Swagger (http://localhost:3003) to manually send a login request, and copy the JWT token from the response.
See this Loom video for a demo: https://www.loom.com/share/b2328a7ec6054afebb8249ea59ef2f18
TL;DR: run nestjs-api + yarn graphql:codegen
to update react-query hooks after changing nestjs entity models or any .graphql file. Install VsCode “Run on Save” extension to automatize codegen (for .graphql files).
Note: in case code generation doesn’t work, it might be because the nestjs-api app is not running. Make sure that it is in a running state.
We use graphql-codegen
to generate react-query hooks (queries and mutations). To run the code generation, first ensure the nestjs-api is running, then execute yarn graphql:codegen
.
To auto-run the codegen after changes to .graphql
files, install this VsCode “Run on Save” extension: https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave. The repository’s VsCode config (in .vscode/settings.json
) is already set up to enable this.
schema.graphql
in the project root folder. If you want to ensure it’s 100% up to date, first start NestJS (yarn start:alone:nestjs-api
), then run yarn graphql:codegen
Schemas for data models (e.g. ConProfile
, ConMentoringSession
, TpJobseekerProfile
and TpJobListing
) are defined in two places:
firstName
, birthDate
, etc.), through a web admin interface. Talk to Eric/Anil/Manu for access.common-types
library: see the repository folder libs/common-types/src/lib
Each data model in the common-types
folder is represented by a Typescript class. Every data model has two representations:
Record
, the model’s structure, property names and property types reflect how the data model is. The term Record is chosen since it’s standard terminology in Salesforce. Record is just Salesforce’s way of saying row or instance.Entity
, the model follows a simpler and flatter structure, the same one that was used for years before CON and TP data were migrated to Salesforce. We use the term Entity as it implies a “thing”, such as a jobseeker’s profile, a mentor<>mentee match, a logged mentoring session, and so forth.There are two important reasons why data models have two representations:
__c
is automatically added to the name of any property we define on a model/object. There are also nested objects within objects.To convert data from one domain representation to another, we use Mapper classes. Look for file names ending in .mapper
.
Our nestjs-api
thereafter uses GraphQL and code generation (codegen) to defining types (both TS types and GraphQL object tpyes) in various places. You can think of this as the data models “bubbling up” from the back-end:
libs/common-types/src/lib
folder, as typescript classes@ObjectType()
yarn graphql:codegen
uses the graphql-codegen
tool to read the schema. It then generates Typescript types (see libs/data-access/src/lib/types/types.ts
). It also scans all .graphql
files for queries and mutations, and creates react-query
queries and mutations stored in .generated.ts
files right next to the .graphql
file.See the Onboarding Checklist and Workflow for design tasks in our Wiki.
We send out automated reminder emails to ReDI Connect mentor and mentee users, for things like "you've both been in an active mentorship for 10 days, no mentoring sessions have been logged yet, please start logging them". See Daily job to send notification emails to users for a full list of automated reminder emails.
Main benefits:
ReDI Connect and ReDI Talent Pool are two React front-ends that use a Express/Loopback/NodeJS back-end to access data stored in a MongoDB database. The backend is hosted on a virtual machine, whereas the React front-ends are compiled into static assets stored on AWS S3 / CloudFront. Emails to users are sent via AWS SES. Some other static assets plus user uploads are hosted in AWS S3 buckets.
This diagram shows the current system architecture of both platforms:
We use pm2
on the production server to manage our two nodejs servers, loopback
and nestjs-api
.
pm2 monit
for an overview of the two servers and their logs. Run pm2 status
for a quick status of the servers.pm2 start <server-name>
or pm2 stop <server-name>
. To restart, run pm2 restart <server-name>
. You don't need to include environment variables or various other flags, pm2 has this configuration "saved" since the first boot.If you ever need to configure/start the servers from "scratch", here's how to do it:
[All the environment variables] pm2 restart --name loopback --log /home/ubuntu/loopback.log --max-memory-restart 250M /home/ubuntu/connect/apps/api/server/server.js
[All the environment variables] pm2 start --name nestjs-api --log /home/ubuntu/nestjs-api.log --max-memory-restart 500M connect/dist/apps/nestjs-api/main.js
If you need to update the environment variables, run the above command with restart
instead of start
, and also add the --update-env
flag.
All the below is written by Nx.
This project was generated using Nx.
🔎 Powerful, Extensible Dev Tools
Nx supports many plugins which add capabilities for developing different types of applications and different tools.
These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
Below are our core plugins:
npm install --save-dev @nrwl/react
npm install --save-dev @nrwl/web
npm install --save-dev @nrwl/angular
npm install --save-dev @nrwl/nest
npm install --save-dev @nrwl/express
npm install --save-dev @nrwl/node
There are also many community plugins you could add.
Run nx g @nrwl/react:app my-app
to generate an application.
You can use any of the plugins above to generate applications as well.
When using Nx, you can create multiple applications and libraries in the same workspace.
Run nx g @nrwl/react:lib my-lib
to generate a library.
You can also use any of the plugins above to generate libraries as well.
Libraries are shareable across libraries and applications. They can be imported from @talent-connect/mylib
.
Run nx serve my-app
for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
Run nx g @nrwl/react:component my-component --project=my-app
to generate a new component.
Run nx build my-app
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run nx test my-app
to execute the unit tests via Jest.
Run nx affected:test
to execute the unit tests affected by a change.
Run ng e2e my-app
to execute the end-to-end tests via Cypress.
Run nx affected:e2e
to execute the end-to-end tests affected by a change.
Run nx dep-graph
to see a diagram of the dependencies of your projects.
Visit the Nx Documentation to learn more.
Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly.
Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nx’s advanced code generation and project dependency graph, plus a unified experience for both frontend and backend developers.
Visit Nx Cloud to learn more.