Skip to content

Justinianus2001/trello-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📋 Trello Clone - Backend API

A full-featured Trello clone backend built with Node.js, Express, and MongoDB. This RESTful API provides comprehensive board management, real-time collaboration, and user authentication.

✨ Features

  • 🔐 Authentication & Authorization

    • JWT-based authentication
    • User registration with email verification
    • Secure password handling
    • Protected routes with middleware
  • 📊 Board Management

    • Create, read, update, delete boards
    • Board ownership and permissions
    • Invite users to boards
    • Real-time board updates via WebSocket
  • 📝 Column & Card System

    • Flexible column management
    • Drag-and-drop card organization
    • Card descriptions and activities
    • Card attachments
  • 👥 User Collaboration

    • User invitations system
    • Board member management
    • Real-time notifications
  • 📁 File Management

    • Image upload support (Cloudinary)
    • Avatar management
    • Card attachments
  • ✉️ Email Services

    • Email verification
    • Invitation emails
    • Powered by Brevo

🛠️ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT (JSON Web Tokens)
  • Validation: Express Validator / Joi
  • File Upload: Multer
  • Cloud Storage: Cloudinary
  • Email Service: Brevo (formerly Sendinblue)
  • WebSocket: Socket.io
  • CORS: Express CORS middleware

📁 Project Structure

trello-api/
├── src/
│   ├── config/          # Configuration files
│   │   ├── cors.js
│   │   ├── environment.js
│   │   └── mongodb.js
│   ├── controllers/     # Request handlers
│   │   ├── boardController.js
│   │   ├── cardController.js
│   │   ├── columnController.js
│   │   ├── invitationController.js
│   │   └── userController.js
│   ├── middlewares/     # Custom middleware
│   │   ├── authMiddleware.js
│   │   ├── erorHandlingMiddleware.js
│   │   └── multerUploadMiddleware.js
│   ├── models/          # Database models
│   │   ├── boardModel.js
│   │   ├── cardModel.js
│   │   ├── columnModel.js
│   │   ├── invitationModel.js
│   │   └── userModel.js
│   ├── providers/       # Third-party service integrations
│   │   ├── BrevoProvider.js
│   │   ├── CloudinaryProvider.js
│   │   └── JwtProvider.js
│   ├── routes/          # API routes
│   │   └── v1/
│   │       ├── boardRoute.js
│   │       ├── cardRoute.js
│   │       ├── columnRoute.js
│   │       ├── invitationRoute.js
│   │       ├── userRoute.js
│   │       └── index.js
│   ├── services/        # Business logic
│   │   ├── boardService.js
│   │   ├── cardService.js
│   │   ├── columnService.js
│   │   ├── invitationService.js
│   │   └── userService.js
│   ├── sockets/         # WebSocket handlers
│   │   └── inviteUserToBoardSocket.js
│   ├── utils/           # Utility functions
│   │   ├── algorithms.js
│   │   ├── ApiError.js
│   │   ├── constants.js
│   │   ├── formatters.js
│   │   ├── sorts.js
│   │   └── validators.js
│   ├── validations/     # Request validation schemas
│   │   ├── boardValidation.js
│   │   ├── cardValidation.js
│   │   ├── columnValidation.js
│   │   ├── invitationValidation.js
│   │   └── userValidation.js
│   └── server.js        # Application entry point
├── .env.example
├── .eslintrc.cjs
├── .babelrc
├── jsconfig.json
└── package.json

🚀 Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (v4.4 or higher)
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/Justinianus2001/trello-api.git
    cd trello-api
  2. Install dependencies

    npm install
  3. Set up environment variables

    Copy .env.example to .env and fill in your credentials:

    cp .env.example .env

    Required environment variables:

    # Server Configuration
    LOCAL_DEV_APP_HOST=localhost
    LOCAL_DEV_APP_PORT=8017
    
    # Build Mode
    BUILD_MODE=dev
    
    # Database
    MONGODB_URI=your_mongodb_connection_string
    DATABASE_NAME=your_database_name
    
    # JWT Secret
    JWT_SECRET=your_jwt_secret_key
    
    # Cloudinary (for file uploads)
    CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
    CLOUDINARY_API_KEY=your_cloudinary_api_key
    CLOUDINARY_API_SECRET=your_cloudinary_api_secret
    
    # Brevo (for emails)
    BREVO_API_KEY=your_brevo_api_key
    BREVO_SENDER_EMAIL=your_sender_email
    BREVO_SENDER_NAME=Your_App_Name
    
    # Client URL (for CORS and email links)
    CLIENT_URL=http://localhost:5173
  4. Start the development server

    npm run dev

    The API will be available at http://localhost:8017

Production Build

npm run build
npm start

📚 API Documentation

Base URL

http://localhost:8017/v1

Authentication Endpoints

Method Endpoint Description Auth Required
POST /users/register Register a new user No
POST /users/login Login user No
GET /users/verify/:token Verify email No
GET /users/me Get current user Yes
PUT /users/update Update user profile Yes

Board Endpoints

Method Endpoint Description Auth Required
GET /boards Get all user boards Yes
POST /boards Create new board Yes
GET /boards/:id Get board details Yes
PUT /boards/:id Update board Yes
DELETE /boards/:id Delete board Yes
POST /boards/:id/invite Invite user to board Yes

Column Endpoints

Method Endpoint Description Auth Required
POST /columns Create column Yes
PUT /columns/:id Update column Yes
DELETE /columns/:id Delete column Yes

Card Endpoints

Method Endpoint Description Auth Required
POST /cards Create card Yes
PUT /cards/:id Update card Yes
DELETE /cards/:id Delete card Yes

Invitation Endpoints

Method Endpoint Description Auth Required
GET /invitations Get user invitations Yes
POST /invitations/:id/accept Accept invitation Yes
POST /invitations/:id/decline Decline invitation Yes

🔒 Authentication

This API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:

Authorization: Bearer <your_jwt_token>

🧪 Testing

npm test

📝 Code Style

This project uses ESLint for code linting. Run the linter:

npm run lint

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License.

👨‍💻 Author

Hoang Le Ngoc - @Justinianus2001

🙏 Acknowledgments

  • Inspired by Trello
  • Built as a learning project for full-stack development

📧 Contact

For questions or support, please open an issue or contact: lengochoang681@gmail.com


Frontend Repository: trello-web

About

A RESTful API built with Node.js, Express.js, and MongoDB to power a full-stack Trello-style project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published