{"id":13492867,"url":"https://github.com/abhinavs/scoop","last_synced_at":"2025-04-23T22:06:17.366Z","repository":{"id":40244386,"uuid":"369304935","full_name":"abhinavs/scoop","owner":"abhinavs","description":"Scoop - a production-ready Sinatra boilerplate project using Corneal, ActiveRecord, Capistrano, Puma \u0026 Nginx","archived":false,"fork":false,"pushed_at":"2022-06-02T04:05:17.000Z","size":211,"stargazers_count":5,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T22:06:05.563Z","etag":null,"topics":["activerecord","api-boilerplate","capistrano","corneal","json-api","nginx","nginx-proxy","puma","ruby","sinatra","sinatra-boilerplate","sinatra-mvc","sinatra-skeleton"],"latest_commit_sha":null,"homepage":"https://www.abhinav.co/scoop","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhinavs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["abhinavs"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-05-20T18:36:52.000Z","updated_at":"2023-07-17T07:39:27.000Z","dependencies_parsed_at":"2022-09-04T01:00:49.064Z","dependency_job_id":null,"html_url":"https://github.com/abhinavs/scoop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinavs%2Fscoop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinavs%2Fscoop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinavs%2Fscoop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhinavs%2Fscoop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhinavs","download_url":"https://codeload.github.com/abhinavs/scoop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522298,"owners_count":21444511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["activerecord","api-boilerplate","capistrano","corneal","json-api","nginx","nginx-proxy","puma","ruby","sinatra","sinatra-boilerplate","sinatra-mvc","sinatra-skeleton"],"created_at":"2024-07-31T19:01:10.006Z","updated_at":"2025-04-23T22:06:16.275Z","avatar_url":"https://github.com/abhinavs.png","language":"HTML","funding_links":["https://github.com/sponsors/abhinavs"],"categories":["Boilerplate and Template"],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/abhinavs/scoop/master/public/images/scoop-header.png\" /\u003e\n\n# Scoop\n## a production-ready Sinatra boilerplate project using Corneal, ActiveRecord, Capistrano, Puma \u0026 Nginx\n\n[Sinatra](http://sinatrarb.com/) is a Ruby framework that helps you quickly create web applications, APIs and microservices. Its minimalism not only attracted a lot of developers, but it also inspired [Flask](https://flask.palletsprojects.com/en/2.0.x/) in Python and [Express](https://expressjs.com/) in Node.js\n\nIf you are developing microservices or web APIs, Sinatra is a great choice. However, bootstraping a Sinatra project that is optimized for development speed as well as is easy to deploy has become non trivial because \n1. Documentation is not easy to find (you mostly find Ruby on Rails specific tips)\n2. You need to write code to set up and connect DB, manage migrations etc.\n3. You need to create a right directory structure yourself and configure it accordingly\n4. You also miss a boot file that you can use with console and with custom rake tasks/scripts\n5. Setting up projects for deployment is tedious and error prone, with a lot of details to be filled in for Capistrano, Puma and Nginx.\n\n[Scoop](https://github.com/abhinavs/scoop) solves it by providing a good boilerplate that can be a starting point for your next project. It solves all the above mentioned problems and comes up with easy to edit configuration files that can help you correctly configure servers.\n\nScoop uses\n1. [Corneal](http://thebrianemory.github.io/corneal/) to make scaffolding models, controllers and views\n2. ActiveRecord as database ORM\n3. Capistrano for deployment\n4. Puma as app server\n5. Nginx as a proxy server\n\nIn addition, \n1. it is also JSON API ready with JSON, CORS and JSONP support already enabled,\n2. has a RoR like console, and\n3. comes up with example script and rake task that can be used to perform tasks that load the environment\n\nTry Sinatra \u0026 Scoop by forking [Scoop Repository](https://github.com/abhinavs/scoop/fork)\n\n### Installation \u0026 set up\nIt is very easy to start using scoop as a base for your project, you need to do the following on your development machine\n  - `git clone git@github.com:abhinavs/scoop.git APP_NAME` (replace `APP_NAME` with the name of your application, and replace `abhinavs` with your username if you have forked the repo)\n  - `rvm install 3.0.1`\n  - `gem install corneal`\n  - `gem install foreman`\n  - `gem install bundler`\n  - `cd scoop; bundle install`\n\nYou should also see `config/database.yml` file, and change name of the database. After that create the database \n`bundle exec rake db:create` \n\n### Development\nScoop used Corneal - it is a Sinatra app generator with useful utilities\n  - Generate a model: `corneal model NAME`\n  - Generate a controller: `corneal controller NAME`\n  - Generate a controller with no views: `corneal controller NAME --no-views`\n  - Generate a model with its associated views and controllers: `corneal scaffold NAME`\n\nScoop has JSON integration, and it is perfect for APIs. You can check out [pincodr's controller](https://github.com/abhinavs/pincodr/blob/master/app/controllers/pincodr_controller.rb) to see how to create APIs.\n\nYou can migrate data using the following command\n`bundle exec rake db:migrate`\n\n### Starting development server\nYou can start the development server using foreman\n`foreman start`\n\nIf you open the `http://localhost:9393` you should see a page getting rendered. You can also see `http://localhost:9393/status` for JSON response. Both of these routes are inside `app/controllers/example_controller.rb`\n\n### Console \u0026 Rake tasks\nFrom the application directory, do `bundle exec rake console` to open rails like console.\n\nIf you want to run create and run custom rake tasks, look at `Rakefile` and `bin/example_script.rb` for example\n\n### Deploying to production\nOur production set up uses\n  - rvm as ruby version manager\n  - We add puma as a `sysctl` service for easy management\n\n\u003ePlease note - if you need help in installing RVM and other essential packages, you can check out [this guide on Soopr](https://www.soopr.co/blog/deploy-ruby-on-rails-app-on-aws-graviton-part-1). If you need help in installing database, you can see \"Creating A Database\" section on [Go Rails' guide](https://gorails.com/deploy/ubuntu/20.04#database)\n\nAssuming you have created the database, and have installed `rvm`, install ruby on the **server(s)** by`rvm install 3.0.1`\n\n  - `rvm use --default 3.0.1` # You can also set it as default\n  - `gem install bundler` # Install bundler\n  - `sudo apt-get install nginx`\n\nTo start with first see `config/deploy.rb` and `config/deploy/production.rb` files, and change the following details\n  - Server IPs (`instances` in `config/deploy/production.rb`)\n  - Name of the application (`application`)\n  - Git repo URL (`repo_url`)\n  - Full path of the directory in which you want code to be deployed (`deploy_to`)\n  - Name of the deploying user (`deploy_user`) - this user will ssh into the system\n  - SSH key (`deploy_ssh_keys`)\n\n### Installing puma as a service\nModify `config/scoop-puma.example.service` \n  - Update `WorkingDirectory`, `ExecStart`, `ExecStop` with right working directory\n  - Update `SyslogIdentifier` with the name you want to give. I generally prefer to keep it as the name of the app and puma (scoop-puma) so that you can deploy multiple services.\n\nModify `config/deploy.rb` and replace `scoop-puma` with the name you have chosen.\n\n\nLogin to the **server(s)** and do the following\n  - Create the directory you have mentioned in your `deploy_to` variable\n  - Create an .prod-env in that directory (look at `config/prod-env`) file as an example. You need DATABASE_URL, SINATRA_ENV \u0026 RACK_ENV variables. Add any other credentials you have to use.\n\nFrom your local machine, deploy code by `cap production deploy`  - this step may not succeed, but ensure your code reaches the server.\n\nOn the **server(s)**, now we need to install puma as a service (I am copying it as scoop-puma.service, you should use the service name you have given in SyslogIdentifier)\n  - `cp config/scoop-puma.example.service /usr/lib/systemd/system/scoop-puma.service` \n  - `sudo systemctl daemon-reload`\n  - `sudo systemctl enable scoop-puma.service`\n\n\nFrom your local machine, deploy code once again using `cap production deploy` - ideally this time, deployment should succeed and puma server should come up.\n\nCheck if puma server is up or not by `sudo service scoop-puma status`\n\n### Config Nginx\nModify `scoop.nginx.conf' and change the following things\n  - Name of the server `server_name`\n  - Path wherever you see - this path is the server path, and will have `current` in it.\n\nOn the `server(s)` copy this config file to /etc/nginx/sites-enabled/scoop.conf and restart the nginx (`sudo service nginx restart`) \n\n(You might have to symlink scoop.conf file in sites-available directory too - you can do that by `sudo ln -s /etc/nginx/sites-enabled/scoop.conf /etc/nginx/sites-available/scoop.conf`)\n\n### Final Deploy\nDeploy it once again `cap production deploy` \n\n\ncontact: [abhinav][1] | [homepage][2]\n\n [1]: https://twitter.com/abhinav \"abhinav\"\n [2]: https://www.abhinav.co \"homepage\"\n\n## Other Projects\nIf you like Scoop, do check out my other projects\n*   [cookie](https://github.com/abhinavs/cookie) - a free landing website boilerplate using Jekyll and Tailwind CSS\n*   [moonwalk](https://github.com/abhinavs/moonwalk) - a fast and minimal blog theme with clean dark mode\n*   [soopr](https://www.soopr.co) - a tool that supports you in content marketing\n*   [apicagent](https://www.apicagent.com) - a FREE API that extracts device details from user-agent string\n*   [pincodr](https://pincodr.apiclabs.com) - a FREE API for Indian pincodes\n*   [humangous](https://www.humangous.co) - create public and private 'working with you' guides\n*   [blockr](https://www.abhinav.co/blockr) - a CLI tool to help you easily block and unblock websites\n*   [microrequests](https://www.abhinav.co/microrequests) - a Python library to help you consume microservice efficiently\n\n\n✨⚡You can read more about me on my [blog](https://www.abhinav.co/about/) or follow me on Twitter- [@abhinav](https://twitter.com/abhinav)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhinavs%2Fscoop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhinavs%2Fscoop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhinavs%2Fscoop/lists"}