{"id":21164927,"url":"https://github.com/1-harshit/iitk-coin","last_synced_at":"2025-07-09T16:33:42.728Z","repository":{"id":46640761,"uuid":"371891726","full_name":"1-Harshit/iitk-coin","owner":"1-Harshit","description":"Summer SnT Project 2021,  Programming Club","archived":false,"fork":false,"pushed_at":"2021-10-15T19:49:14.000Z","size":6183,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T03:06:45.621Z","etag":null,"topics":["backend","currency","go","golang","jwt","psuedo","server","sqlite3","summer-project","wallet"],"latest_commit_sha":null,"homepage":"https://1-harshit.github.io/iitk-coin/","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/1-Harshit.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-29T05:50:19.000Z","updated_at":"2023-04-15T11:37:12.000Z","dependencies_parsed_at":"2022-08-29T20:30:42.441Z","dependency_job_id":null,"html_url":"https://github.com/1-Harshit/iitk-coin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/1-Harshit/iitk-coin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1-Harshit%2Fiitk-coin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1-Harshit%2Fiitk-coin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1-Harshit%2Fiitk-coin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1-Harshit%2Fiitk-coin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1-Harshit","download_url":"https://codeload.github.com/1-Harshit/iitk-coin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1-Harshit%2Fiitk-coin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264494989,"owners_count":23617474,"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","currency","go","golang","jwt","psuedo","server","sqlite3","summer-project","wallet"],"created_at":"2024-11-20T14:14:45.585Z","updated_at":"2025-07-09T16:33:42.373Z","avatar_url":"https://github.com/1-Harshit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iitk-coin\n\n## **Summer Project 2021**\n\n## **SnT Project 2021, Programming Club**\n\nThis repository contains the backend code for the IITK Coin which is a reward based psuedo currency of IIT Kanpur.\n\n### Relevant Links\n\n- [Documentation of this repo](https://docs.google.com/document/d/16ZVl9a0_EFNMDupLyzjbsJd7bqx9oZ9GRznnxGYbLdI/edit?usp=sharing)\n- [Website](https://1-harshit.github.io/iitk-coin/)\n- [EndTerm Evaulation Folder](https://drive.google.com/drive/folders/1N93J_1ouR1AXctIZZkek0YMD5_LY0LVM?usp=sharing)\n- [Midterm Evaluation presentation](https://docs.google.com/presentation/d/1kriN-7A3v1RlXUDL5NETX3roJKRMJInptkWofIxY8dg/edit?usp=sharing)\n- [Midterm Documentation](https://docs.google.com/document/d/1bvOWH4k0U-l2pQ1jLWIDzOkJ2wbHNW4jJw7tMWkUV6o/edit?usp=sharing)\n\n## Table Of Content\n\n- [Development Environment](#development-environment)\n- [Directory Structure](#directory-structure)\n- [Usage](#usage)\n- [Endpoints](#endpoints)\n- [Models](#models)\n- [Settings](#settings)\n\n## Development Environment\n\n```bash\n- OS:           Ubuntu 20.04.2 LTS x86-64    # https://ubuntu.com/download\n- Kernel:       Linux 5.8.0-59-generic       # https://kernel.ubuntu.com/\n- go version:   go1.16.6 linux/amd64         # https://golang.org/dl/\n- text editor:  VSCode                       # https://code.visualstudio.com/download\n- terminal:     Zsh                          # https://ohmyz.sh/\n```\n\n## Directory Structure\n\n```\n.\n~go/src/github.com/1-Harshit/iitk-coin\n├── auth\n│   └── auth.go\n├── config\n│   ├── config.go\n│   ├── email_cred.go\n│   ├── otp.go\n│   ├── settings.go\n│   └── validate.go\n├── data.db\n├── db\n│   ├── db.go\n│   ├── otp.go\n│   ├── redeem.go\n│   └── user.go\n├── Dockerfile\n├── go.mod\n├── go.sum\n├── iitk-coin\n├── LICENSE\n├── main.go\n├── Models.png\n├── README.md\n└── routes\n    ├── redeem.go\n    ├── trnxn.go\n    ├── user.go\n    └── utility.go\n\n4 directories, 23 files\n```\n\n## Usage\n\n### Use this Repo\n\n```bash\nmkdir $GOPATH/src/github.com/1-Harshit\ncd $GOPATH/src/github.com/1-Harshit\ngit clone https://github.com/1-Harshit/iitk-coin.git\ncd iitk-coin\n\ngo run main.go\n# or build the program and run the executable\ngo build\n./iitk-coin\n```\n\n### Use Docker Image\n\n```bash\ndocker run --rm -p 8080:8080 1harshit/iitk-coin\n```\n\nExpected Output:\n\n```\n2021/07/18 01:03:46 Starting server. Listening on http://localhost:8080\n```\n\n## Endpoints\n\nPOST requests take place via `JSON` requests. A typical usage would look like\n\n```bash\ncurl -H \"Content-Type: application/json\" [-H \"Authorization: Bearer JWT\"] --request POST  -d '\u003cjson-request\u003e'  http://localhost:8080/\u003cendpoint\u003e\n# or if using get\ncurl [-H \"Authorization: Bearer JWT\"] --request GET http://localhost:8080/\u003cendpoint\u003e\n```\n\n#### Signup\n\n- `/signup/otp` : `POST`\n\n```json\n{ \"name\": \"\u003cname\u003e\", \"roll\": \"\u003crollno\u003e\", \"email\": \"\u003cemailid\u003e\" }\n```\n\n- `/signup` : `POST`\n\n```json\n{\n  \"name\": \"\u003cname\u003e\",\n  \"roll\": \"\u003crollno\u003e\",\n  \"email\": \"\u003cemailid\u003e\",\n  \"password\": \"\u003cpassword\u003e\",\n  \"otp\": \"\u003cotp\u003e\",\n  \"batch\": \"\u003cbatch\u003e\"\n}\n```\n\n#### Login\n\n- `/login` : `POST`\n\n```json\n{ \"roll\": \"\u003crollno\u003e\", \"password\": \"\u003cpassword\u003e\" }\n```\n\n- `/secretpage` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/secretpage\n```\n\nAuth Header needed in all endpoints below this\n\n#### User's Info\n\n- `/user/info` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/user/info\n```\n\n- `/user/reward` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/user/reward\n```\n\n- `/user/transaction` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/user/transaction\n```\n\n- `/user/redeem` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/user/redeem\n```\n\n#### Reset Password\n\n- `/forgotpass/otp` : `POST`\n\n```json\n{ \"roll\": \"\u003crollno\u003e\", \"email\": \"\u003cemailid\u003e\" }\n```\n\n- `/forgotpass` : `POST`\n\n```json\n{ \"roll\": \"\u003crollno\u003e\", \"password\": \"\u003cpassword\u003e\", \"otp\": \"\u003cotp\u003e\" }\n```\n\n#### Rewards\n\n- `/reward` : `POST` Only GenSec and AH\n\n```json\n{ \"roll\": \"\u003crollno\u003e\", \"coins\": \"\u003ccoins\u003e\" }\n```\n\n#### Transfer\n\n- `/transfer/otp` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/transfer/otp\n```\n\n- `/transfer` : `POST`\n\n```json\n{ \"roll\": \"\u003crollno\u003e\", \"coins\": \"\u003ccoins\u003e\", \"otp\": \"\u003cotp\u003e\" }\n```\n\n#### Store\n\n- `/store/list` : `GET`\n\n```bash\ncurl --request GET http://localhost:8080/store/list\n```\n\n- `/store/add` : `POST` Only GenSec and AH\n\n```json\n{ \"name\": \"\u003citemname\u003e\", \"value\": \"\u003citemvalue\u003e\" }\n```\n\n- `/store/remove` : `POST` Only GenSec and AH\n\n```json\n{ \"itemNo\": \"\u003citemno\u003e\" }\n```\n\n#### Redeem\n\n- `/redeem/request/otp` : `GET`\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080/redeem/request/otp\n```\n\n- `/redeem/request` : `POST`\n\n```json\n{ \"itemNo\": \"\u003citemno\u003e\", \"otp\": \"\u003cotp\u003e\" }\n```\n\n- `/redeem/list` : `GET` Only GenSec and AH\n\n```bash\ncurl -H \"Authorization: Bearer $JWT\" --request GET http://localhost:8080//redeem/list\n```\n\n- `/redeem/approve` : `POST` Only GenSec and AH\n\n```json\n{ \"redeemid\": \"\u003credeemid\u003e\" }\n```\n\n- `/redeem/reject` : `POST` Only GenSec and AH\n\n```json\n{ \"redeemid\": \"\u003credeemid\u003e\" }\n```\n\n### How to use\n\n1. Run the `main.go` file this will Listen and Serve on `localhost:8080`\n2. Use `curl` to use endpoints as shown above\n\n## Models\n\n![Models](Models.png \"Database Struct\")\n\n## Settings\n\n### about `config/settings.go`\n\nSome unkown variables are stored there.\n\n- Path of DB\n- Max coins one can have\n- Minimum Events needed for transfer\n- tax\n  - const IntraBatchTax float64 = 0.02\n  - const InterBatchTax float64 = 0.33\n- const IsStoreOpen bool = true\n- Email Credentials for sending OTP\n    - Username\n    - Password\n\n## Footnotes\n\nI'd like to name it **Koins**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1-harshit%2Fiitk-coin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1-harshit%2Fiitk-coin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1-harshit%2Fiitk-coin/lists"}