This repository contains my implementation of backend of IITK Coin pclub snt summer project.
- Directory Structure
- Database
- Endpoint Details
├── Dockerfile
├── README.md
├── controllers
│ ├── auth.go
│ ├── coins.go
│ ├── db.go
│ ├── item.go
│ ├── middleware.go
│ ├── otp.go
│ ├── redeem.go
│ ├── router.go
│ ├── transaction.go
│ ├── user.go
│ ├── utils.go
│ └── validation.go
├── docker-compose.yml
├── go.mod
├── go.sum
├── main.go
├── models
│ ├── hash.go
│ ├── item.go
│ ├── params.go
│ ├── request.go
│ ├── token.go
│ └── user.go
├── sqldb
│ └── db.go
└── utils
├── mail.go
└── otp.go
4 directories, 27 files
My database implementation containe five tables
-
CREATE TABLE users ( rollNo INTEGER PRIMARY KEY, name TEXT NOT NULL, password TEXT NOT NULL, coins TEXT NOT NULL, isAdmin INTEGER NOT NULL, isFreezed INTEGER NOT NULL );
-
CREATE TABLE transactions ( id INTEGER PRIMARY KEY AUTOINCREMENT, sender INTEGER REFERENCES users(rollNo), reciever INTEGET NOT NULL REFERENCES users(rollNo), amount INTEGER NOT NULL, type TEXT NOT NULL, madeAt INTEGER NOT NULL );
-
CREATE TABLE redeem_requests ( id INTEGER PRIMARY KEY AUTOINCREMENT, user INTEGER NOT NULL REFERENCES users(rollNo), itemCode INTEGER NOT NULL REFERENCES items(code), status TEXT NOT NULL, madeAt TEXT NOT NULL );
-
CREATE TABLE items ( code INTEGER PRIMARY KEY AUTOINCREMENT, amount INTEGER NOT NULL, name TEXT NOT NULL, isAvailable INTEGER NOT NULL );
-
CREATE TABLE otps ( otp INTEGER NOT NULL, user INTEGER NOT NULL REFERENCES users(rollNo) PRIMARY KEY, madeAt TEXT NOT NULL );
url: /user/signup
method: POST
Request: Body {
"rollNo": "",
"name": "",
"password": "",
"isAdmin": "",
"isFreezed": ""
}
url: /user/login
method: POST
Request: Body {
"rollNo": "",
"password": ""
}
url: /coins/send
method: POST
Request: Body {
"rollNo": "",
"coins": ""
}
-> rollNo here refers to reciever's roll no.
url: /coins/reward
method: POST
Request: Body {
"rollNo": "",
"coins": ""
}
-> rollNo here refers to reciever's roll no.
Note:- This is an admin only route.
url: /coins/balance
method: GET
url: /items
method: GET
url: /coins/redeem
method: POST
Request: Body {
"itemCode: ""
}
url: /redeemRequests
method: GET
Note:- This is an admin only route.
url: /redeemRequests
method: POST
Request: Body {
"id": "",
"status": ""
}
Note:- This is an admin only route.
url: /otp
method: GET
url: /otp
method: POST
Request: Body {
"otp": "",
}
url: /items
method: POST
Request: Body {
"amount": "",
"name": "",
"isAvailable": ""
}
Note:- This is an admin only route.
url: /items/:itemcode
method: PUT
Request: Body {
"amount": "", //optional
"name": "", //optional
"isAvailable": "" //optional
}
Note:- This is an admin only route.
url: /items/:itemcode
method: DELETE
Note:- This is an admin only route.