This project was built for The Israel Museum, Jerusalem.
The technology stack:
For the DB I used MySQL Link
For the FrontEnd I used React with Redux and Material UI Link
For the BackEnd I used REST-API and WebSocket (NodeJS) - current repository
For the deployment I used AWS-EC2 Link
For the documentation I used wiki.js Link
To menage all the project I used Monday and Git
The project goal is to build a Management events system for IMJ.
General documentation on the structure of the IMJ project
- .env - required variables in ./_env
- db structure and data - ./sql/structure/imj_db.mwb || ./sql/migration/last_dump.sql
Production: https://www.yisraelbar.xyz Local: http://localhost:3000
Production:
- Rest: https://rest-api.yisraelbar.xyz
- WebSocket: wss://ws-api.yisraelbar.xyz
Local:
- Rest: http://localhost:3001
- WebSocket: ws://localhost:3020
Run the project - Simply by running the commend: docker-compose up Stop the project: docker-compose down --rmi all
To make any request REST / WS you will have to get a token from here There 3 types of Tokens:
- Platform - used for all the requests (valid for 1d)
- Login -(NOTE - NOT available yet) used for 2FA, after you enter username and password another validation is required: email/sms (valid for 20m)
- Reset Password - (valid for 20m)
Payload token for example:
{
"user": { "id": 1, "level": 1 },
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiY295NWR5d0gyM0dQdHpjaFB2ZGs2Y0ZpWGVqenlXcmNBQUJqWVN0SWMzWT0iLCJhbGdvcml0aG0iOiJIUzI1NiIsImlhdCI6MTY0ODE1OTIxNSwiZXhwIjoxNjQ4MjQ1NjE1fQ.EwRKw_6WVGcpU6n2SSMyAawUz0YPVmWDB6xZcScqSbM"
}
The token been created with
The project works with db in mysql, where the db name is: imj_db When the project starts to run he tries to init db connections from .env file The values:
DB_HOST = localhost
DB_USERNAME = root
DB_PASSWORD = password
DB_NAME = imj_db
All call's to db (execution of sql queries) done by db_helper file ./utils/db_helper
For example:
const product = await db_helper.get(query.get_product_by_id(product_id))
contains queries to update the dbs
contains DB structure: imj_db
contains all queries to mysql db
All about the WS in the project you will find in our ws-documentation wiki-ws
After the connection to the WS a unique session will be created in order to identity the connection and handle all of his requests. Session example:
{ user: { id: 1, level: 1 }, authenticate: true }
All the rest is this project are been declare in index.js and the implementation is in the ./api/ folder, The available EndPoints:
- auth
- bid
- client
- cost
- csv
- event
- event_type
- forgot_password
- location
- schedule_event
- supplier
- user
- utils
Each EndPoint divide to three parts:
- auth.routes.js
- auth.controller.js
- auth.service.js
More info in our Wiki
Some of the tasks in the project are highly consuming cpu usage and in order to not block the Node main loop - we created workers for those tasks. The task that using a worker: csv - in order to create a csv files for different tables in the db/ and client display
We using ./utils/helper.js
in order to validate phone number/ emails/ passwords etc' using regex.
We using Rabbit-MQ in order to handle our loges in the project.
We using a single connection in order to connect to the queues,
each queue use ./utils/message_broker.js
that's produce (DP - Singleton) object of the queue
For more info about RabbitMQ click here
The queue path in the project: ./utils/log_queue.js
The Folder ./files/
is contain all the files that user will upload or create(csv/pdf) while he used the website, in order to download the files the client side need to call to follow path:
http://example.com/assets/file_name.pdf
For example:
It runs a job/task periodically on a given schedule in our server, and one of the benefit of this is that we able change the task or replace it without stopping the server.
Our cron job is: ./cron_job/clean_files.js
and every night in: 00:00 it delete all the files that created during the day. (in order to clean the server from unused files)
The sms in our project is in use to for 2FA, sms path in the project: ./utils/send_sms.js
We using twilio package to send the sms.
sms-twilio
The emails in our project is used for forgot password/ send files/ 2FA The package that we used: sendgrid/mail
We using csv files in order to produce reports and db tables data. The package that we used: csv-writer
We using the following package in order to create FDP files for bids. The package that we used: pdfkit
👀 All rights reserved to Yisrael Bar
🌱 How to reach me:
My Linkedin
If you want to see more of my projects:
My GitHub