Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

DevCollab API Server ๐Ÿš€

A robust Node.js/Express.js backend API for a developer collaboration platform, built with TypeScript, MongoDB, and modern development practices.

๐ŸŒŸ Features

๐Ÿ” Authentication & User Management

  • User Registration & Login: Secure user authentication with JWT tokens
  • Email Verification: Email-based account verification system
  • Password Management: Secure password hashing with bcrypt
  • Profile Management: User profile CRUD operations with avatar support
  • Session Management: JWT-based session handling

๐Ÿ“ Project Management

  • Project CRUD: Create, read, update, and delete projects
  • Collaboration System: Add/remove project collaborators
  • Project Ownership: Secure project access control
  • Activity Tracking: Project activity logging (prepared for future use)

๐Ÿ“‹ Task Management

  • Task CRUD: Comprehensive task management system
  • Priority Levels: Low, medium, high priority support
  • Assignment System: Assign tasks to team members
  • Due Date Tracking: Task deadline management
  • Status Management: Track task completion status

๐Ÿ’ฌ Communication & Collaboration

  • Real-time Chat: Project-based chat system
  • Comment System: Task and project commenting
  • Collaboration Requests: Send and manage collaboration invitations
  • Notification System: User notifications for various events

๐Ÿ—ฃ๏ธ Community Features

  • Discussion Forums: Topic-based discussion system
  • Pre-defined Topics: Default topics for common developer subjects
  • Community Engagement: Public discussion participation

๐Ÿ› ๏ธ Technical Features

  • TypeScript: Full TypeScript support with strict type checking
  • MongoDB Integration: Mongoose ODM with MongoDB
  • File Upload: Cloudinary integration for image storage
  • Email Services: Nodemailer-based email functionality
  • Input Validation: Zod schema validation
  • Middleware System: Authentication and validation middleware
  • Error Handling: Comprehensive error handling and logging

๐Ÿ—๏ธ Architecture

Project Structure

dev-server/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/                 # Express app configuration
โ”‚   โ”œโ”€โ”€ controllers/         # Business logic controllers
โ”‚   โ”œโ”€โ”€ middleware/          # Custom middleware functions
โ”‚   โ”œโ”€โ”€ models/              # MongoDB/Mongoose models
โ”‚   โ”œโ”€โ”€ routes/              # API route definitions
โ”‚   โ”œโ”€โ”€ schemas/             # Zod validation schemas
โ”‚   โ”œโ”€โ”€ types/               # TypeScript type definitions
โ”‚   โ”œโ”€โ”€ utils/               # Utility functions
โ”‚   โ”œโ”€โ”€ app.ts              # Express app setup
โ”‚   โ””โ”€โ”€ server.ts           # Server entry point
โ”œโ”€โ”€ tests/                   # Test suite (Jest + Supertest)
โ”œโ”€โ”€ dist/                    # Compiled JavaScript output
โ”œโ”€โ”€ package.json             # Dependencies and scripts
โ”œโ”€โ”€ tsconfig.json           # TypeScript configuration
โ””โ”€โ”€ README.md               # This file

Technology Stack

  • Runtime: Node.js
  • Framework: Express.js 5.x
  • Language: TypeScript 5.x
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT (JSON Web Tokens)
  • Validation: Zod schema validation
  • File Storage: Cloudinary
  • Email: Nodemailer
  • Testing: Jest + Supertest
  • Development: Nodemon + ts-node-dev

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • MongoDB instance (local or cloud)
  • Cloudinary account (for file uploads)
  • Gmail account (for email services)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd devcollab/dev-server
  2. Install dependencies

    npm install
  3. Environment Configuration

    cp env.example .env

    Fill in your environment variables:

    PORT=5000
    MONGO_URI=mongodb://localhost:27017/devcollab
    JWT_SECRET=your-super-secret-jwt-key
    EMAIL_USER=your-gmail@gmail.com
    EMAIL_APP_PASSWORD=your-gmail-app-password
    CLOUDINARY_CLOUD_NAME=your-cloud-name
    CLOUDINARY_API_KEY=your-api-key
    CLOUDINARY_API_SECRET=your-api-secret
  4. Database Setup

    • Ensure MongoDB is running
    • The application will automatically create collections
  5. Start Development Server

    npm run dev

Available Scripts

  • npm run dev - Start development server with hot reload
  • npm run build - Build TypeScript to JavaScript
  • npm start - Start production server
  • npm test - Run test suite
  • npm run test:watch - Run tests in watch mode
  • npm run test:coverage - Generate test coverage report

๐Ÿ“š API Documentation

Base URL

http://localhost:5000/v1/api

Authentication

All protected routes require a valid JWT token in the Authorization header:

Authorization: Bearer <your-jwt-token>

Endpoints

๐Ÿ” Authentication (/auth)

