{"id":21164970,"url":"https://github.com/abhishekshree/iitk-coin","last_synced_at":"2025-06-13T17:32:37.149Z","repository":{"id":65253235,"uuid":"371770560","full_name":"abhishekshree/iitk-coin","owner":"abhishekshree","description":"Summer Project 2021, Programming Club","archived":false,"fork":false,"pushed_at":"2021-07-26T08:09:00.000Z","size":8198,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T16:43:45.573Z","etag":null,"topics":["backend","golang","jwt","sqlite3"],"latest_commit_sha":null,"homepage":"https://iitk-coin-docs.netlify.app/","language":"Go","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/abhishekshree.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}},"created_at":"2021-05-28T17:14:27.000Z","updated_at":"2022-03-16T10:22:40.000Z","dependencies_parsed_at":"2023-01-16T15:00:23.667Z","dependency_job_id":null,"html_url":"https://github.com/abhishekshree/iitk-coin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abhishekshree/iitk-coin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhishekshree%2Fiitk-coin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhishekshree%2Fiitk-coin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhishekshree%2Fiitk-coin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhishekshree%2Fiitk-coin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhishekshree","download_url":"https://codeload.github.com/abhishekshree/iitk-coin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhishekshree%2Fiitk-coin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259688365,"owners_count":22896392,"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":["backend","golang","jwt","sqlite3"],"created_at":"2024-11-20T14:15:45.581Z","updated_at":"2025-06-13T17:32:37.127Z","avatar_url":"https://github.com/abhishekshree.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IITK Coin\n\n[![](https://img.shields.io/docker/cloud/build/abhishekshree/iitk-coin?style=flat-square)](https://hub.docker.com/r/abhishekshree/iitk-coin)\n[![Netlify](https://img.shields.io/netlify/3fccc76a-3ea3-4141-9cf2-e152c5f65be8?style=flat-square)](https://iitk-coin-docs.netlify.app/)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/abhishekshree/iitk-coin?style=flat-square)\n![GitHub repo size](https://img.shields.io/github/repo-size/abhishekshree/iitk-coin?style=flat-square)\n\nThis repository contains the backend for IITK Coin, which is a centralized pseudo-coin system in golang (fiber) for use in IITK Campus.\n\n## \u003cu\u003eIndex\u003c/u\u003e\n\n- [Directory Structure](#directory-structure)\n- [Database](#database-sqlite)\n- [Details of the endpoints](#details-of-the-endpoints)\n\n---\n\n## \u003cu\u003eDirectory Structure\u003c/u\u003e\n\u003cbr /\u003e\n\n```\n├── config\n│   └── config.go\n├── db\n│   ├── admin.go\n│   ├── db.go\n│   ├── records.go\n│   ├── redeem.go\n│   └── transactions.go\n├── Dockerfile\n├── go.mod\n├── go.sum\n├── iitk-coin\n├── main.go\n├── middleware\n│   ├── hash.go\n│   └── jwt.go\n├── README.md\n├── routes\n│   ├── redeem.go\n│   ├── routes.go\n│   └── transactions.go\n└── Users.db\n\n4 directories, 19 files\n```\n\n---\n\n## \u003cu\u003eDatabase: `SQLite`\u003c/u\u003e\nThe database currently has three tables, they are:\n\u003cbr /\u003e\n\n- User\n\n```sql\nCREATE TABLE User (\n    rollno TEXT,\n    name TEXT,\n    password TEXT,\n    coins REAL,\n    Admin BOOLEAN DEFAULT 0,\n    PRIMARY KEY(rollno)\n);\n```\n\n- Transactions\n\n```sql\nCREATE TABLE Transactions (\n    id INTEGER PRIMARY KEY,\n    from_roll TEXT,\n    to_roll TEXT,\n    type TEXT,\n    timestamp TEXT,\n    amount_before_tax REAL,\n    tax REAL\n);\n```\n\n- RedeemRequests\n\n```sql\nCREATE TABLE RedeemRequests (\n    id INTEGER PRIMARY KEY,\n    rollno TEXT,\n    item TEXT,\n    timestamp TEXT,\n    status INTEGER DEFAULT 0\n);\n\n-- for status: 0 -\u003e Pending, 1 -\u003e Redeemed, 2 -\u003e Declined\n```\n\n---\n\n## \u003cu\u003eDetails of the endpoints:\u003c/u\u003e\nCan also be viewed [here.](https://iitk-coin-docs.netlify.app/)\n\u003cbr /\u003e\n\n### Signup\n\n```\nurl : /signup\nmethod : POST\n\nRequest Body: {\n    \"Roll\" : \"\",\n    \"Name\" : \"\",\n    \"Password\" : \"\"\n}\n\nResponse : {\n            \"success\": true/false\n}\n\n```\n\n### Login\n\n```\nurl : /login\nmethod : POST\n\nRequest Body: {\n    \"Roll\" : \"\",\n    \"Password\" : \"\"\n}\n\nResponse : {\n            \"token\": JWT Token\n            \"status\": true/false\n}\nNOTE: Token is returned only after a successful login. Also it expires in 3 days.\n```\n\n### Secretpage\n\n```\nurl : /secretpage\nmethod : GET\n\nResponse : \"This is a very secret string.\"\nNOTE: Can access only after a successful JWT verification and if the user Exists.\n```\n\n### Get Coins\n\n```\nurl : /getCoins\nmethod : GET\n\nRequest Body: {\n    \"rollno\" : \"\",\n}\n\nResponse : {\n            \"rollno\": \u003cRoll Number\u003e,\n            \"coins\": \u003cCoins currently held by user\u003e,\n}\n```\n\n### Award Coins\n\n```\nurl : /awardCoins\nmethod : POST (JWT Required)\nRequest Body: {\n    \"rollno\" : \"\",\n    \"amount\": \u003cfloat\u003e\n}\n\nResponse : {\n            \"message\": \"Coins Awarded.\"\n}\nNote: Check from JWT if the amount coming from user X is actually after when user X logs in and is an admin.\n```\n\n### Transfer Coins\n\n```\nurl : /transferCoins\nmethod : POST (JWT Required)\n\nRequest Body: {\n    \"from\" : \"\",\n    \"to\": \"190028\",\n    \"amount\": \u003cfloat\u003e\n}\n\nResponse : {\n            \"message\": \"Coins Transferred.\",\n            \"amount\":  \u003cAmount Transferred after tax deduction\u003e,\n}\nNote: Check from JWT if the amount coming from user X is actually after when user X logs in.\n```\n\n### Sidenote:\n\nAlso defined some functions to give or take admin privileges in the db package.\n\n```go\n\nfunc MakeAdmin(rollno string) bool\nfunc RemoveAdmin(rollno string) bool\nfunc IsAdmin(rollno string) bool\n\n```\n\n### Get a list of Redeemable items and price\n\n```\nurl : /getRedeemList\nmethod : GET\n\nRequest Body: \u003cNone\u003e\n\nResponse : \u003cRedeemable items\u003e\n```\n\n### Create a Redeem Request\n\n\n```\nurl : /redeemRequest\n\nmethod : POST\n\nRequest Body: {\n    \"item\": \"B\"\n}\n\nResponse : {\n    \"message\": \u003cMessage\u003e\n}\n\nNote: The Roll number is obtained from active JWT\n```\n\n### Accept a Redeem Request\n\n\n```\nurl : /acceptRedeemRequest\n\nmethod : POST\n\nRequest Body: {\n    \"id\":6\n}\n\nResponse : {\n    \"message\": \u003cMessage\u003e\n}\n\nNote: This route is ADMIN ONLY.\n```\n\n### Reject a Redeem Request\n\n\n```\nurl : /rejectRedeemRequest\n\nmethod : POST\n\nRequest Body: {\n    \"id\":6\n}\n\nResponse : {\n    \"message\": \u003cMessage\u003e\n}\n\nNote: This route is ADMIN ONLY. Also, a request which was accepted earlier can be rejected too, in that case the coins are lost (like in other coin based systems).\n```\n\n### Reject all the pending requests from a user (in case someone spams a lot of requests)\n\n```\nurl : /rejectPendingRequests\n\nmethod : POST\n\nRequest Body: {\n    \"roll\":\"190028\"\n}\n\nResponse : {\n    \"message\": \u003cMessage\u003e\n}\n\nNote: This route is ADMIN ONLY.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhishekshree%2Fiitk-coin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhishekshree%2Fiitk-coin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhishekshree%2Fiitk-coin/lists"}