{"id":26566580,"url":"https://github.com/salgadobreno/dme","last_synced_at":"2026-04-09T02:02:23.916Z","repository":{"id":141502518,"uuid":"109065343","full_name":"salgadobreno/dme","owner":"salgadobreno","description":"Prototype of after-sales \u0026 maintenance lab management software that was being developed at Avixy which I was allowed to publish. It was shaping up to be a very interesting app.","archived":false,"fork":false,"pushed_at":"2017-11-06T02:00:09.000Z","size":1001,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-05T06:31:36.791Z","etag":null,"topics":["reactjs","ruby","sinatra","state-machine"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/salgadobreno.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-11-01T00:03:54.000Z","updated_at":"2025-07-29T14:21:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"48468050-3f4e-4e6f-9f38-2a18cd9adb95","html_url":"https://github.com/salgadobreno/dme","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/salgadobreno/dme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salgadobreno%2Fdme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salgadobreno%2Fdme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salgadobreno%2Fdme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salgadobreno%2Fdme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salgadobreno","download_url":"https://codeload.github.com/salgadobreno/dme/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salgadobreno%2Fdme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31581864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["reactjs","ruby","sinatra","state-machine"],"created_at":"2025-03-22T18:35:20.504Z","updated_at":"2026-04-09T02:02:23.897Z","avatar_url":"https://github.com/salgadobreno.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"  ```\n  +--------------------------------------------------------+\n  | APP                                                    |\n  |                                                        |\n  | CORE                   SERVICES          WEB           |\n  | +------------------+   +-----------+     +--------+    |\n  | |DeviceServiceOrder| \u003c-+ AppService| \u003c--+ SINATRA | \u003c--+------- REQUESTS\n  | +-+----------------+   +-----------+     +--------+    |\n  | | |StateMachine    |                        ^          |\n  | | +-+--------------+                        |          |\n  | | | |State         |                        |          |\n  | | | +-+------------+                     UI |          |\n  | | | | |Rules       |                        |          |\n  | | | | ++-----------+                     +--+--+       |\n  | | | | ||Operations |                     |React|       |\n  | | | | |+-----------+                     +-----+       |\n  | | | | ||Validations|                                   |\n  | +-+-+-+++----------+                                   |\n  |                                                        |\n  | +----------+                                           |\n  | |DeviceLog |                                           |\n  | +----------+                                           |\n  |                                                        |\n  | +-------------+                                        |\n  | |StateMachines|                                        |\n  | +-------------+                                        |\n  |                                                        |\n  | +------+                                               |\n  | |States|                                               |\n  | +------+                                               |\n  |                                                        |\n  | +----------+                                           |\n  | |Operations|                                           |\n  | +----------+                                           |\n  |                                                        |\n  +--------------------------------------------------------+\n```\n\n\nMongo db configuration\n==================\n\nURI format for Single-node plan:\n```\nmongodb://dbuser:dbpass@host:port/dbname\n```\n\nURI format for Cluster plan:\n```\nmongodb://dbuser:dbpass@host1:port1,host2:port2/dbname\n```\n\nThe configuration fo the mongoDB connection could be found at\ntest/mongoid.yml\n\nTests\n===\n\nTo run a single test, just do:\n\n```\nruby -I . -I test/helper test/state_test.rb --name /database.operations/\n```\n\nSinatra and React\n===================\n\n###Pre-requisites\n\n- yarn\n- node\n\n------------------------------\n### Running\n* Run JSON Server for dev:\n  `yarn api`\n* Run React components in 'dev mode'(webpack js devserver, hot reload):\n  `yarn dev`\n* Run both!\n  `yarn api | yarn dev`\n* Build React components, update app/web/public/*-bundle.js files and make it\n  available for Sinatra App:\n  `yarn build`\n* Build React components, update app/web/public*-bundle.js files and\n  make it available for Production App:\n  `yarn prod`\n* Run Sinatra App:\n  `ruby app/web/app.rb` or `rackup`\n\n#### Attention!\n\n\u003e The `API URL` will be different depending on what environment you're in or what you're trying to do. When running React devserver normally you'll be using json-server as the API, so the default `API_URL` there is set, in `webpack.config.js`, to `http://localhost:8080`. When you run `yarn build` it will use the `webpack.prod.config.js`, which sets `API_URL` to `http://localhost:4567`. You can override the `API_URL` with an environment variable(normally sent along with the command) like: \n\n\u003e `__API__='http://192.168.1.53:4567' yarn dev`\n\n\u003e `__API__='http://192.168.2.5:6060' yarn api | yarn api`\n\n\u003e `__API__='http://192.168.2.5:6060' yarn build \u0026\u0026 rackup`\n\n#### Attention2!\n\n\u003e If you're working remotely through VPN you may need to pass additional parameters to access the server.\n\n\u003e `yarn dev --host 0.0.0.0`\n\n\u003e `ruby -I . app/web/app.rb -o 0.0.0.0`\n\nCLI App\n=======\n\nRunning: `ruby app/cli3.rb [command]`\n\nTo see full StackTrace:  `GLI_DEBUG=true ruby app/cli3.rb [command]`\n\nAPP RUNNER\n==========\n\nRunning: `ruby -I . app/app_runner.rb -W0` (-W0 tries to supress\nwarnings)\n\nGUARD\n=====\n\nRunning guard: `guard`, `guard -c`(this options clears the prompt before\nevery test run)\n\n* `[enter]` in guard prompt -\u003e run all tests\n* `pause` in guard prompt -\u003e stop watching files\n\nPRY\n===\n\nUse it as command-line: `pry`\n\nUse it as debugger: `binding.pry` in code\n\nUseful commands:\n\n* `continue #debugger`\n* `next #debugger`\n* `exit #if debugging, continues, else, le`ave pry prompt\n* `show-source Device#initialize`\n* `edit Device#initialize`\n* `ls -I @device #lists instances variable`s on @device\n* `watch @device.state_machine.current_sta`te #add an expression to\n  'watch', it will tell you when it changes\n* `watch #show all watches and their curre`nt values\n* `help`\n* `whereami #shows which line you are and `the code surrounding it\n* `edit -c #edits the `whereami` location!`\n\nVagrant Customizations\n===================\n\n* Vim with Janus\n* Vim Tmux Navigator(C-h, C-j, C-k, C-l navigates between Tmux Panes and\n  also Vim splits\n* Bash aliases, see: `vagrantfiles/bash_aliases`\n\nDocker configuration\n===\nIn order to use docker as a tool for development, test and deploy in the\nproduction environment, some actions should be performed to make\neverything work smothly.\n\n* you need the docker environment installed on your machine. Please\n  refer to https://docs.docker.com/engine/installation/\n\nTo make everything work you need:\n\n1 - build the development container with ruby 2.4.1\n2 - pull the mongoid container\n3 - create a private network for the containers to share\n4 - start the mongodb container using the private network created on the\nprevious step\n\n## Build the development container\n\n```\ndocker build .\n```\n\n* you can give a name for your development container and use it in you\n  docker file to avoid forced unecessary builds.\n\neg. docker build -t company/name:tag\n\n```\ndocker build -t avixy/maintenanceservice:0.1\n```\n\n## Pull the mongoid container\n\n```\ndocker pull mongo\n```\n\nThis will pull the latest version of the mongo container\n\n## Create a local private network\n\n```\ndocker network create --driver bridge my_nw\n```\n\nPlease read:\nhttps://docs.docker.com/engine/userguide/networking/#user-defined-networks\n\n## Start the mongodb container using a existing network\n\n```\ndocker run --network=my_nw -d --name=mongodb mongo\n```\n\n## Run tests\n\n```\ndocker run \u003ccontainer_id or name\u003e rake \n```\n\n## BONUS:\n\nTo run a sinatra API test just run the container with this option:\n```\ndocker run --network=my_nw ruby -p 8080:4567 app/api_service.rb\n```\n\nTo make the container be removed after running do this:\n```\ndocker run --rm --network=my_nw -p 8080:4567 09cedce91b94 ruby\napp/api_service.rb\n```\n\nTo clear unused containers, images and networs do:\n```\ndocker system prune\n```\n\n# Using docker-compose to run your environment\n\nI have added a docker compose file to help the deployment of this\napplication, but it can also be used to the development environment.\n\n## To run and build the environment\n```\ndocker-compose -f docker-compose.yml up -d --build -d\n```\n\nThis will make the mongo container running and will run the application\ntests. You could see the test result by running `docker logs` or\nre-running the service docker container with the rake instruction\nenabled:\n\n```\ndocker run --network=devicemanagementengine_default --rm -it --env\nRACK_ENV=test avixy/maintenancesrv:0.1 rake\n```\n\nYou could use docker-compose command to run the service vm, just\nremember to set the network between the containers.\n\nAt the end of the development session run `docker compose down` to shut\ndown all containers, networks and volumes created by the docker-compose\ncommand.\n\nProduction deployment\n===\n\nTo deploy this project into production you should use the docker-machine\napplication (https://docs.docker.com/machine/install-machine/):\n\n- Install docker into the production host if needed\n- Configure your local docker machine to map the production host using a\n  generic driver\n- Use the docker-compose-production.yml file as the configuration base\n  for your deployment\n- Be sure you have pair of pub/priv key in your local machine\n\nFirst of all, you have to copy the public key to remote-host.\n```\nssh-copy-id -i ~/.ssh/id_rsa.pub \u003cremote-host - in this case 192.168.2.5\u003e\n```\n\nThere's a script create in order to make it smooth and is\nlocated at 'scripts/deploy.sh'.\n\nFirst this script checks if there's a mapping the production host in ur local\nmachine:\n```\n(sudo docker-machine ls -q | grep '^vm$')\n```\n\nThen it updates React Bundle Resources showed above:\n```\n(cd ../ \u0026\u0026 exec yarn prod)\n```\n\nAfter that, if the environment doesnt have the production host mapping\nit creates it locally:\n```\ndocker-machine create \\\n   --driver generic \\\n   --generic-ip-address=192.168.2.5 \\\n   --generic-ssh-key $KEY_FILE \\\n   --generic-ssh-user avixy vm\n```\n\nFinaly it deploys the application in the proper production container\n```\ndocker-compose -f docker-compose-production.yml up --build -d\n```\n\nThis should bring everything that you need to the production host\n\nYou can check the status of your machine with the command:\n```\nsudo docker-machine ls\n```\n\nThere's also a Rake task to do all above procedures in once. Check it\nout:\n\n```\nrake deploy[key_file]\n```\n\nThat key_file parameter is a rsa key that need to be on server in order\nto allow access to production server.\n\nRunning this task as super user, it brings on what u need and deploy\nwhat production server needs.\n\nGIT HOOKS\n===\n\nIn order to not miss any TODO comments in src code, there's script\n\"todo_finder.sh\" that\nwas mapped to a Rake Task :\n\n```\nrake todo\n```\n\nThis script generates todo.txt file and outputs to screen lines that\ncontains TODO comments.\n\nIn order to update that todo.txt file for development, it was created\nalso a git hook \"pre-commit\" located in scripts folder.\n\nIs recomended to create symbolic link inside .git folder to every\ncommit so that todo.txt file could be updated.\n\n```\nln -s scripts/pre-commit .git/hooks/pre-commit\nchmod +x .git/hooks/pre-commit\n```\n\n\nKNOWN ISSUES\n===========\n\n* We're using gem `sourcify` in the lib/ProcSerializer utility, this gem\nis old, unsuported and could cause us problems. We've documented known\nproblems in the \"bugs\" section of it's test and decided not to switch\noff of it for the moment because maybe the feature of Storing/Restoring\nprocs/lambdas will be more of a Development helper. If it gets\nproblematic we'll move to either only using Validations/Operations\ndefined in classes, or switch the implementation to other gems:\nruby2ruby, seattlerb/ruby_parser, whitequark/parser\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalgadobreno%2Fdme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalgadobreno%2Fdme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalgadobreno%2Fdme/lists"}