A production-ready backend for a Trello-style task management application featuring collaborative boards, lists, cards, and a custom Smart Recommendations Engine.
This system is built using Node.js, Express.js, and MongoDB with JWT authentication. It supports detailed access control, member invitations, drag-and-drop logic (positional indexing), and an NLP-like rule-based recommendation system for due dates and list movements.
- User Registration & Login.
- Password hashing using bcrypt.
- Token-based authentication (JWT).
- Secure protected routes.
- Create, update, and delete boards.
- Access Control: Owner vs. Member permissions.
- Invite members via email.
- Fetch all boards a user has access to.
- Create, update, and delete lists within a board.
- Positional Indexing: Handles ordered lists.
- Auto-incrementing list positions.
- Create, update, delete cards.
- Move Logic: Move cards across lists with automatic position shifting.
- Metadata: Priority, labels, assignees, and due dates.
- Strong validation and permission checks.
A rule-based NLP module that provides:
- Due Date Suggestions: Based on weighted keyword scoring (e.g., "urgent", "asap").
- List Movement Suggestions: Based on status keywords (e.g., "done", "review").
- Related Cards: Grouped by textual similarity using cosine-like scoring.
- Confidence Scoring: Returns a confidence level for every suggestion.
- Owner: Full update/delete permissions.
- Member: Read, add, and edit cards/lists.
- Middleware ensures no unauthorized access.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB + Mongoose
- Auth: JWT (JSON Web Token) & bcrypt.js
- Logic: Custom NLP-like keyword engine
- Architecture: Modular (Controllers, Routes, Services)
src/
โโโ controllers/ # Request handlers
โ โโโ auth.controller.js
โ โโโ board.controller.js
โ โโโ list.controller.js
โ โโโ card.controller.js
โ โโโ recs.controller.js
โ
โโโ middlewares/ # Auth & Permission checks
โ โโโ auth.middleware.js
โ โโโ checkBoardAccess.js
โ
โโโ models/ # Mongoose Schemas
โ โโโ user.model.js
โ โโโ board.model.js
โ โโโ list.model.js
โ โโโ card.model.js
โ
โโโ routes/ # API Route definitions
โ โโโ auth.routes.js
โ โโโ board.routes.js
โ โโโ list.routes.js
โ โโโ card.routes.js
โ โโโ recs.routes.js
โ
โโโ utils/ # Helper functions
โ โโโ generateJWT.js
โ โโโ textUtils.js
โ โโโ recommendationsLogic.js
โ
โโโ server.js # Entry point
โโโ README.mdgit clone <repo-url>
cd backendnpm installCreate a .env file in the root directory and add the following:
PORT=8080
MONGO_URI=mongodb://localhost:27017/trello-clone
JWT_SECRET=your_jwt_secret
EXPIRES_IN=7dDevelopment Mode:
npm run devProduction Mode:
npm startServer runs on: http://localhost:8080
All protected routes require the following header:
Authorization: Bearer <token>
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Login and receive JWT |
| Method | Endpoint | Description |
|---|---|---|
| POST | /boards |
Create a board |
| GET | /boards |
Get all boards (Owner/Member) |
| GET | /boards/:id |
Get specific board details |
| PUT | /boards/:id |
Update board (Owner only) |
| DELETE | /boards/:id |
Delete board (Owner only) |
| POST | /boards/:id/members |
Invite user by email |
| Method | Endpoint | Description |
|---|---|---|
| POST | /boards/:id/lists |
Create a new list |
| GET | /boards/:id/lists |
Get ordered lists |
| PUT | /boards/:id/lists/:listId |
Update list |
| DELETE | /boards/:id/lists/:listId |
Delete list |
| Method | Endpoint | Description |
|---|---|---|
| POST | /card/:boardId/:listId/cards |
Create a card |
| GET | /card/:boardId/cards |
Get all cards |
| PUT | /card/:boardId/cards/:cardId |
Update card details |
| POST | /card/:boardId/cards/:cardId/move |
Move card (List/Position) |
| DELETE | /card/:boardId/cards/:cardId |
Delete card |
| Method | Endpoint | Description |
|---|---|---|
| GET | /boards/:boardId/recommendations |
Get AI suggestions |
Response Example for Recommendations:
{
"dueDateSuggestions": [
{
"cardTitle": "Fix login bug",
"suggestedDue": "2025-02-24T09:00:00.123Z",
"score": 7,
"confidence": 0.85,
"reason": "Weighted keywords sum = 7"
}
],
"moveSuggestions": [
{
"cardTitle": "Fix login bug",
"suggestedListName": "In Progress",
"confidence": 0.8,
"reason": "Matched 2 keyword(s)"
}
]
}Calculates a score based on keywords in the card description:
- +5:
urgent,asap - +3:
bug,fix - +2:
review - +1:
meeting,planning
Result:
- Score โฅ 8 โ Due in 1 day
- Score โฅ 5 โ Due in 2 days
- Score โฅ 3 โ Due in 5 days
- Score > 0 โ Due in 7 days
Suggests moving a card to a specific list based on keywords:
start,doingโ "In Progress"done,completedโ "Done"blocked,holdโ "Blocked"review,prโ "Review"
- Tokenizes card titles and descriptions.
- Generates term frequency vectors.
- Computes cosine-like similarity.
- Groups cards with a similarity threshold โฅ 0.25.
- Sanitized Queries: Prevents NoSQL injection.
- Password Encryption: Uses
bcrypt(no plaintext storage). - Role-Based Access: Strict Owner vs. Member separation.
- Environment Config: Sensitive keys stored in
.env.
- Real-time updates using Socket.io.
- Activity Logs / Audit Trails.
- Granular Roles (Admin, Editor, Viewer).
- File Attachments (AWS S3 / Cloudinary).
- Commenting system on cards.
Samarth Gupta Backend built for the Mini Trello Clone assignment.