{"id":17537525,"url":"https://github.com/peterbecich/narrativedemo","last_synced_at":"2025-08-09T14:16:35.472Z","repository":{"id":84146564,"uuid":"117480413","full_name":"peterbecich/NarrativeDemo","owner":"peterbecich","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-17T01:26:21.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-09T01:21:04.119Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/peterbecich.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":"2018-01-15T00:57:57.000Z","updated_at":"2018-01-15T00:58:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"e89f57f3-1a35-475d-acdc-c73843052d55","html_url":"https://github.com/peterbecich/NarrativeDemo","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/peterbecich%2FNarrativeDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterbecich%2FNarrativeDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterbecich%2FNarrativeDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterbecich%2FNarrativeDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterbecich","download_url":"https://codeload.github.com/peterbecich/NarrativeDemo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246135739,"owners_count":20729056,"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-10-20T20:42:07.108Z","updated_at":"2025-03-29T03:45:57.368Z","avatar_url":"https://github.com/peterbecich.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/peterbecich/NarrativeDemo.svg?branch=master)](https://travis-ci.org/peterbecich/NarrativeDemo)\n\nCues taken from [peterbecich/BannoDemo](https://github.com/peterbecich/BannoDemo) and [peterbecich/stock-ops](https://github.com/peterbecich/stock-ops)\n\n-----------------------\n\n# Quick Start\n\nDocker Compose is required.\n\n1. Create a file `NarrativeDemo/ops/server/.env`.  Docker Compose will read this file for its environmental variables\n1. Copy this template into `.env`.  Make up a password.  Both the server and client will access this environmental variable:\n\n```\nPOSTGRES_PASSWORD=\n```\n4. Proceed with either a pre-built Docker Image, or build the image from source\n\n## Start from Pre-built Docker Image\n\n1. Pull the Docker image from Docker Hub: \n   [peterbecich/narrativedemo](https://hub.docker.com/r/peterbecich/narrativedemo/)\n\n1. Proceed to start the Compose application\n\n## (or) Build from Source\n\nSBT is required.\n\n1. Start SBT in `NarrativeDemo/`\n1. Enter the `server` sub-project\n   ```\n   sbt:narrativedemo\u003e project backend\n   [info] Set current project to narrativedemo (in build file:./NarrativeDemo/)\n   ```\n1. Run `docker` in SBT to produce the Docker image `peterbecich/narrativedemo:latest`\n   ```\n   sbt:narrativedemo\u003e docker\n   [info] Including from cache: cats-effect_2.12-0.8.jar\n   .\n   .\n   .\n   [info] Successfully built d467a3dfffeb\n   [info] Tagging image d467a3dfffeb with name: peterbecich/narrativedemo:latest\n   [success] Total time: 4 s, completed Jan 16, 2018 4:45:11 PM \n   ```\n1. Exit SBT\n1. Proceed to start the Compose application\n\n## Start Docker Compose\n\n1. Change directory to `NarrativeDemo/ops/server`\n1. Run `docker-compose up` to start the demonstration and log to the terminal, or `docker-compose up -d` to start the demonstration and detach\n\n1. See the documentation of REST endpoints\n\n1. If detached, run `docker-compose down` to stop the Compose application\n\n\n-----------------------\n\n# Endpoints\n\n* Create user\n  ```POST http://localhost:80/user```\n  ``` \n  {\n  \"userId\": \"97daea7a-4f58-4d15-a540-7c967c9df55b\",\n  \"createdAt\": \"2018-01-17T01:05:46.988\"\n  }\n  // POST http://localhost:80/user\n  // HTTP/1.1 200 OK\n  ```\n  \n* Retrieve user\n\n  ```GET http://localhost:80/user?userId=97daea7a-4f58-4d15-a540-7c967c9df55b```\n  \n  ```\n  {\n  \"userId\": \"97daea7a-4f58-4d15-a540-7c967c9df55b\",\n  \"createdAt\": \"2018-01-17T01:05:46.988\"\n  }\n  // GET http://localhost:80/user?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\n  // HTTP/1.1 200 OK\n  ```\n* Register \"click\" with user at current UTC time\n\n  ```POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=click```\n  \n  ```\n  // POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=click\n  // HTTP/1.1 204 No Content\n  ```\n* Register \"click\" with user at given UTC epoch milliseconds\n\n  ```POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=click\u0026timestamp=1516151445306```\n  \n  ```\n  // POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=click\u0026timestamp=1516151445306\n  // HTTP/1.1 204 No Content\n  ```\n\n* Register \"impression\" with user at current UTC time\n\n  ```POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=impression```\n  \n  ```\n  // POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=impression\n  // HTTP/1.1 204 No Content\n  ```\n\n* Register \"impression\" with user at given UTC epoch milliseconds\n\n  ```POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=impression\u0026timestamp=1516151445306```\n  \n  ```\n  // POST http://localhost:80/analytics?userId=97daea7a-4f58-4d15-a540-7c967c9df55b\u0026event=impression\u0026timestamp=1516151445306\n  // HTTP/1.1 204 No Content\n  ```\n  \n* Retrieve number of clicks, impressions, and new users created in the current hour\n\n  ```GET http://localhost:80/analytics```\n  \n  ```\n  {\n\t  \"hour\": \"2018-01-17T01:00\",\n\t  \"usersCreated\": 3,\n\t  \"clicks\": 1,\n\t  \"impressions\": 1\n  }\n  // GET http://localhost:80/analytics\n  // HTTP/1.1 200 OK\n  ```\n\n* Retrieve number of clicks, impressions, and new users created in the hour of the given UTC epoch milliseconds\n\n  ```GET http://localhost:80/analytics?timestamp=1516150000000```\n  \n  ```\n  {\n  \"hour\": \"2018-01-17T00:00\",\n  \"usersCreated\": 4,\n  \"clicks\": 1,\n  \"impressions\": 2\n  }\n  // GET http://localhost:80/analytics?timestamp=1516150000000\n  // HTTP/1.1 200 OK\n  ```\n\n\n\n\n\n\n\n  \n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterbecich%2Fnarrativedemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterbecich%2Fnarrativedemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterbecich%2Fnarrativedemo/lists"}