Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1-harshit/iitk-coin
Summer SnT Project 2021, Programming Club
https://github.com/1-harshit/iitk-coin
backend currency go golang jwt psuedo server sqlite3 summer-project wallet
Last synced: about 2 months ago
JSON representation
Summer SnT Project 2021, Programming Club
- Host: GitHub
- URL: https://github.com/1-harshit/iitk-coin
- Owner: 1-Harshit
- License: mit
- Created: 2021-05-29T05:50:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-15T19:49:14.000Z (about 3 years ago)
- Last Synced: 2024-11-20T14:14:22.404Z (about 2 months ago)
- Topics: backend, currency, go, golang, jwt, psuedo, server, sqlite3, summer-project, wallet
- Language: Go
- Homepage: https://1-harshit.github.io/iitk-coin/
- Size: 5.9 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iitk-coin
## **Summer Project 2021**
## **SnT Project 2021, Programming Club**
This repository contains the backend code for the IITK Coin which is a reward based psuedo currency of IIT Kanpur.
### Relevant Links
- [Documentation of this repo](https://docs.google.com/document/d/16ZVl9a0_EFNMDupLyzjbsJd7bqx9oZ9GRznnxGYbLdI/edit?usp=sharing)
- [Website](https://1-harshit.github.io/iitk-coin/)
- [EndTerm Evaulation Folder](https://drive.google.com/drive/folders/1N93J_1ouR1AXctIZZkek0YMD5_LY0LVM?usp=sharing)
- [Midterm Evaluation presentation](https://docs.google.com/presentation/d/1kriN-7A3v1RlXUDL5NETX3roJKRMJInptkWofIxY8dg/edit?usp=sharing)
- [Midterm Documentation](https://docs.google.com/document/d/1bvOWH4k0U-l2pQ1jLWIDzOkJ2wbHNW4jJw7tMWkUV6o/edit?usp=sharing)## Table Of Content
- [Development Environment](#development-environment)
- [Directory Structure](#directory-structure)
- [Usage](#usage)
- [Endpoints](#endpoints)
- [Models](#models)
- [Settings](#settings)## Development Environment
```bash
- OS: Ubuntu 20.04.2 LTS x86-64 # https://ubuntu.com/download
- Kernel: Linux 5.8.0-59-generic # https://kernel.ubuntu.com/
- go version: go1.16.6 linux/amd64 # https://golang.org/dl/
- text editor: VSCode # https://code.visualstudio.com/download
- terminal: Zsh # https://ohmyz.sh/
```## Directory Structure
```
.
~go/src/github.com/1-Harshit/iitk-coin
├── auth
│ └── auth.go
├── config
│ ├── config.go
│ ├── email_cred.go
│ ├── otp.go
│ ├── settings.go
│ └── validate.go
├── data.db
├── db
│ ├── db.go
│ ├── otp.go
│ ├── redeem.go
│ └── user.go
├── Dockerfile
├── go.mod
├── go.sum
├── iitk-coin
├── LICENSE
├── main.go
├── Models.png
├── README.md
└── routes
├── redeem.go
├── trnxn.go
├── user.go
└── utility.go4 directories, 23 files
```## Usage
### Use this Repo
```bash
mkdir $GOPATH/src/github.com/1-Harshit
cd $GOPATH/src/github.com/1-Harshit
git clone https://github.com/1-Harshit/iitk-coin.git
cd iitk-coingo run main.go
# or build the program and run the executable
go build
./iitk-coin
```### Use Docker Image
```bash
docker run --rm -p 8080:8080 1harshit/iitk-coin
```Expected Output:
```
2021/07/18 01:03:46 Starting server. Listening on http://localhost:8080
```## Endpoints
POST requests take place via `JSON` requests. A typical usage would look like
```bash
curl -H "Content-Type: application/json" [-H "Authorization: Bearer JWT"] --request POST -d '' http://localhost:8080/
# or if using get
curl [-H "Authorization: Bearer JWT"] --request GET http://localhost:8080/
```#### Signup
- `/signup/otp` : `POST`
```json
{ "name": "", "roll": "", "email": "" }
```- `/signup` : `POST`
```json
{
"name": "",
"roll": "",
"email": "",
"password": "",
"otp": "",
"batch": ""
}
```#### Login
- `/login` : `POST`
```json
{ "roll": "", "password": "" }
```- `/secretpage` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/secretpage
```Auth Header needed in all endpoints below this
#### User's Info
- `/user/info` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/info
```- `/user/reward` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/reward
```- `/user/transaction` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/transaction
```- `/user/redeem` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/redeem
```#### Reset Password
- `/forgotpass/otp` : `POST`
```json
{ "roll": "", "email": "" }
```- `/forgotpass` : `POST`
```json
{ "roll": "", "password": "", "otp": "" }
```#### Rewards
- `/reward` : `POST` Only GenSec and AH
```json
{ "roll": "", "coins": "" }
```#### Transfer
- `/transfer/otp` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/transfer/otp
```- `/transfer` : `POST`
```json
{ "roll": "", "coins": "", "otp": "" }
```#### Store
- `/store/list` : `GET`
```bash
curl --request GET http://localhost:8080/store/list
```- `/store/add` : `POST` Only GenSec and AH
```json
{ "name": "", "value": "" }
```- `/store/remove` : `POST` Only GenSec and AH
```json
{ "itemNo": "" }
```#### Redeem
- `/redeem/request/otp` : `GET`
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/redeem/request/otp
```- `/redeem/request` : `POST`
```json
{ "itemNo": "", "otp": "" }
```- `/redeem/list` : `GET` Only GenSec and AH
```bash
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080//redeem/list
```- `/redeem/approve` : `POST` Only GenSec and AH
```json
{ "redeemid": "" }
```- `/redeem/reject` : `POST` Only GenSec and AH
```json
{ "redeemid": "" }
```### How to use
1. Run the `main.go` file this will Listen and Serve on `localhost:8080`
2. Use `curl` to use endpoints as shown above## Models
![Models](Models.png "Database Struct")
## Settings
### about `config/settings.go`
Some unkown variables are stored there.
- Path of DB
- Max coins one can have
- Minimum Events needed for transfer
- tax
- const IntraBatchTax float64 = 0.02
- const InterBatchTax float64 = 0.33
- const IsStoreOpen bool = true
- Email Credentials for sending OTP
- Username
- Password## Footnotes
I'd like to name it **Koins**