{"id":37854562,"url":"https://github.com/thembones79/lem-server","last_synced_at":"2026-01-16T16:24:41.455Z","repository":{"id":40422556,"uuid":"282040091","full_name":"thembones79/lem-server","owner":"thembones79","description":"NodeJS with ExpressJS REST API for LEM (Line Efficiency Monitoring) System","archived":false,"fork":false,"pushed_at":"2025-01-20T05:11:40.000Z","size":525,"stargazers_count":1,"open_issues_count":47,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T06:23:01.235Z","etag":null,"topics":["api","efficiency","efficiency-monitoring","express","lem","manufacturing","mongodb","mongoose","nodejs","production","rest","rest-api"],"latest_commit_sha":null,"homepage":"https://riverdi-lem.herokuapp.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thembones79.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-23T19:39:11.000Z","updated_at":"2023-04-12T08:29:23.000Z","dependencies_parsed_at":"2025-01-20T06:21:52.003Z","dependency_job_id":"d43a9fc0-0c3f-4ffa-ab55-9bd3002a9d62","html_url":"https://github.com/thembones79/lem-server","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/thembones79/lem-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thembones79%2Flem-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thembones79%2Flem-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thembones79%2Flem-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thembones79%2Flem-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thembones79","download_url":"https://codeload.github.com/thembones79/lem-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thembones79%2Flem-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","efficiency","efficiency-monitoring","express","lem","manufacturing","mongodb","mongoose","nodejs","production","rest","rest-api"],"created_at":"2026-01-16T16:24:40.752Z","updated_at":"2026-01-16T16:24:41.442Z","avatar_url":"https://github.com/thembones79.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST API for LEM (Line Efficiency Monitoring) System\n\n[**LEM System**](https://riverdi-lem.netlify.app/) is an internal tool for measuring and monitoring manufacturing/production lines **[app overview](https://github.com/thembones79/cs50x/tree/master/project#readme)**.\n\nThe project was created as the [final project](https://cs50.harvard.edu/x/2020/project/) to graduate [Harvard\u0026#39;s CS50](https://cs50.harvard.edu/x/2020/) for benefit of my colleagues at Manufacturing Department of [Unisystem](https://www.unisystem-displays.com/en/) and [Riverdi](https://riverdi.com/) (Industrial display and touch screen manufacturer).\n\nThe application has to solve some issues that my folks have to tackle on daily basis.\n\n## The main features of **[LEM System](https://github.com/thembones79/cs50x/tree/master/project#readme)**:\n\n**The software has to:**\n\n1. Utilize bar-code scanners (in fact, it is not a bar code but [Data Matrix](https://en.wikipedia.org/wiki/Data_Matrix) – it\u0026#39;s 2D code, somewhat similar to QR Code) that the company bought for scanning newly developed stickers that are placed on ready made products (as input data)\n2. Read MS Excel file with production schedule and part number details and retrieve data about `tact times`, `part numbers` and `orders` to work with.\n3. Give an instant feedback about `MCT` (Mean Cycle Time), `LCT` (Last Cycle Time), `Efficiency`, estimated `order duration` and estimated `time of order completion`. (also with colors - GREEN and RED so people can instantly see if they are winning or losing)\n4. Give an information about `order`, `customer`, manufactured piece (part number), ordered `quantity`\n5. Give an information about `missing pieces`\n6. Give an information of mixed up pieces (for example the same part number but form another order from same or another client\n7. Give feedback about counting one piece more than once\n8. Give information about how many pieces (of current order) was done on current line and on all the lines and how many pieces are to do\n9. Give ability to have `breaks` during completion the given order\n10. Give ability to `work on more than one line`\n11. Give ability to `start an order on one line and finish it on another`\n12. Give ability to work on `more than one order simultaneously`\n13. Give ability to work on `the same (big) order on more than one line at the same time`\n14. Handle users (production workers, service, foremen and managers) accounts (with `authorization` and `authentication`)\n15. When user reserves a line, the line has to be unavailable to another user until it is released\n\n**Future:**\n\nManager dashboard with:\n\n1. Statistics: orders, users, lines, errors, times, partnumbers\n1. User account management\n1. Line management\n1. Order and work scheduling (← that one, can be implemented only when the application will be independent form this huge excel spreadsheet that is currently a bread and butter of all department and everything is based on it)\n\nThe app is meant to work with some kind of frontend. In this particular system, there is SPA (Single Page Application) in React created for this job ([app](https://riverdi-lem.netlify.app/), [code](https://github.com/thembones79/lem-client#readme)).\n\nLEM System is meant to be an internal tool, so there is no \"sign up\" feature. Users can not add themselves to the system, they can be added only by admin/manager.\n\n### Install:\n\n```\nnpm install\n```\n\n### Run:\n\n```\nnpm run dev\n```\n\nThe app listens on port **`3090`** if PORT is not provided as a environmental variable.\n\n#### Please note that the application has \"config\" directory.\n\nThe \"config\" directory should have three files:\n\n- `Keys.js` (committed to the repository – consists of logic determining if the app is currently in production or development environment and uses one of described below config files accordingly)\n- `Prod.js` (all secrets, api keys, MongoDB connection strings are taken here from environmental variables. In this particular case I\u0026#39;m using Heroku environment)\n- `Dev.js` (UNCOMMITTED! – you have to create it yourself and put there MongoDB connection string and secret string (long, random string is needed to properly generate JWTs). Please add this file to your \".gitignore\" and never send or commit it anywhere!)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/uncommitted_on_backend.png\" /\u003e\n\u003c/p\u003e\n\n---\n\n### Usage _(note: this is a REST API and it is supposed to be consumed by some kind of frontend, SPA preferably, or a mobile app)_:\n\n---\n\n**Route (unprotected): `/signin`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{email, password}`\n\u003e\n\u003e Response: `{token, userId, username, userType}`\n\n_**Feature:** allows existing user to \"sign in\" - gives user a valid JSON Web Token that can be used to make other protected API requests_\n\n---\n\n**Route (protected): `/api/line`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{lineNumber}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{message: confirmationMessage}`\n\n_**Feature:** allows user to add new production line_\n\n---\n\n**Route (protected): `/api/lines`**\n\n\u003e Request: `GET`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{lines}`\n\n_**Feature:** fetches all lines data_\n\n---\n\n**Route (protected): `/api/line/status`**\n\n\u003e Request: `PUT`\n\u003e\n\u003e Request Body: `{lineId, lineStatus}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{message: confirmationMessage}`\n\n_**Feature:** changes chosen line (\"lineId\") status to lineStatus sent in the request\u0026#39;s body_\n\n---\n\n**Route (protected): `/api/user`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{firstname, lastname, email, password, type}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{userType: user.type, userName: user.firstname, userId: user._id,}`\n\n_**Feature:** create a new user with data provided in the request\u0026#39;s body (important! New users can be added only by managers/admins – standard user would get 422 error with message: **\"You do not have privileges to add new user!\"** )_\n\n---\n\n**Route (protected): `/api/order`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{orderNumber, quantity, partNumber, qrCode, customer, tactTime}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{order}`\n\n_**Feature:** adds new order_\n\n---\n\n**Route (protected): `/api/order/close`**\n\n\u003e Request: `PUT`\n\u003e\n\u003e Request Body: `{orderNumber}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{message: confirmationMessage}`\n\n_**Feature:** closes (existing and opened) order_\n\n---\n\n**Route (protected): `/api/orders`**\n\n\u003e Request: `GET`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{orders}`\n\n_**Feature:** fetches all orders data_\n\n---\n\n**Route (protected): `/api/order/:dashedordernumber`**\n\n\u003e Request: `GET`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{existingOrder}`\n\n_**Feature:** fetches chosen order full data_\n\n---\n\n**Route (protected): `/api/order/:dashedordernumber`**\n\n\u003e Request: `DELETE`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{message: confirmationMessage}`\n\n_**Feature:** deletes chosen order_\n\n---\n\n**Route (protected): `/api/scan`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{scanContent, errorCode, _line, _user}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{existingOrder}`\n\n_**Feature:** adds new scan to the chosen order and chosen line_\n\n---\n\n**Route (protected): `/api/menu`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{menuContent, timeStamp}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{existingMenu}`\n\n_**Feature:** overwrites existing order menu with new one (with new time stamp as synchronization indicator and sanity check. Order menu consists orders that have to be processed by manufacture department, and the application. This route is meant to be hit not by regular frontend, but by another node service that takes company\u0026#39;s internal data – excel spreadsheet – processes it and sends to the API in 10 minute intervals)._\n\n---\n\n**Route (protected): `/api/menu`**\n\n\u003e Request: `GET`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{timestamp, menuContent}`\n\n_**Feature:** fetches updated order menu content with a last update time stamp_\n\n---\n\n**Route (protected): `/api/break/start`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{orderNumber, _line}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{existingOrder}`\n\n_**Feature:** creates a new break in chosen order on chosen line (and adds time stamp to the breakStart property)_\n\n---\n\n**Route (protected): `/api/break/end`**\n\n\u003e Request: `POST`\n\u003e\n\u003e Request Body: `{orderNumber, _line}`\n\u003e\n\u003e Request Security Headers: `{authorization: validJsonWebTokenString}`\n\u003e\n\u003e Response: `{existingOrder}`\n\n_**Feature:** adds a breakEnd time stamp_ _to the last break without a breakEnd_ _in chosen order on chosen line (and adds time stamp to the breakStart property)_\n\n---\n\n### The application also checks correctness of barcode reader scans.\n\nThe app divides the code from the scan into 2 parts:\n\n1. the main code (I have called it \"qrCode\", which takes it from your Excel and assumes that it is correct and that it can change, because, for example, a manager came up with a different pattern to generate and I will not predict it)\n2. and attached to it a (five-digit) number from 00001 to the given quantity\n\nWhen it comes to validation, the app checks:\n\n1. is the part before the number the same as the code taken from your excel (if not, it gives the code `e003 - \"wrong code\"`)\n2. whether the number is in the given range (if not, it gives an error `e002 - \"out of range\"` )\n3. if the number was not repeated (if it repeated, it gives error `e001 - \"repeated scan\"`)\n4. if there is no error from the above it returns `e000 - \"OK\"` and **counts this scan**\n\nThanks to this, manager can change the pattern in Excel that generates the basis of the sticker code and theoretically nothing should go wrong\n\nError codes will be used in the future for statistical purposes.\n\nBesides time efficiency, there are going to be statistics about errors on particular line, particular user, particular order, particular part number and all permutation of the above.\n\nSo it would be easier to estimate, for example, which partnumber is \"harder\" to make, or who needs some more training, or which line has mixed up components, or which line needs extra help from quality department or from other line to deliver on time, etc.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/thembones79/cs50x/master/project/assets/RiverdiLEM_stack2.png\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/thembones79/cs50x/master/project/assets/RiverdiLEM_datamodel.png\" /\u003e\n\u003c/p\u003e\n\n## [ \u003e Detailed Project Overview \u003c ](https://github.com/thembones79/cs50x/tree/master/project#readme)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthembones79%2Flem-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthembones79%2Flem-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthembones79%2Flem-server/lists"}