tpm_dashboard_2.0 v2.0.1
Product Purpose and Context
This project is intended to help automate the process of matching and maintaining the information of all the developers under Turing.
It helps achieve the goal of matching developers with a client or role inside Turing based on skills, working hours and challenges a developer has cleared, as well as feedback from interviews and other related criteria.
It achieves that by helping to maintain the necessary information of all the developers, and this information can also be shared with the client in the form of a package, in order to render match making more effective.
Project Architecture
Matching System
itself consists of two separate projects:
- The client side part which is built using ReactJS along with antd and turing-uiux.
Initially, Material UI was used as a front-end framework but now it is being replaced with Ant Design components, in order to make sure that all the internal projects of Turing use and share the same UI design and look & feel.
- On the back end, the matching system exposes a REST API built using NodeJS and Nest.JS as web framework, as well as MySQL as the RDBMS.
Components of the API use TypeScript and TypeORM.
Quick crash-in guide
- Read Getting Started below, install all required tools.
- Connect to your teammate David Truong or somebody other from DevOps team. He would provide VPN and SQL access.
- Ensure you have proper git access. Create your new github account with corporate email and nickname ending in
-turing
. Connect to Zan on getting access to git. - Directory structure:
/work/turing
/sources
/tpm_dashboard_2.0
/self-serve
- Use nvm. Ensure that you use Node 14.17.0.
- Run
npm install
in:BackEnd
,FrontEnd
,Migrations
. Fill in proper.env
files inBackEnd
,FrontEnd
, using.env.example
/.env.development
files as a base. - To run and seed db:
cd Migrations && npm install && docker-compose -f docker-compose.db.yml up
. Give it some time to finish (you should see a lot of SQL logs). If you encounter an error in SQL part, don't forget to clear db:docker exec -ti migrations_db_1 mysql -u root -proot --execute='drop database if exists dev_matching; create database dev_matching'
(works with running migrations db container). First run (without db) could be unsuccessful due to mysql being not ready. - Run new terminals and start apps there:
cd FrontEnd && npm start
,cd BackEnd && npm run start:dev
.
Working on Task
- Ensure task has a Jira issue. Create one if needed in current sprint. Move it in
In progress
. https://turing.atlassian.net/secure/RapidBoard.jspa?rapidView=86&projectKey=SELF(Jira board for Self-Serve project). - Read https://github.com/TuringEnterprises/tpm_dashboard_2.0/blob/develop/docs/gitflow-summary.MD(Gitflow doc).
- Create branch and do work there. Example branch name:
bug/SELF-236-failing-migrations
. - After work is finished, create a merge PR to
develop
branch. NB: mergingdevelop
into your branch first helps a lot!
Getting started (project setup)
- Ensure you are properly authenticated in the @turingenterprises scope. If not:
- Go to https://github.com/settings/tokens
- In the
Personal access tokens
option, create a new token with the following scopes: repo, write:packages, delete:packages - Run in terminal
npm login --scope=@turingenterprises --registry=https://npm.pkg.github.com
- Inform your github username, the previously generated github token as your password, and your email
- more info
Before setting up the Matching System
, please make sure that you have installed the following prerequisites:
- Node (download the latest version from here)
- NPM (NPM - Node package manager being used to install dependencies, will be installed with Node, just make sure to have the latest version)
- MySQL and MySQL Workbench for databases here.
- Docker
(OPTIONAL)
if needed, in order to setup the project inside docker instead of directly on the host machine, here.
Matching System
can be installed by following the steps below for each of the projects. Prior to this, please make sure that you have installed the prerequisites above.
Backend API
- go to the root folder and move inside BackEnd directory:
cd tpm_dashboard_2.0/BackEnd/
- install dependencies:
npm install
- create the
.env
file using.env.example
as a reference. - start the server:
npm start
- the server will be listening on port 4001
- verify if the server is running by
curl localhost:4001
or by opening http://localhost:4001 URL in the browser
Front End
- go to the root folder and move inside FrontEnd directory:
cd tpm_dashboard_2.0/FrontEnd/
- install all the dependencies:
npm install
- start the application:
npm start
- the application will be served/hosted at localhost:3000 (Expected behaviour: signup page should open as default page)
- if the browser does not open automatically, verify that the app is running by opening the http://localhost:3000 url in your browser
RDBMS
MySQL is used for the database. In order to setup the database locally, please complete the following steps:
- install MySQL Workbench (8.0 or above)
create a database
- If you have installed MySQL locally follow these instructions
- If you are using docker
- CD into
./Migrations
- Create
.env
file. Tested(DB_USERNAME=root DB_PASSWORD=root DB_NAME=dev_matching DB_HOST=localhost DB_PORT=3306 NODE_ENV=development)
- Create and start a network
docker-compose -f ./docker-compose.db.yml up -d
- The command will start MySQL at localhost:3306 and run migrations. You can check migration logs using
docker logs migrate
- If you want to rerun migrations later
docker start migrate
- CD into
create tables and seeds initial data by running
npm run migrate
fromMigrations
package- to only create tables
npm run migration:run
- to only seed database with initial data
npm run seed:run
- to only create tables
Troubleshooting
make sure you can connect to the database using Workbench
make sure the database name matches the
DB_NAME
environment variable you specified in./Migrations/.env
make sure
NODE_ENV
is set to bedevelopment
in./Migrations/.env
file
Elasticsearch
Elasticsearch is used for faster (and more detailed) search of developers and jobs.
There are two components in Elasticseach/
folder
- logstash - used for reading data from RDBMS and storing data in elasticsearch
- elasticsearch - used as datastore and No-SQL database which can give us easier way to preform complex queries and fast search
In Elasticsearch/README.md
you can find more detailed instructions how to setup environment.
How to contribute
Starting Dec. 3, 2019, the project will strictly adhere to gitflow for development and release.
You can find more information about the new workflow [here].
(OBSOLETE)
Please clone the repository, and create a branch named according to the task out of base branch (develop).
A PR should be created to merge the code into the develop branch. The PR should ideally include the information like JIRA ticket or the Github issue that it implements, the purpose of the PR, how to test it, which outputs are expected, and any images or gifs that can help understand it.
Please make sure to run the PR changes in production mode also (especially for backend API by setting `NODE_ENV=production` as an environment variable and executing command `npm run start:prod`) to avoid any issues during deployments.
Deployment and Workflow
Environments
As of this writing (Nov. 29 2019), we use three different environments for Matching System
.
- Dev where new features are tested internally by the team.
- Staging, reserved for QA.
- Production, intended for shared use by several teams within the company.
Deployment
https://docs.google.com/document/d/1urhFA9PWVDLIvUi4rZVZD1-uN2mZT54MpbCFhsedR-A/edit?usp=sharing
URLs
- Dev: https://matching-dev-env.turing.com
- Staging: https://matching-staging.turing.com
- UAT is deployed to https://uat-matching.turing.com
- Production is deployed to https://matching.turing.com
Jenkins
The various environments use Jenkins for Continuous Deployment, with dev automatically fetching the latest code from this repositories' develop branch. This is the link to the Jenkins web portal for running the front-end and back-end builds. https://jenkins-development.turing.com/view/matching-turing-com/
As of this writing (Nov. 29 2019), migrations are run as part of the back-end build.
@Hector can help get into the system by creating the user and privileges to run builds.
New Env - Docker
Matching System
also makes use of Docker containers in order to make it easy to setup the project in any environment with docker installed. Just install docker from the link mentioned above. Once Docker is installed and running, follow the steps below to run the application:
- cd into the project's root directory from a Command Terminal (where the
docker-compose.yml
file is located) - Run command docker-compose up this will take a few minutes and both the frontend and backend api for the matching system should be ready and deployed
- Browse localhost:3000 to see the newly deployed matching system
- Matching system API will be deployed on port # 4001
- If the application is to be deployed on a remote server, NGINX can be used as a reverse proxy server to route the traffic from your - remote server’s domain to the localhost:3001 where matching system is running. Please follow This Guide for setting up NGINX server on your server machine.
Additional Resources
1 year ago