{"id":21953588,"url":"https://github.com/zbhavyai/test-openhouseai","last_synced_at":"2026-04-12T18:22:07.257Z","repository":{"id":45745069,"uuid":"507451536","full_name":"zbhavyai/test-openhouseai","owner":"zbhavyai","description":"Assessment for OpenHouse.ai","archived":false,"fork":false,"pushed_at":"2022-07-15T17:54:36.000Z","size":179,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T22:46:16.412Z","etag":null,"topics":["hibernate","panache-entity","postgres","quarkus","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Java","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/zbhavyai.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}},"created_at":"2022-06-26T01:26:37.000Z","updated_at":"2022-07-15T17:54:55.000Z","dependencies_parsed_at":"2022-09-02T00:11:08.444Z","dependency_job_id":null,"html_url":"https://github.com/zbhavyai/test-openhouseai","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/zbhavyai%2Ftest-openhouseai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbhavyai%2Ftest-openhouseai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbhavyai%2Ftest-openhouseai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbhavyai%2Ftest-openhouseai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zbhavyai","download_url":"https://codeload.github.com/zbhavyai/test-openhouseai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245001407,"owners_count":20545244,"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":["hibernate","panache-entity","postgres","quarkus","rest-api"],"created_at":"2024-11-29T07:10:34.557Z","updated_at":"2026-04-12T18:22:02.208Z","avatar_url":"https://github.com/zbhavyai.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenHouse.ai Assessment\n\nBackend Assessment - retrieving logs\n\n## How to build and run\n\n1. The following are required to build and run this project:\n\n   - JDK version 11.0.11 or above\n   - Maven version 3.6.3 or above (if not using maven wrapper)\n   - PostgreSQL version 14.4 or above\n\n2. Start your postgres database server. Set the property `quarkus.datasource.password` with the password of the user `postgres` in the file [application.properties](src/main/resources/application.properties).\n\n3. Run the command from project's root to launch the application. This will launch the application on `8080` port.\n\n   ```bash\n   $ mvn clean quarkus:dev\n   ```\n\n4. The API can be accessed using the URL `http://localhost:8080/api`.\n\n## Storing Logs\n\n- Make a post call to `/api/store` with one log entry as payload. For example:\n\n  ```bash\n  $ curl -X POST -H \"Content-Type: application/json\" -d  '{\n  \"userId\": \"ABC123XYZ\",\n  \"sessionId\": \"XYZ456ABC\",\n  \"actions\": [\n     {\n        \"time\": \"2018-10-18T21:37:28-06:00\",\n        \"type\": \"CLICK\",\n        \"properties\": {\n        \"locationX\": 52,\n        \"locationY\": 11\n        }\n     },\n     {\n        \"time\": \"2018-10-18T21:37:30-06:00\",\n        \"type\": \"VIEW\",\n        \"properties\": {\n        \"viewedId\": \"FDJKLHSLD\"\n        }\n     },\n     {\n        \"time\": \"2018-10-18T21:37:30-06:00\",\n        \"type\": \"NAVIGATE\",\n        \"properties\": {\n        \"pageFrom\": \"communities\",\n        \"pageTo\": \"inventory\"\n        }\n     }\n  ]\n  }' 'http://localhost:8080/api/store'\n  ```\n\n- Make a post call to `/api/storeall` with array of log entries as payload. For example:\n\n  ```bash\n  $ curl -X POST -H \"Content-Type: application/json\" -d  '[\n  {\n     \"userId\": \"USER123\",\n     \"sessionId\": \"SESSION123\",\n     \"actions\": [\n        {\n        \"time\": \"2022-06-01T21:37:28-06:00\",\n        \"type\": \"CLICK\",\n        \"properties\": {\n           \"locationX\": 52,\n           \"locationY\": 11\n        }\n        },\n        {\n        \"time\": \"2022-06-01T21:37:30-06:00\",\n        \"type\": \"VIEW\",\n        \"properties\": {\n           \"viewedId\": \"QWERTY\"\n        }\n        },\n        {\n        \"time\": \"2022-06-01T21:37:30-06:00\",\n        \"type\": \"NAVIGATE\",\n        \"properties\": {\n           \"pageFrom\": \"page1\",\n           \"pageTo\": \"page2\"\n        }\n        }\n     ]\n  },\n  {\n     \"userId\": \"USER123\",\n     \"sessionId\": \"SESSION456\",\n     \"actions\": [\n        {\n        \"time\": \"2022-06-15T21:37:28-06:00\",\n        \"type\": \"CLICK\",\n        \"properties\": {\n           \"locationX\": 52,\n           \"locationY\": 11\n        }\n        },\n        {\n        \"time\": \"2022-06-15T21:37:30-06:00\",\n        \"type\": \"VIEW\",\n        \"properties\": {\n           \"viewedId\": \"ASDFG\"\n        }\n        },\n        {\n        \"time\": \"2022-06-15T21:37:30-06:00\",\n        \"type\": \"NAVIGATE\",\n        \"properties\": {\n           \"pageFrom\": \"page5\",\n           \"pageTo\": \"page3\"\n        }\n        }\n     ]\n  },\n  {\n     \"userId\": \"USER456\",\n     \"sessionId\": \"SESSION789\",\n     \"actions\": [\n        {\n        \"time\": \"2022-06-25T21:37:28-06:00\",\n        \"type\": \"CLICK\",\n        \"properties\": {\n           \"locationX\": 52,\n           \"locationY\": 11\n        }\n        },\n        {\n        \"time\": \"2022-06-25T21:37:30-06:00\",\n        \"type\": \"VIEW\",\n        \"properties\": {\n           \"viewedId\": \"ZXCVB\"\n        }\n        },\n        {\n        \"time\": \"2022-06-25T21:37:30-06:00\",\n        \"type\": \"NAVIGATE\",\n        \"properties\": {\n           \"pageFrom\": \"page8\",\n           \"pageTo\": \"page12\"\n        }\n        }\n     ]\n  }\n  ]' 'http://localhost:8080/api/storeall'\n  ```\n\n## Retrieving Logs\n\n- Make a get call to `/api/retrieve/all` to retrieve all logs. For example:\n\n  ```bash\n  $ curl -X GET 'http://localhost:8080/api/retrieve/all'\n  ```\n\n- Make a get call to `/api/retrieve` with parameters to retrieve logs based on user, time range, or log type. Any combination of these parameters can be used. For example:\n\n  ```bash\n  $ curl -X GET 'http://localhost:8080/api/retrieve?user=USER123\u0026type=NAVIGATE\u0026startTime=2022-06-01T21:37:30-06:00\u0026endTime=2022-06-25T21:37:28-06:00'\n  ```\n\n## Follow-up Questions\n\nTo make cloud scalable and to query millions of data points:\n\n- Add indexes to the database\n- Cache REST endpoints\n- Load balance the servers\n- Add unit tests with maximum coverage\n- Scale the database horizontally\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbhavyai%2Ftest-openhouseai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzbhavyai%2Ftest-openhouseai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbhavyai%2Ftest-openhouseai/lists"}