thread-core
A backend API for a Reddit-style forum app, handling users, communities, posts, comments, and voting.
thread-core is a backend API for a community discussion platform, similar in concept to a forum site where users can join topic-based communities, post content, vote on posts, and comment in threads. It is written in JavaScript and runs on Node.js with Express as the web framework and MongoDB as the database.
The authentication system uses JWT tokens (short-lived credentials that prove who you are without needing to send a password each request), with passwords stored securely using bcrypt hashing. Users can register, log in, and update their profile including a profile picture, which is stored via Cloudinary, a cloud image hosting service.
Communities can be created and joined or left by any registered user. When the owner of a community leaves, admin rights are handed over to the next member automatically. If the last person leaves, the community and all its associated data are deleted. Only community members can create posts. Posts support optional image uploads via Cloudinary. Voting on posts uses an upvote/downvote toggle system that enforces one vote per user per post, and deleting a post removes all its comments and vote records.
Comments support two levels of nesting: top-level comments and replies to those comments. Feeds (the home feed showing all posts, and community-specific feeds) support cursor-based pagination, meaning the API returns a pointer to the next page of results rather than using page numbers.
The tech stack is Node.js runtime, Express 5 framework, MongoDB and Mongoose for the database layer, jsonwebtoken for authentication tokens, bcrypt for password hashing, Multer for file handling, and Cloudinary for image storage.
Where it fits
- Use it as a ready-made backend for a community or forum style app.
- Study it as an example of JWT authentication and role handling in Express.
- Learn cursor-based pagination patterns for feeds and comments.
- Extend it with a frontend to build a full community discussion app.