{"id":16542649,"url":"https://github.com/ycd/leaderboard","last_synced_at":"2025-03-04T06:46:01.484Z","repository":{"id":65298656,"uuid":"363247842","full_name":"ycd/leaderboard","owner":"ycd","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-15T18:14:20.000Z","size":197,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T03:49:55.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/ycd.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":"2021-04-30T20:08:58.000Z","updated_at":"2021-05-03T23:26:37.000Z","dependencies_parsed_at":"2024-11-14T16:39:08.713Z","dependency_job_id":"bd843235-eb97-4c6f-b99b-6316bd1bdb6d","html_url":"https://github.com/ycd/leaderboard","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/ycd%2Fleaderboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fleaderboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fleaderboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ycd%2Fleaderboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ycd","download_url":"https://codeload.github.com/ycd/leaderboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241801195,"owners_count":20022383,"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-11T18:58:12.274Z","updated_at":"2025-03-04T06:46:01.463Z","avatar_url":"https://github.com/ycd.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\n# Getting Started\n\n# Achitecture\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"assets/architecture.png\" width=700 height=400\u003e\n\n\u003c/div\u003e\n\n\n# Development\n\n## Running locally\n\n### Prerequisites\n\n1. GNU Make \u003e=3.5\n1. Docker Engine \u003e= 20\n1. Docker Compose\n\n#### Build image\n\n```bash\nmake build\n```\n\n#### Run locally \n\n```bash\nmake run-dev\n```\n\n#### Testing\n\n1. Start the test environment with the following command which will provision the required components for your application.\n\n```bash\nmake run-test-env\n```\n\n2. Run the tests\n\n```bash\nmake run-tests\n```\n\n#### Pushing image to container registry\n\n```bash\nmake push-image\n```\n\n# Deployment\n\n## Provisioning a new Kubernetes Cluster with Terraform \n\n1. Download [Terraform](https://www.terraform.io/downloads.html)\n1. Initialize terraform with `terraform init`\n1. If you haven't got your credentials yet, get them with `gcloud auth application-default login`\n1. Provision the cluster setup with `terraform apply -auto-approve`\n1. Get the kubeconfig file by running the following command \n\n```bash\ngcloud container clusters get-credentials $( echo var.name | terraform console ) \\\n    --zone $( echo var.location | terraform console )   \\\n    --project $( echo var.project | terraform console )\n``` \n\n\n6. After a few minutes of provisioning your cluster must be ready, test it with `kubectl cluster-info`.\n\n## Deploy PostgreSQL on Kubernetes\n\n1. Create Persistent volume. \n\n```bash\nkubectl apply -f psql-persistent-vol.yaml\n```\n\n2. Apply The PostgreSQL deployment.\n\n```bash\nkubectl apply -f psql-service.yaml\n```\n\n3. Apply the PostgreSQL service. \n\n```bash\nkubectl apply -f psql-service.yaml\n```\n\n## Deploying the services\n\n1. Create Deployment, ConfigMap and Service for Redis\n\n```bash\nkubectl apply -f redis-deployment-service.yaml\n```\n\n2. Create Deployment for API service.\n\n```bash\nkubectl apply -f api-deployment.yaml\n```\n\n3. Apply and expose the API service through a load balancer.\n\n```bash\nkubectl apply -f api-service.yaml\n```\n\nThat's it.\n\n### Creating mock data\n\nYou can create mock data for testing with the following command.\n\n```bash\nmake insert-mock-data BASE_URL=http://HOST:PORT\n``` \n\n# API Reference\n\n### Get the global leaderboard\n\n```http\n  GET /leaderboard\n```\n\n\n#### Response \n\n```json\n{\n  \"data\": [\n    {\n      \"rank\": 1,\n      \"points\": 99,\n      \"display_name\": \"test_451\",\n      \"country\": \"ug\"\n    },\n    {\n      \"rank\": 2,\n      \"points\": 98,\n      \"display_name\": \"test_376\",\n      \"country\": \"fr\"\n    }\n  ],\n  \"error\": null,\n  \"success\": true\n}\n```\n\n\n### Get leaderboard of the specific country\n\n```http\n  GET /leaderboard/:country_code\n```\n\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `country_code`      | `string` | **Required**. ISO 639-1 Code of the Country |\n\n#### Response\n\n```json\n{\n  \"data\": [\n    {\n      \"rank\": 1,\n      \"points\": 99,\n      \"display_name\": \"test_443\",\n      \"country\": \"fr\"\n    },\n    {\n      \"rank\": 2,\n      \"points\": 98,\n      \"display_name\": \"test_376\",\n      \"country\": \"fr\"\n    }\n  ],\n  \"error\": null,\n  \"success\": true\n}\n```\n\n### Submit Score\n\n```http\n  GET /score/submit\n```\n\n#### Request \n\n```json\n{\n  \"score_worth\": 1234.6,\n  \"user_id\": \"f1607032-aaf3-41df-9d61-84d06b97a322\"\n}\n```\n\n#### Response\n\n```json\n{\n  \"data\": {\n    \"score_worth\": 1234.6,\n    \"user_id\": \"f1607032-aaf3-41df-9d61-84d06b97a322\",\n    \"timestamp\": 1619972382\n  },\n  \"error\": \"\",\n  \"success\": true\n}\n```\n\n### Create new user\n\n```http\n  GET /user/create\n```\n\n\n#### Request\n\n```json\n{\n  \"display_name\": \"ycd_123\",\n  \"country\": \"us\"\n}\n```\n\n#### Response\n\n```json\n{\n  \"data\": {\n    \"user_id\": \"0db88bec-6b99-4972-b72e-c35c9ee38cf9\",\n    \"display_name\": \"ycd_123\",\n    \"points\": 0,\n    \"rank\": 100\n  },\n  \"error\": \"\",\n  \"success\": true\n}\n```\n\n\n### Get user profile\n\n```http\n  GET /user/profile/:guid\n```\n\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `guid`      | `string` | **Required**. GUID(UUID) |\n\n#### Response\n\n```json\n{\n  \"data\": {\n    \"user_id\": \"64f6faea-db27-415f-a7bc-6b8cd8e893d1\",\n    \"display_name\": \"yaguasdf\",\n    \"points\": 0,\n    \"rank\": 100\n  },\n  \"error\": \"\",\n  \"success\": true\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fycd%2Fleaderboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fycd%2Fleaderboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fycd%2Fleaderboard/lists"}