A NodeJs application which uses MongoDB to store nested/threaded comments. User Comments can be one of the primary things in any Social or Collaborative website. The applications like Instagram, YouTube, Reddit etc have great implementations of User Comments.
- The Backend is a REST API built in ExpressJs which is an MVC web-application framework for NodeJs.
- MongoDB is used as the NoSQL Database along with ExpressJs in the backend Rest API. Mongoose, a MongoDB ODM(Object Data Mapper) has also been used along with MongoDB in the database layer.
- The Frontend is built using ReactJs along with React-Router and Material UI as component library.
- Home page has a demo post where users can add their comments.
- Users can Add a new comment or reply to an existing comment.
- Users can also Edit their own comment
- Their can be no limit to the nesting of comments, but ideally, for the optimum performace and better user experience, I added a restriction to the depth value of nesting comments as 4.
- For Instance, Instagram only allow one level of reply to a comment, that is nesting level of 2 (parent, one-child)
- Express 4.x
- MongoDB 3.x
- Mongoose 5.x
- Node 8.x
- React-Router 5.x
Clone the repository and Run the following commands in the terminal:
npm run install_all
(This will install the server's and the client's dependency packages)npm start
(This will start the backend server. Alternatively, you can also runnpm run start_dev
to start the server withnodemon
, which will look for the changes in the files and restart the server everytime)cd view && npm start
(This will start the Frontend React application for Dev Environment. For Production, runnpm build
to build the FrontEnd for deployment)
Examples of Threaded Comments?
How to store Threded Comments?
Threaded Comments are basically hierarchical data, with parent & child relation.
Their are bunch of ways to store the hierarchical data in Relational/non-Relational database