Skip to content

benmo-pdx/Chat_Backend_CS314

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ben Moritz, benmo@pdx.edu Chat App - Final Deliverable

===Layout===

*.env #Holds location variables and secret for JWT signing. Must be filed out before running backend.

*index.js #Acts as entry point into backend for web application *db.js #Mogoose connection helper *gridfs.js #GridFS connection helper for storing images in MongoDB. *models #Contains Object Data Models for application objects. -user.model.js #Contains all info pertaining to one user. -message.model.js #Contains all info pertaining to a specific message between two users. -channel.model.js #Contains all info pertaining to any one group chat. -channel-message.model.js #Contains info pertaining to any message in a group chat. Contains a channel ID instead of a sending User ID. *middleware #Initial interface between user and server -auth.middleware.js #Manages auth tokens/cookies. -upload.middleware.js #Handles initial storage/processing of uploaded images. *routes #Routes frontend requests to server and vice versa. -auth.routes.js #signup, login, logout, getUserInfo, updateProfile -channel.routes.js #createChannel, getUserChannels, getChannelMessages -contacts.routes.js #searchContacts, getAllContacts, getContactsForList, deleteDirectMessages -files.routes.js #Specifically helps direct files stored with GridFS to the frontend with appropriate naming. -messages.routes.js #getMessages, uploadMessageFile, uploadFile *controllers #Handles server interactions with database. -auth.controller.js #Performs login/out, signup, user lookup, and update actions. -channel.controller.js #Performs channel lookup and creation actions. -contacts.controller.js #Performs contact lookup and user message management functions. -messages.controller.js #Performs message loading and creation actions. *socket.js #Uses socket.io to allow real-time messaging between users.

The Express App frontend sends requests through Node.js, which in turn interfaces with MongoDB and GridFS via MongoDB to add/fetch data from the backend database.

===Testing===

Unit testing was performed on each function to ensure that it produced proper output/accepted proper input and would produce the appropriate error code upon failure. End-to-end tests were performed to test system integrity from signup to login to messaging to logout. Multiple separate connections were created to test server function under load.

===Challenges===

I had some difficulty getting database entries to match what was needed for input into the frontend and vice versa. When developing an application entirely on your own, you need to worry less about the modularity of your code, as you are able to modify either portion of an application when two parts aren't interfacing correctly. However, when developing only one section of an application, in this case the backend of a chat application, I/O is strictly defined and you must modify your code to match it exactly. At various points I had to chase down bugs caused by slightly different naming conventions to variables containing things like ID, which arrived from MongoDB methods with different names than what the frontend app expected. In another instance, the backend code needed to be changed to accommodate red profile colors having a color value of 0, as this was originally being assigned to null by Node.js.

===Additional Features===

This backend implements GridFS to support file sizes beyond the max file size supported natively by MongoDB. I found that I did not have many image files on my computer, but that some of the files that I did have lying around were fairly high resolution screenshots from video games, which would potentially push the limits of what MongoDB could store, so I implemented GridFS in the backend database to account for the possibility of a user uploading similarly large files without generating errors.

About

A backend implementation to be used with the prebuit frontend for CS314's term project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors