Skip to content

Backend API

blangley28 edited this page Oct 14, 2020 · 7 revisions

Overview

The pathways backend allows for persistent memory of pathways, criteria, and eventually users. It follows the MERN stack (MongoDB, ExpressJS, React, Node). Since the database can not be run in browser a new server is required to connect to the database. Screen Shot 2020-10-14 at 3 06 08 PM The React frontend will make calls to the server API (using something like axios). The API will link the client requests to persisting the data in the database.

MongoDB

MongoDB is a document-based NoSQL database which stores data as JSON. The Mongoose library is available for a Node app to connect to a MongoDB. Instructions on downloading and running MongoDB can be found here.

Collection Schemas

Collections in Mongo are equivalent to Tables in SQL based databases. There are 4 collections - Pathway, Criteria, User, and Workspace. The schemas for each collection are as follows:

const Pathway = new Schema({
	id: String, // Pathway ID (not MongoDB) – pathway.id
        userid: String, // ID for the user who owns this pathway
	pathway: Object // The actual pathway JSON
});
const Criteria = new Schema({
	id: String, // Criteria ID (not MongoDB) – criteria.id
	userid: String, // ID for the user who owns this criteria
	criteria: Object // The actual criteria JSON
});
const User = new Schema({
	userid: String, // Unique ID for this user
	email: String,
	password: String // Hashed password (bcrypt)
});
const Workspace = new Schema({
	userid: String, // ID for the user who owns this workspace
	name: String, // Name for the workspace
	initials: String, // 2 character abbreviation
	admin: String[], // List of user IDs w/ admin privileges
	member: String[], // List of user IDs w/ member privileges
	criteria: String[], // List of criteria IDs in workspace
	pathway: String[], // List of pathway IDs in workspace
});

Note: Before user authentication is implemented the User and Workspace collections will not exist. The userid property on Pathway and Criteria will also not exist yet.

Clone this wiki locally