There are two types of users: student and faculty. They can browse books available. For students the maximum duration to hold a title is 30 days and for faculty it is 180 days. 5 and 8 are the upper limits of holding number of books for student and faculty respectively. Same title cannot be issued to a user. Holding a title more than the speculated duration will be charged ₹ 1/- per day. A mail will be sent as a warning two days before the due date of each title held.
View demo discussion.
The project is built using the MERN stack plus PostgreSQL and GraphQL. TypeScript instead of conventional JavaScript is used throught.
- React
- SASS
- Node
- Express
- GraphQL.js
- Mongo DB (Atlas - AWS)
- Mongoose
- PostgreSQL (AWS)
- AMQP (RabbitMQ)
- The application has a loosely coupled frontend and backend architecture.
- The frontend is implemented in React 17 and SASS.
- The backend is implemented in Node.js and Express.js.
- The communication API is implemented in GraphQL.js which is configured in the backend.
- A polygot DBMS is used — stationary data handling is done by (NoSQL) MongoDB via Mongoose, while transaction data handling is done by (SQL) PostgreSQL.
- Both the DBMS are cloud hosted — MongoDB Atlas is used for MongoDB, while ElephantSQL is used for PostgreSQL.
- A single channel message queue is implemented via RabbitMQ to communicate between transaction resolvers of the API and the backend operations.
Note: I encountered some problems with my implementation of the message queue via RabbitMQ. The stringified JSON had some problems, and so, I've reversed the changes by directly resetting the main branch. I'll fix that and push the feature soon.
- Create a MongoDB Atlas account and create a cluster.
- Open collections in the cluster and visit the
Command Line Toolstab. - Scroll down to
Data Import and Export Toolssection and copy the import string. It should look likemongoimport --uri mongodb+srv://<USERNAME>:<PASSWORD>@cluster0.snhzr.mongodb.net/<DATABASE> --collection <COLLECTION> --type <FILETYPE> --file <FILENAME> - Install MongoDB Tools and then open terminal.
- Follow for all 3 files in dummy database content: paste the string from above while filling the data in the
<...>parts — forDATABASEuselibrary, forCOLLECTIONuseauthors,books,users, one at a time, forFILETYPEusejson, and finally forFILENAMEprovide path to each file relative to the terminal's PWD.
- Create an ElephantSQL account and create an instance.
- Install PostgreSQL (installs pgAdmin).
- Launch
pgAdmin-> Right Click onServers(left panel) ->Create Server. - Fill in details (name, host, database, username, password) which you'll get once you create the ElephantSQL instance.
- After Server is added, expand it (left panel) -> expand
Databasesthen scroll down to find your database and expand it -> expandSchemas-> expandPublic. - Right click on
Tables->Create Tablefor each table according to the schema:Joins are not being used here so it doesn't matter whether you use PRIMARY KEYs (PKs), but it serves as a constraint- "shelf" ("bookID" VARCHAR(16) PK, "quantity" numeric)
- "notifications" ("userID" VARCHAR(16) PK, "bookID" VARCHAR(16) PK)
- "awaiting" ("userID" VARCHAR(16) PK, "bookID" VARCHAR(16) PK, "type" VARCHAR(8), "createdAt" TIMESTAMP without Timezone)
- "transactions" ("transID" VARCHAR(16) PK, "userID" VARCHAR(16), "bookID" VARCHAR(16), "borrowDate" TIMESTAMP without Timezone, "returnDate" TIMESTAMP without Timezone - can be NULL)
- For each table, Right click on table name after expanding
Tables-> visitTools(menu bar) -> clickImport/Export-> Select file path followed by filename for each.csvfile corresponding to each of the 4 tables, and import the dummy data.
- Install Node JS
- Clone Repository
- Setup Databases
- Install RabbitMQ
- Navigate to each of
frontendandbackenddirectories and run (in terminal)npm ci - In
frontenddirectory, runnpm start - In
backenddirectory, edit the contents of.envfile with your databases configuration information - Start RabbitMQ service
- In
backenddirectory, runnpm run dev - Launch web app from
localhost:3000 - (optional) Launch GraphiQL app from
localhost:8000/api
Note: Project doesn't adapt to varying screen sizes; designed and tested on a monitor having resolution 2560 × 1080 with 100% display scaling, checked to appear fine on 1920 × 1080 at 125% scaling. For other configurations, front-end design may look out of place.