Method Endpoint Description Auth Required
POST /register User registration No
POST /login User login No
GET /verify-email/:token Email verification No
POST /resend-verification Resend verification email No
GET /profile Get current user profile Yes
GET /users/:id Get user by ID Yes
PUT /users/:id Update user profile Yes
DELETE /users/:id Delete user account Yes

๐Ÿ“ Projects (/project)

Method Endpoint Description Auth Required
GET / Get user's projects Yes
GET /:projectId Get project by ID Yes
POST /create Create new project Yes
PUT /update/:projectId Update project Yes
DELETE /:projectId Delete project Yes
DELETE /:projectId/:collaboratorId Remove collaborator Yes

๐Ÿ“‹ Tasks (/task)

Method Endpoint Description Auth Required
GET / Get user's tasks Yes
GET /:taskId Get task by ID Yes
POST /create Create new task Yes
PUT /update/:taskId Update task Yes
DELETE /:taskId Delete task Yes

๐Ÿ’ฌ Comments (/comment)

Method Endpoint Description Auth Required
GET /:commentId Get comment by ID Yes
POST /create Create new comment Yes
PUT /update/:commentId Update comment Yes
DELETE /:commentId Delete comment Yes

๐Ÿ—ฃ๏ธ Discussions (/discussion)

Method Endpoint Description Auth Required
GET / Get all discussions No
GET /:discussionId Get discussion by ID No
POST /create Create new discussion Yes
PUT /update/:discussionId Update discussion Yes
DELETE /:discussionId Delete discussion Yes
POST /:discussionId/topic Add new topic Yes
POST /:discussionId/discussion Add discussion text Yes

๐Ÿ”” Notifications (/notification)

Method Endpoint Description Auth Required
GET / Get user notifications Yes
PUT /:notificationId/read Mark as read Yes
DELETE /:notificationId Delete notification Yes

๐Ÿ’ญ Chat (/chat)

Method Endpoint Description Auth Required
POST /send Send message Yes
GET /conversation/:userId Get conversation Yes
GET /conversations Get all conversations Yes

๐Ÿค Collaboration (/collaboration)

Method Endpoint Description Auth Required
POST /request Send collaboration request Yes
GET /requests Get collaboration requests Yes
PUT /accept/:requestId Accept request Yes
PUT /reject/:requestId Reject request Yes

๐Ÿ—„๏ธ Data Models

User Model

interface IUser {
  name: string;
  image?: string;
  email: string;
  password: string;
  isVerified: boolean;
  verificationToken?: string;
  verificationExpires?: Date;
  projects?: ObjectId[];
  createdAt: Date;
  updatedAt: Date;
}

Project Model

interface IProject {
  title: string;
  description: string;
  owner: ObjectId;
  collaborators: ObjectId[];
  createdAt: Date;
  updatedAt: Date;
}

Task Model

interface ITask {
  title: string;
  description: string;
  assignees?: ObjectId[];
  project: ObjectId;
  createdBy: ObjectId;
  dueDate?: Date;
  priority: 'low' | 'medium' | 'high';
  comments: ObjectId[];
  createdAt: Date;
  updatedAt: Date;
}

Discussion Model

interface IDiscussion {
  name: string;
  description: string;
  topics: string[];
  discussion: string[];
  createdAt: Date;
  updatedAt: Date;
}

๐Ÿ”’ Security Features

  • JWT Authentication: Secure token-based authentication
  • Password Hashing: Bcrypt password encryption
  • Input Validation: Zod schema validation for all inputs
  • CORS Protection: Configurable CORS settings
  • Rate Limiting: Built-in Express rate limiting
  • SQL Injection Protection: MongoDB with parameterized queries
  • XSS Protection: Input sanitization and validation

๐Ÿงช Testing

The project includes a comprehensive test suite:

  • Unit Tests: Individual function testing
  • Integration Tests: API endpoint testing
  • Test Coverage: Jest coverage reporting
  • Test Utilities: Helper functions for test data creation
  • Database Testing: Isolated test database environment

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

๐Ÿš€ Deployment

Production Build

npm run build
npm start

Environment Variables for Production

  • Set NODE_ENV=production
  • Use strong JWT secrets
  • Configure production MongoDB URI
  • Set up production email services
  • Configure production Cloudinary settings

Docker Support

The project can be containerized using Docker:

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 5000
CMD ["npm", "start"]

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

๐Ÿ“ License

This project is licensed under the ISC License.

๐Ÿ†˜ Support

For support and questions:

  • Create an issue in the repository
  • Check the troubleshooting guide
  • Review the API documentation

๐Ÿ”ฎ Future Enhancements

  • Real-time WebSocket support
  • Advanced search and filtering
  • File sharing system
  • Project templates
  • Advanced analytics
  • Mobile app support
  • Third-party integrations
  • Advanced permission system

DevCollab - Empowering developers to collaborate effectively! ๐Ÿš€

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages