Cat-Scribers


This project is an implementation of the Shopify Developer Challenge 2021. You can access the prompt by clicking
here.
The Cat-Scibers project is a subscription based REST API to subscribe to cat photos. Its purpose is to provide the
ability to every user to subscribe to other user's cat photos. Not only that, but it is also impossible to submit a
picture that does not contain a Cat. This project utilizes Google Vision API to ensure that the content of the site
stays pure with respect to its original purpose.
Currently, payments are taken every first of the month at midnight, or when you subscribe to another user.
How to run
- Install Golang (this project was developed with
go 1.14.2 windows/amd64
)
- Run
go get
- Get an API key for Google Vision API
- Get a MongoDB instance running (the original version uses MongoDB Atlas, but a local version would work just as well.
- Set the following Environment Variables:
HTTP_PORT=<Port number>
GOOGLE_APPLICATION_CREDENTIALS=<Path to Google JSON credentials file>
MONGODB_URL=<MongoDB connection URL>
JWT_SECREt=<JWT secret>
API documentation
Open
GET /ping
- Health
- Request:
empty
- Response: "Pong"
POST /login
- Login
-
Request:
email: string,
password: string
-
Response:
user_id: string,
token: string
POST /signup
- Sign up
-
Request:
name: string,
email: string,
password: string,
subscription_price: number
-
Response:
user_id: string,
token: string
GET /users
- Get all users
GET /user/:id
- Get user by ID
Require to be authenticated
To access those routes, the request must have an Authorization header. Example: Authorization Bearer <token>
-
GET /user
- Get current user
-
PUT /user
- Update current user
-
Request:
id: string
name: string
email: string
subscriptions: string[]
photos: string[]
balance: number
subscription_price: number
-
Response:
id: string
name: string
email: string
subscriptions: string[]
photos: string[]
balance: number
subscription_price: number
-
DELETE /user
- Delete current user
- Request:
empty
- Response:
message: successul
-
POST /user/photo/
- Upload photo
-
POST /user/photos/
- Upload multiple photos
-
DELETE /user/photo/:id
- Delete a photo by ID (current user)
-
Request: empty
-
Response:
message: string
-
GET /photo/:id/
- Get a photo by ID (must be subscribed to owner)
-
GET /user/:id/photos/
- Get all photos from user with ID (must be subscribed to owner)
-
POST /subscribe/:id
- Subscribe current user to user with ID
- Request:
empty
- Response:
message: string
-
DELETE /subscribe/:id
- unsubscribe current user from user with ID
- Request:
empty
- Response:
message: string
Backlog
-
Implement all relevant HTTP methods for a complete REST project
(This project implemented the basic methods for the MVP)
-
Implement optimized queries for specific operations that could be performed in a single aggregation pipeline
and would bring greater performances for certain operations.
-
Fix some obvious problems (ex: Can update the balance of a user)