{"id":21672574,"url":"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs","last_synced_at":"2025-03-20T08:27:14.897Z","repository":{"id":50244896,"uuid":"336104347","full_name":"redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs","owner":"redis-developer","description":"This repo shows a basic analytics dashboard app that uses Redis Bitmap written in NodeJS (JavaScript)","archived":false,"fork":false,"pushed_at":"2023-06-27T07:09:32.000Z","size":4576,"stargazers_count":11,"open_issues_count":1,"forks_count":9,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-01-25T09:27:39.171Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vue","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/redis-developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-04T22:54:31.000Z","updated_at":"2024-11-06T17:56:41.000Z","dependencies_parsed_at":"2025-01-25T09:36:02.998Z","dependency_job_id":null,"html_url":"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs","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/redis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redis-developer","download_url":"https://codeload.github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244576974,"owners_count":20475221,"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":[],"created_at":"2024-11-25T13:30:10.608Z","updated_at":"2025-03-20T08:27:14.876Z","avatar_url":"https://github.com/redis-developer.png","language":"Vue","readme":"# Redis Analytics Bitmaps demo\n\nShowcases how to implement analytics system using Redis Bitmaps (and other data types) in NodeJS\n\n\u003ca href=\"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/main/preview.png?raw=true\"\u003e\u003cimg src=\"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/main/preview-min.png?raw=true\" width=\"100%\" height=\"auto\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/main/preview-2.png?raw=true\"\u003e\u003cimg src=\"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/main/preview-2-min.png?raw=true\" width=\"50%\" height=\"auto\"\u003e\u003c/a\u003e\u003ca href=\"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/main/preview-3.png?raw=true\"\u003e\u003cimg src=\"https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/main/preview-3-min.png?raw=true\" width=\"50%\" height=\"auto\"\u003e\u003c/a\u003e\n\n# Overview video\n\nHere's a short video that explains the project and how it uses Redis:\n\n[![Watch the video on YouTube](https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs/blob/cb8c2178a6c5a019c42aa91739ad9bfdbb2d558c/docs/YTThumbnail.png)](https://www.youtube.com/watch?v=Ugym4yUeIhA)\n\n## How it works\n### How the data is stored:\n\n* The event data is stored in various keys and various data types.\n    * For each of time spans:\n        * year: like 2021\n        * month: like 2021-03 (means March of 2021)\n        * day: like 2021-03-03 (means 3rd March of 2021)\n        * weekOfMonth: like 2021-03/4 (means 4th week of March 2021)\n        * anytime\n        \n    * and for each of scopes:\n        * source\n        * action\n        * source + action\n        * action + page\n        * userId + action\n        * global\n        \n    * and for each of data types (types):\n        * count (Integer stored as String)\n        * bitmap\n        * set\n        \nIs generated key like: `rab:{type}[:custom:{customName}][:user:{userId}][:source:{source}][:action:{action}][:page:{page}]:timeSpan:{timeSpan}`, where values in `[]` are optional.\n* For each generated key like `rab:count:*`, data is stored like: `INCR {key}`\n    * E.g `INCR rab:count:action:addToCart:timeSpan:2015-12/3`\n* For each generated key like: `rab:set:*`, data is stored like: `SADD {key} {userId}`\n    * E.g `SADD rab:set:action:addToCart:timeSpan:2015-12/3 8`\n* For each generated key like `rab:bitmap:*`, data is stored like: `SETBIT {key} {userId} 1`.\n    * E.g `SETBIT rab:bitmap:action:addToCart:timeSpan:2015-12/3 8 1`\n* Cohort data:\n    * We store users who register and then bought some products (action order matters).\n    * For each buy action in December we check if user performed register action before (register counter must be greater than zero).\n    * If so, we set user bit to 1 like: `SETBIT rab:bitmap:custom:cohort-buy:timeSpan:{timeSpan} {userId} 1`\n    * E.g User Id 2 bought 2 products on 2015-12-17. He won't be stored.\n    * E.g User Id 10 bought 1 product on 2015-12-17 and registered on 2015-12-16. He will be stored like: `SETBIT rab:bitmap:custom:cohort-buy:timeSpan:2015-12 10 1`.\n    * We assume that user cannot buy without register.\n* Retention data:\n    * Retention means users who bought on two different dates\n    * For each buy action we check if user bought more products anytime than bought on particular day (current purchase not included).\n    * If so, we add user id to set like: `SADD rab:set:custom:retention-buy:timeSpan:{timeSpan} {userId}`\n    * E.g User Id 5 bought 3 products on 2015-12-15. His retention won't be stored (products bought on particular day: 2, products bought anytime: 0).\n    * E.g User Id 3 bought 1 product on 2015-12-15 and before - 1 product on 2015-12-13. His retention will be stored (products bought on particular day: 0, products bought anytime: 1) like: `SADD rab:set:custom:retention-buy:timeSpan:2015-12 3`.\n\n### How the data is accessed:\n\n* Total Traffic: \n    * December: `BITCOUNT rab:bitmap:custom:global:timeSpan:2015-12`\n    * X week of December: `BITCOUNT rab:bitmap:custom:global:timeSpan:2015-12/{X}`\n        * E.g `BITCOUNT rab:bitmap:custom:global:timeSpan:2015-12/3`\n\n* Traffic per Page ({page} is one of: homepage, product1, product2, product3):\n    * December: `BITCOUNT rab:bitmap:action:visit:page:{page}:timeSpan:2015-12`\n        * E.g `BITCOUNT rab:bitmap:action:visit:page:homepage:timeSpan:2015-12`\n    * X week of December: `BITCOUNT rab:bitmap:action:visit:page:{page}:timeSpan:2015-12/{X}`\n        * E.g `BITCOUNT rab:bitmap:action:visit:page:product1:timeSpan:2015-12/2`\n\n* Traffic per Source ({source} is one of: google, Facebook, email, direct, referral, none):\n    * December: `BITCOUNT rab:bitmap:source:{source}:timeSpan:2015-12`\n        * E.g `BITCOUNT rab:bitmap:source:referral:timeSpan:2015-12`\n    * X week of December: `BITCOUNT rab:bitmap:source:{source}:timeSpan:2015-12/{X}`\n        * E.g `BITCOUNT rab:bitmap:source:google:timeSpan:2015-12/1`\n\n* Trend traffic ({page} is one of: homepage, product1, product2, product3):\n    * December: from `BITCOUNT rab:bitmap:action:visit:{page}:timeSpan:2015-12-01` to `BITCOUNT rab:bitmap:action:visit:{page}:timeSpan:2015-12-31`\n    * 1 Week of December: Similar as above, but from 2015-12-01 to 2015-12-07\n    * 2 Week of December: Similar as above, but from 2015-12-08 to 2015-12-14\n    * 3 Week of December: Similar as above, but from 2015-12-15 to 2015-12-21\n    * 4 Week of December: Similar as above, but from 2015-12-22 to 2015-12-28\n    * 5 Week of December: Similar as above, but from 2015-12-29 to 2015-12-31\n        * E.g `BITCOUNT rab:bitmap:action:visit:homepage:timeSpan:2015-12-29` =\u003e `BITCOUNT rab:bitmap:action:visit:homepage:timeSpan:2015-12-30` =\u003e `BITCOUNT rab:bitmap:action:visit:homepage:timeSpan:2015-12-31`\n\n* Total products bought:\n    * December: `GET rab:count:action:buy:timeSpan:2015-12`\n    * X week of December: `GET rab:count:action:buy:timeSpan:2015-12/{X}`\n        * E.g `GET rab:count:action:buy:timeSpan:2015-12/1`\n\n* Total products added to cart:\n    * December: `GET rab:count:action:addToCart:timeSpan:2015-12`\n    * X week of December: `GET rab:count:action:addToCart:timeSpan:2015-12/{X}`\n        * E.g `GET rab:count:action:addToCart:timeSpan:2015-12/1`\n\n* Shares of products bought ({productPage} is on of product1, product2, product3):\n    * December: `GET rab:count:action:buy:page:{productPage}:timeSpan:2015-12`\n        * E.g `GET rab:count:action:buy:page:product3:timeSpan:2015-12`\n    * X week of December: `GET rab:count:action:buy:page:{productPage}:timeSpan:2015-12/{X}`\n        * E.g `GET rab:count:action:buy:page:product1:timeSpan:2015-12/2`\n\n* Customer and Cohort Analysis:\n    * People who registered: `BITCOUNT rab:bitmap:action:register:timeSpan:2015-12`\n    * People who register then bought (order matters): `BITCOUNT rab:bitmap:custom:cohort-buy:timeSpan:2015-12`\n    * Dropoff: (People who register then bought / People who register) * 100 [%]\n\n* Customers who bought only specified product ({productPage} is one of: product1, product2, product3): `SMEMBERS rab:set:action:buy:page:{productPage}:timeSpan:2015-12`\n    * E.g `SMEMBERS rab:set:action:buy:page:product2:timeSpan:2015-12`\n* Customers who bought Product1 and Product2: `SINTER rab:set:action:buy:page:product1:timeSpan:anytime rab:set:action:buy:page:product2:timeSpan:anytime`\n* Customer Retention (customers who bought on the different dates): `SMEMBERS rab:set:custom:retention-buy:timeSpan:anytime`\n\n## Hot to run it locally?\n\n### Prerequisites\n\n- Node - v12.19.0\n- NPM - v6.14.8\n- Docker - v19.03.13 (optional)\n\n### Local installation\n\nGo to `/server` folder (`cd ./server`) and then:\n\n```\n# copy file and set proper data inside\ncp .env.example .env\n\n# install dependencies\nnpm install\n\n# run docker compose or install redis manually\ndocker network create global\ndocker-compose up -d --build\n\n# Run dev server\nnpm run dev\n```\n\nGo to `/client` folder (`cd ./client`) and then:\n\n```\n# copy file and set proper data inside\ncp .env.example .env\n\n# install dependencies\nnpm install\n\n# run development mode\nnpm run serve\n```\n\n## Deployment\n\nTo make deploys work, you need to create free account in https://redislabs.com/try-free/\n\n### Google Cloud Run\n\n[![Run on Google\nCloud](https://deploy.cloud.run/button.svg)](https://deploy.cloud.run/?git_repo=https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs.git\u0026revision=feature/deploy-buttons)\n\n### Heroku\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)\n\n### Vercel\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs\u0026env=REDIS_ENDPOINT_URI,REDIS_PASSWORD)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis-developer%2Fbasic-analytics-dashboard-redis-bitmaps-nodejs/lists"}