An open API service indexing awesome lists of open source software.

https://github.com/arsh342/collabspace


https://github.com/arsh342/collabspace

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

# CollabSpace - Team Collaboration Platform

![CollabSpace Logo](https://via.placeholder.com/200x80/1e40af/ffffff?text=CollabSpace)

A comprehensive team collaboration platform built with Node.js, Express, MongoDB, and Socket.IO. CollabSpace provides real-time chat, task management, team organization, and file sharing capabilities for modern teams.

## ๐Ÿš€ Features

### Core Features

- **Real-time Team Chat** - Instant messaging with Socket.IO
- **Task Management** - Create, assign, and track tasks with Kanban boards
- **Team Organization** - Create teams, invite members, manage roles
- **File Sharing** - Upload and share files in chat and tasks
- **User Authentication** - Secure login with session management
- **Responsive Design** - Works on desktop, tablet, and mobile

### Advanced Features

- **Role-based Access Control** - Organizers and Members with different permissions
- **Real-time Notifications** - Live updates for messages, tasks, and team activities
- **Message Reactions** - React to messages with emojis
- **File Attachments** - Support for images, documents, and other files
- **Typing Indicators** - See when team members are typing
- **Online Status** - Track who's currently online
- **Search Functionality** - Search messages and tasks
- **Dashboard Analytics** - Overview of team activity and progress

## ๐Ÿ› ๏ธ Technology Stack

### Backend

- **Node.js** - Runtime environment
- **Express.js** - Web framework
- **MongoDB** - Database with Mongoose ODM
- **Socket.IO** - Real-time communication
- **JWT** - Authentication tokens
- **bcryptjs** - Password hashing
- **Multer** - File upload handling

### Frontend

- **EJS** - Template engine
- **Tailwind CSS** - Utility-first CSS framework
- **Vanilla JavaScript** - Client-side functionality
- **Font Awesome** - Icons
- **Socket.IO Client** - Real-time communication

### Development Tools

- **Nodemon** - Development server
- **PM2** - Production process manager
- **PostCSS** - CSS processing
- **Autoprefixer** - CSS vendor prefixes

## ๐Ÿ“ Project Structure

```
collabspace/
โ”œโ”€โ”€ src/ # Source code
โ”‚ โ”œโ”€โ”€ app.js # Main application entry point
โ”‚ โ”œโ”€โ”€ config/ # Configuration files
โ”‚ โ”‚ โ”œโ”€โ”€ database.js # MongoDB connection
โ”‚ โ”‚ โ””โ”€โ”€ jwt.js # JWT configuration
โ”‚ โ”œโ”€โ”€ middleware/ # Express middleware
โ”‚ โ”‚ โ”œโ”€โ”€ auth.js # Authentication middleware
โ”‚ โ”‚ โ”œโ”€โ”€ errorHandler.js # Error handling
โ”‚ โ”‚ โ”œโ”€โ”€ logger.js # Logging middleware
โ”‚ โ”‚ โ””โ”€โ”€ rateLimiter.js # Rate limiting
โ”‚ โ”œโ”€โ”€ models/ # Database models
โ”‚ โ”‚ โ”œโ”€โ”€ User.js # User model
โ”‚ โ”‚ โ”œโ”€โ”€ Team.js # Team model
โ”‚ โ”‚ โ”œโ”€โ”€ Task.js # Task model
โ”‚ โ”‚ โ”œโ”€โ”€ Message.js # Message model
โ”‚ โ”‚ โ””โ”€โ”€ TeamInvitation.js # Team invitation model
โ”‚ โ”œโ”€โ”€ routes/ # API routes
โ”‚ โ”‚ โ”œโ”€โ”€ auth.js # Authentication routes
โ”‚ โ”‚ โ”œโ”€โ”€ users.js # User management
โ”‚ โ”‚ โ”œโ”€โ”€ teams.js # Team management
โ”‚ โ”‚ โ”œโ”€โ”€ tasks.js # Task management
โ”‚ โ”‚ โ”œโ”€โ”€ chat.js # Chat functionality
โ”‚ โ”‚ โ”œโ”€โ”€ messages.js # Message handling
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard.js # Dashboard data
โ”‚ โ”‚ โ”œโ”€โ”€ invitations.js # Team invitations
โ”‚ โ”‚ โ”œโ”€โ”€ member-api.js # Member API endpoints
โ”‚ โ”‚ โ”œโ”€โ”€ member-api-simple.js # Simplified member API
โ”‚ โ”‚ โ””โ”€โ”€ upload.js # File upload handling
โ”‚ โ”œโ”€โ”€ views/ # EJS templates
โ”‚ โ”‚ โ”œโ”€โ”€ layouts/ # Layout templates
โ”‚ โ”‚ โ”œโ”€โ”€ partials/ # Reusable components
โ”‚ โ”‚ โ”œโ”€โ”€ index.ejs # Landing page
โ”‚ โ”‚ โ”œโ”€โ”€ login.ejs # Login page
โ”‚ โ”‚ โ”œโ”€โ”€ register.ejs # Registration page
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard.ejs # Main dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ organiser-dashboard.ejs # Organizer dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ member-dashboard.ejs # Member dashboard
โ”‚ โ”‚ โ””โ”€โ”€ [other pages].ejs # Additional pages
โ”‚ โ”œโ”€โ”€ public/ # Static assets
โ”‚ โ”‚ โ”œโ”€โ”€ css/ # Stylesheets
โ”‚ โ”‚ โ””โ”€โ”€ js/ # Client-side JavaScript
โ”‚ โ””โ”€โ”€ utils/ # Utility functions
โ”‚ โ””โ”€โ”€ dashboardSummary.js # Dashboard calculations
โ”œโ”€โ”€ uploads/ # File uploads directory
โ”œโ”€โ”€ logs/ # Application logs
โ”œโ”€โ”€ package.json # Dependencies and scripts
โ”œโ”€โ”€ tailwind.config.js # Tailwind CSS configuration
โ”œโ”€โ”€ postcss.config.js # PostCSS configuration
โ””โ”€โ”€ README.md # This file
```

## ๐Ÿš€ Getting Started

### Prerequisites

- Node.js (v18.0.0 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn

### Installation

1. **Clone the repository**

```bash
git clone https://github.com/yourusername/collabspace.git
cd collabspace
```

2. **Install dependencies**

```bash
npm install
```

3. **Environment Setup**
Create a `.env` file in the root directory:

```env
# Database
MONGODB_URI=mongodb://localhost:27017/collabspace

# JWT
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=7d

# Session
SESSION_SECRET=your-session-secret

# Server
PORT=3000
NODE_ENV=development

# File Upload
UPLOAD_PATH=./uploads
MAX_FILE_SIZE=5242880
```

4. **Start MongoDB**

```bash
# Using MongoDB service
sudo systemctl start mongod

# Or using Docker
docker run -d -p 27017:27017 --name mongodb mongo:latest
```

5. **Run the application**

```bash
# Development mode
npm run dev

# Production mode
npm start
```

6. **Access the application**
Open your browser and navigate to `http://localhost:3000`

## ๐Ÿ”ง Configuration

### Database Configuration

The application uses MongoDB with Mongoose ODM. Database connection is configured in `src/config/database.js`:

```javascript
const mongoose = require("mongoose");

const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGODB_URI);
console.log("MongoDB connected successfully");
} catch (error) {
console.error("Database connection error:", error);
process.exit(1);
}
};
```

### Authentication

- **Session-based authentication** for web interface
- **JWT tokens** for API access
- **Password hashing** with bcryptjs
- **Rate limiting** to prevent brute force attacks

### File Upload

- **Multer** for handling multipart/form-data
- **File type validation** for security
- **Size limits** to prevent abuse
- **Organized storage** in uploads directory

## ๐Ÿ“Š Database Schema

### User Model

```javascript
{
username: String (unique, required),
email: String (unique, required),
password: String (required),
firstName: String (required),
lastName: String (required),
avatar: String,
phone: String,
bio: String,
isOnline: Boolean,
lastSeen: Date,
createdAt: Date,
updatedAt: Date
}
```

### Team Model

```javascript
{
name: String (required),
description: String,
admin: ObjectId (ref: User),
members: [ObjectId] (ref: User),
avatar: String,
isPublic: Boolean,
lastActivity: Date,
lastMessage: ObjectId (ref: Message),
createdAt: Date,
updatedAt: Date
}
```

### Task Model

```javascript
{
title: String (required),
description: String,
team: ObjectId (ref: Team),
assignedTo: ObjectId (ref: User),
createdBy: ObjectId (ref: User),
status: String (enum: ['todo', 'in_progress', 'review', 'completed']),
priority: String (enum: ['low', 'medium', 'high']),
dueDate: Date,
attachments: [Object],
isArchived: Boolean,
createdAt: Date,
updatedAt: Date
}
```

### Message Model

```javascript
{
content: String (required),
team: ObjectId (ref: Team),
sender: ObjectId (ref: User),
messageType: String (enum: ['text', 'file', 'image', 'system']),
attachments: [Object],
reactions: [Object],
replyTo: Object,
mentions: [Object],
isEdited: Boolean,
editedAt: Date,
isDeleted: Boolean,
deletedAt: Date,
createdAt: Date,
updatedAt: Date
}
```

## ๐Ÿ”Œ API Endpoints

### Authentication

- `POST /api/auth/register` - User registration
- `POST /api/auth/login` - User login
- `POST /api/auth/logout` - User logout
- `GET /api/auth/me` - Get current user

### Users

- `GET /api/users` - Get all users
- `GET /api/users/:id` - Get user by ID
- `PUT /api/users/:id` - Update user
- `DELETE /api/users/:id` - Delete user

### Teams

- `GET /api/teams` - Get user's teams
- `POST /api/teams` - Create team
- `GET /api/teams/:id` - Get team details
- `PUT /api/teams/:id` - Update team
- `DELETE /api/teams/:id` - Delete team
- `POST /api/teams/:id/members` - Add team member
- `DELETE /api/teams/:id/members/:userId` - Remove team member

### Tasks

- `GET /api/tasks` - Get tasks
- `POST /api/tasks` - Create task
- `GET /api/tasks/:id` - Get task details
- `PUT /api/tasks/:id` - Update task
- `DELETE /api/tasks/:id` - Delete task

### Chat & Messages

- `GET /api/chat/conversations` - Get conversations
- `GET /api/chat/messages/:conversationId` - Get messages
- `POST /api/chat/messages` - Send message
- `PUT /api/chat/messages/:id` - Edit message
- `DELETE /api/chat/messages/:id` - Delete message

### File Upload

- `POST /api/upload` - Upload file
- `GET /api/files/:filename` - Get file

## ๐ŸŽจ User Interface

### Dashboard Types

1. **Organizer Dashboard** - Full access to team management
2. **Member Dashboard** - Limited access to assigned tasks and team chat

### Key UI Components

- **Navigation Sidebar** - Quick access to different sections
- **Team Chat Interface** - Real-time messaging with file support
- **Task Kanban Board** - Visual task management
- **Team Management** - Create and manage teams
- **User Profile** - Account settings and preferences

## ๐Ÿ”’ Security Features

- **Password Hashing** - bcryptjs with salt rounds
- **Session Management** - Secure session storage
- **Rate Limiting** - Prevent abuse and DDoS attacks
- **Input Validation** - Sanitize and validate all inputs
- **File Upload Security** - Type and size validation
- **CORS Configuration** - Control cross-origin requests
- **Helmet.js** - Security headers

## ๐Ÿš€ Deployment

### Production Setup

1. **Environment Variables**

```env
NODE_ENV=production
MONGODB_URI=mongodb://your-production-db
JWT_SECRET=your-production-jwt-secret
SESSION_SECRET=your-production-session-secret
```

2. **Using PM2**

```bash
npm run prod # Start with PM2
npm run stop # Stop PM2 process
npm run restart # Restart PM2 process
```

3. **Using Docker**
```dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
```

### Deployment Platforms

- **Heroku** - Easy deployment with buildpacks
- **DigitalOcean** - VPS deployment
- **AWS EC2** - Scalable cloud deployment
- **Docker** - Containerized deployment

## ๐Ÿงช Testing

### Manual Testing

- User registration and login
- Team creation and management
- Task creation and assignment
- Real-time chat functionality
- File upload and sharing

### Test Scripts

```bash
# Test database connection
node test-app.js

# Test date handling
node test-createdAt.js
```

## ๐Ÿ“ Development Guidelines

### Code Style

- Use ES6+ features
- Follow async/await pattern
- Implement proper error handling
- Add comprehensive logging
- Write descriptive comments

### Git Workflow

- Feature branches for new development
- Pull requests for code review
- Semantic commit messages
- Regular merges to main branch

## ๐Ÿค Contributing

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

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ†˜ Support

For support and questions:

- Create an issue on GitHub
- Check the documentation
- Review the code comments
- Contact the development team

## ๐Ÿ”ฎ Future Enhancements

- **Video Conferencing** - Integrated video calls
- **Calendar Integration** - Task scheduling and deadlines
- **Mobile App** - React Native or Flutter app
- **Advanced Analytics** - Team performance metrics
- **Third-party Integrations** - Slack, Discord, GitHub
- **AI Features** - Smart task suggestions and chat bots

---

**CollabSpace** - Bringing teams together, one collaboration at a time! ๐Ÿš€