{"id":15725839,"url":"https://github.com/ndrean/superm-v4","last_synced_at":"2026-04-06T08:01:50.492Z","repository":{"id":124426667,"uuid":"328277983","full_name":"ndrean/superm-v4","owner":"ndrean","description":"online shopping React tuto / JJ with backend (ruby/Sinatra) to save shopping cart to Redis","archived":false,"fork":false,"pushed_at":"2021-01-11T02:28:52.000Z","size":32733,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T01:28:45.178Z","etag":null,"topics":["nginx","overmind","puma","react","redis","ruby","sinatra"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ndrean.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":"2021-01-10T01:08:16.000Z","updated_at":"2021-01-11T02:28:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"8d4f6ec9-a9a1-4bc1-984e-b0342e504abf","html_url":"https://github.com/ndrean/superm-v4","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ndrean/superm-v4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrean%2Fsuperm-v4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrean%2Fsuperm-v4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrean%2Fsuperm-v4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrean%2Fsuperm-v4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndrean","download_url":"https://codeload.github.com/ndrean/superm-v4/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndrean%2Fsuperm-v4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31464102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","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":["nginx","overmind","puma","react","redis","ruby","sinatra"],"created_at":"2024-10-03T22:24:31.999Z","updated_at":"2026-04-06T08:01:50.475Z","avatar_url":"https://github.com/ndrean.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React frontend with Sinatra/Redis backend\n\nWe will save here the cart to Redis configured to save to disk. We have a small Ruby/Sinatra api that serves the React requests (via the app-server Puma), and Sinatra communicates with Redis.\n\n## 1) Running **dev mode** on localhost with **overmind**\n\nWe have the following directory structure:\n\n```bash\n-/Profile\n |-/frontend (React, node_modules)\n |-/backend (Gemfile, Puma app-sever, Sinatra api)\n```\n\n\u003e We can run separatly `yarn start` (React) and `bundle exec Puma` (the app-server that serves the Sinatra/Ruby api).\n\nWe will run both processes at once with **overmind**. To run these two processes from another folder than the standard one, we will create a **/bin** folder in the backend folder, and use the **-cwd** flag for `yarn`.\n\n### Binstubs\n\nTo run `bundler` from another direcory, create a **/bin** folder:\n\n```bash\n$\u003e bundle install --binstubs\n```\n\nThis creates a directory (defaults to ~/bin) and place any executables from the gem there. These executables run in Bundler's context. If used, you might add this directory to your environment's PATH variable. For instance, if the rails gem comes with a rails executable, this flag will create a bin/rails executable that ensures that all referred dependencies will be resolved using the bundled gems.\n\n### Overmind flags\n\n\u003chttps://github.com/DarthSim/overmind\u003e\n\n- to use, do `overmind start`\n- you can also specify the name of the Profile with the flag `-f Procfile`.\n- To start a single process, use `-l` flag\n- To specify the port for a specific process, do `-p $PORT` in the process\n- To run `yarn` from another directory, use `--cwd` flag\n\n```bash\n$\u003e overmind start -l backend\n```\n\nThe Profile used here is:\n\n```bash\n#Profile\nbackend: ./backend/bin/bundle exec ./backend/bin/puma -p 9292 -C ./backend/puma.rb\nfrontend: yarn --cwd ./frontend/ -p 3000 start\n```\n\nwith:\n\n```rb\n# app.rb\nconfigure do\n      redis_url = ENV[\"REDISTOGO_URL\"] || \"redis://localhost:6379\"\n      uri = URI.parse(redis_url)\n      $redis = Redis.new(host: uri.host, port: uri.port, password: \"secret\")\n   end\n#config.ru\nrequire './backend/app.rb'\n```\n\n## 2) Running the production build on Docker\n\nWe will run Nginx as reverse proxy to serve React's static built files and forward requests to the app-server Puma which serves the Sinatra backend, that communicates with Redis.\n\nWe will create 3 processes, **Redis**, **Nginx**, **Sinatra** and use `docker-compose` to create a network for containers to communicate.\n\nWe create a **Node** container that builds the React app. We then create an Nginx container that serves the copy of the static React files and forwards http request to the Puma app-server. This is done via a Dockerfile.\n\nWe create a backend container that runs the Ruby/Sinatra api. We create the `Dockerfile.sinatra`.\nWe create a Redis container with persistance on disk. We create a file `Dockerfile.redis` where we pass a `redis.conf` to set the password and save strategy.\n\nThe settings for Redis for Ruby are: `redis_url = \"redis://redis:6379`.\n\n```rb\n# app.rb\nconfigure do\n      redis_url = ENV[\"REDISTOGO_URL\"] || \"redis://redis:6379\"\n      uri = URI.parse(redis_url)\n      $redis = Redis.new(host: uri.host, port: uri.port, password: \"secret\")\n   end\n#config.ru\nrequire './app.rb'\n```\n\n## REDIS persistance in `redis.conf`\n\n- dir /data \u003c- volume on host\n- dbfilename dump.rdb \u003c- RDB\n- appendonly yes \u003c- AOF\n- appendfilename \"appendonly.aof\"\n\n\u003e Authentification\n\n```\n# redis.conf\nrequirepass secret\n\n# app.rb\nRedis.new(..., password: \"secret\")\n\n# docker-compose.yml\n- REDIS_PASSWORD=secret\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndrean%2Fsuperm-v4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndrean%2Fsuperm-v4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndrean%2Fsuperm-v4/lists"}