{"id":15986048,"url":"https://github.com/coderhs/chitraguptan","last_synced_at":"2025-04-04T21:26:17.782Z","repository":{"id":50295725,"uuid":"517936467","full_name":"coderhs/chitraguptan","owner":"coderhs","description":"A ruby gem/engine to manage variables and feature flags","archived":false,"fork":false,"pushed_at":"2022-08-16T23:14:02.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T06:13:07.838Z","etag":null,"topics":["admin-dashboard","feature-flags","gem","redis-client","ruby"],"latest_commit_sha":null,"homepage":"https://hsps.in","language":"Ruby","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/coderhs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-26T06:14:01.000Z","updated_at":"2022-07-26T06:31:57.000Z","dependencies_parsed_at":"2022-08-25T11:51:16.896Z","dependency_job_id":null,"html_url":"https://github.com/coderhs/chitraguptan","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/coderhs%2Fchitraguptan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Fchitraguptan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Fchitraguptan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Fchitraguptan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderhs","download_url":"https://codeload.github.com/coderhs/chitraguptan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247251017,"owners_count":20908445,"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":["admin-dashboard","feature-flags","gem","redis-client","ruby"],"created_at":"2024-10-08T02:42:19.337Z","updated_at":"2025-04-04T21:26:17.764Z","avatar_url":"https://github.com/coderhs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project Chitraguptan\n\n## Project Plan\n\nMeaning: Hindu god/divine figure who is assigned with the task of record keeping\n\nThis is an app to develop the dynamic variable manager for Rails.\n\nWe save some values as constant in a rails model\n\n``` rb\nclass RfidTag \u003c ActiveModel\n  def self.filter_weak_rssi\n    where('rssi \u003c 100')\n  end\nend\n```\n\nSimilarly we might code hard values at different parts of the app. To make this\nconfigurable we enter the values into the config file, env file, or store it in\na model in the DB.\n\nSo they can be used as:\n\n```rb\n  where('rssi \u003c ?', ENV['WEAK_RSSI'])\n  # or\n  where('rssi \u003c ?', Rails.configuration.custom_config.weak_rssi)\n  # or\n  where('rssi \u003c ?', RfidSetting.first.weak_rssi)\n```\n\nThe first two of the above, requires re-deploying our rails app, and committing or changing files.\nThe last one requires creating and maintaining an extra model. But it does allow\none to change the variables on the file.\n\nThe aim of this project is to reduce the burden of managing variables. It is especially useful in building simple feature toggles.\n\n```rb\n  where('rssi \u003c ?', Chitraguptan.get(\"week_rssi\", default: 100))\n```\n\nNow this variable will be set as `chitraguptan:week_rssi` in your redis database and also\nstored in your database inside the table: chitraguptan_variables. The table has 3 fields namely, id, key and value (int 32, varchar and jsonb). \n\n## Current ADMIN UI\n\n![image](https://user-images.githubusercontent.com/979321/180947183-cc861cb1-c38e-4179-86dc-35079e1145d8.png)\n\n## Installation\n\nDisclaimer: Currently this project is in active development.\n\nTo install this gem add the following to your Gemfile.\n\n```rb\ngem 'chitraguptan', github: 'coderhs/chitraguptan'\n```\n\nthen run `bundle install`\n\nfollowed by\n\n```sh\nbundle exec rails generate chitraguptan:install\n```\n\nThis will add an initializer file and admin url to your application routes.\n\nThe values you can control from initializer files are:\n```rb\nconfig.redis            = Redis.new # Provide connection string to your local or remote redis host\nconfig.prefix           = 'chitraguptan' # We use the prefix to namespace the variables inserted and managed by the gem.\nconfig.persist          = false # Persist flag will auto save all variables to your database, thus safeguarding it from a redis restart or crash\nconfig.do_not_auto_load = true  # Auto load the existing value in the DB to redis on boot\n```\n\nIf you are enabling the persist flag, you will need to add the migration to your rails app.\n\n```sh\nbundle exec rails generate chitraguptan:migrations\n```\n\n## Purpose of this repo\n\nBuild the whole feature inside this repo and then extract it to a gem\n\n## Things to do\n\n1. Connect to redis - https://github.com/coderhs/chitraguptan/labels/Done\n2. Configure to add prefix to the variables used - https://github.com/coderhs/chitraguptan/labels/Done\n3. Define api to set data, delete data and give default if data doesn't exist - https://github.com/coderhs/chitraguptan/labels/Done\n4. Load existing variables and set them in redis if they don't exist (during boot) - https://github.com/coderhs/chitraguptan/labels/Done\n5. Admin UI to CRUD manage the variables - https://github.com/coderhs/chitraguptan/labels/Done\n6. Extract the code to its own gem - https://github.com/coderhs/chitraguptan/labels/Done\n7. Add to admin UI - Delete key\n8. Create gem install scripts - https://github.com/coderhs/chitraguptan/labels/Done\n   1. Create migration to persist data - https://github.com/coderhs/chitraguptan/labels/Done\n   2. Create initializer file -  https://github.com/coderhs/chitraguptan/labels/Done\n   3. Add engine route to rails app routes\n9. Move get/set/delete/update to its own service classes\n10. Write test for whole code\n11. Control following settings from initializer\n     1. Redis URL\n     2. Auto persistance of variables - https://github.com/coderhs/chitraguptan/labels/Done\n     3. Auto load for variables during boot - https://github.com/coderhs/chitraguptan/labels/Done\n     4. Disable persistance in DB - https://github.com/coderhs/chitraguptan/labels/Done\n12. Write more API documentation\n13. Release the gem to rubygems\n\n## Nice to have\n\n1. Load the list of variables from file (to use without the DB)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderhs%2Fchitraguptan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderhs%2Fchitraguptan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderhs%2Fchitraguptan/lists"}