Skip to content

Samarth622/Trello-Clone-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Mini Trello Clone โ€“ Backend (Node.js + Express + MongoDB)

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.


๐Ÿš€ Features

1. Authentication (JWT)

  • User Registration & Login.
  • Password hashing using bcrypt.
  • Token-based authentication (JWT).
  • Secure protected routes.

2. Boards

  • Create, update, and delete boards.
  • Access Control: Owner vs. Member permissions.
  • Invite members via email.
  • Fetch all boards a user has access to.

3. Lists

  • Create, update, and delete lists within a board.
  • Positional Indexing: Handles ordered lists.
  • Auto-incrementing list positions.

4. Cards

  • 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.

5. ๐Ÿง  Smart Recommendations Engine

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.

6. Access Control

  • Owner: Full update/delete permissions.
  • Member: Read, add, and edit cards/lists.
  • Middleware ensures no unauthorized access.

๐Ÿ›  Tech Stack

  • 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)

๐Ÿ“‚ Project Structure

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.md

โš™๏ธ Installation & Setup

1. Clone the repository

git clone <repo-url>
cd backend

2. Install dependencies

npm install

3. Configure Environment Variables

Create 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=7d

4. Run the Server

Development Mode:

npm run dev

Production Mode:

npm start

Server runs on: http://localhost:8080


๐Ÿ“ก API Overview

All protected routes require the following header: Authorization: Bearer <token>

๐Ÿ” Authentication

Method Endpoint Description
POST /auth/register Register a new user
POST /auth/login Login and receive JWT

๐Ÿ“‹ Boards

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

๐Ÿ“‘ Lists

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

๐Ÿ“ Cards

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

๐Ÿง  Smart Recommendations

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)"
    }
  ]
}

๐Ÿ’ก Recommendation Engine Logic

1. Due Date Logic

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

2. Move Suggestion Logic

Suggests moving a card to a specific list based on keywords:

  • start, doing โ†’ "In Progress"
  • done, completed โ†’ "Done"
  • blocked, hold โ†’ "Blocked"
  • review, pr โ†’ "Review"

3. Related Groups Logic

  • Tokenizes card titles and descriptions.
  • Generates term frequency vectors.
  • Computes cosine-like similarity.
  • Groups cards with a similarity threshold โ‰ฅ 0.25.

๐Ÿ›ก Security & Standards

  • 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.

๐Ÿ”ฎ Future Enhancements

  • Real-time updates using Socket.io.
  • Activity Logs / Audit Trails.
  • Granular Roles (Admin, Editor, Viewer).
  • File Attachments (AWS S3 / Cloudinary).
  • Commenting system on cards.

๐Ÿ‘ค Author

Samarth Gupta Backend built for the Mini Trello Clone assignment.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors