ProjectOS is a scalable, collaborative work management platform that bridges the gap between structured task management (Jira), real-time communication (Slack), and centralized documentation (Notion).
Built with modern technologies, it offers a robust backend for real-time collaboration, secure authentication, efficient project tracking, and seamless file sharing powered by Cloudinary.
- JWT-Based Auth: Secure session management using Access and Refresh tokens.
- Role-Based Access: Granular control for different user roles within projects.
- Password Safety: Industry-standard encryption using
bcryptfor all user credentials.
- Full CRUD Support: Seamlessly create, update, and manage project lifecycles.
- Member Collaboration: Add and remove members to projects with ease.
- Activity Tracking: Real-time logging of project-related activities to keep teams informed.
- Scoped Rooms: Automatic creation of project-specific communication channels via Socket.io.
- Dynamic Task Assignment: Assign tasks to multiple project members with clear ownership.
- Smart Updates: Real-time status synchronization across all connected team members.
- History Logs: Detailed trail of task modifications, including assignee and status changes.
- Project-Specific Chat: Secure messaging within project rooms using Socket.io.
- History Retrieval: Efficient loading of chat history with pagination for optimized performance.
- Real-time Indicators: Visual cues for typing status (
typing:start,typing:stop). - Message Management: Support for editing and soft-deleting messages with historical transparency.
- @Mentions & Notifications: Tag team members using
@usernamesyntax with real-time in-app notifications.
- In-Chat Attachments: Send files (images, documents, videos, etc.) directly alongside chat messages.
- Cloudinary-Powered Storage: Automatic upload and CDN delivery via Cloudinary with
resource_type: 'auto'for universal file support. - Base64 Transport: Files are sent as Base64-encoded strings over Socket.io for seamless real-time delivery.
- Persistent File Records: Every uploaded file is stored in a dedicated
Filemodel with full metadata tracking (original name, MIME type, size, URL). - Project-Scoped Files: All uploads are linked to a specific project and the uploading user for auditability.
- Soft Delete Support: Files can be soft-deleted without losing historical data.
- Interactive Swagger Docs: Fully documented REST API endpoints for easy testing and integration.
- Centralized Validation: Robust input sanitization and schema validation using Joi.
- Error Handling: Unified error management for consistent and helpful API responses.
We leverage a modern and robust stack to ensure performance, scalability, and security.
| Category | Technologies |
|---|---|
| Backend | |
| Database | |
| Real-time | |
| Caching/Security | |
| File Storage | |
| Documentation | |
| Validation |
Follow these steps to get the project running locally on your machine.
Ensure you have the following installed:
(v16.x or higher)
(Local or Atlas)
(Required for rate limiting)
- A free
account (Sign up here)
-
Clone the Repository
git clone <repository-url> cd ProductionGraded
-
Install Dependencies
npm install
-
Environment Setup Create a
.envfile in the root directory and add the following variables:# Server PORT=5001 # Database MONGO_URI=mongodb://127.0.0.1:27017/ProjectOS_DB # Authentication ACCESS_TOKEN_SECRET=your_access_token_secret REFRESH_TOKEN_SECRET=your_refresh_token_secret # Admin Seed ADMIN_EMAIL=admin@projectos.com ADMIN_PASSWORD=your_admin_password # Cloudinary (Required for File Uploads) CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
💡 How to get Cloudinary credentials:
- Create a free account at cloudinary.com.
- Navigate to the Dashboard after logging in.
- Copy the Cloud Name, API Key, and API Secret from the dashboard.
-
Start the Project For development with automatic restarts:
npm run start
Once the server is running, you can access the interactive API documentation at:
http://localhost:5001/api-docs
This allows you to test endpoints directly from your browser.
This section provides a comprehensive guide to the File Upload system integrated into ProjectOS's real-time chat.
┌──────────────┐ Base64 via ┌──────────────┐ Upload API ┌──────────────┐
│ │ Socket.io │ │ │ │
│ Client │ ──────────────► │ Server │ ────────────► │ Cloudinary │
│ │ │ (chatHandler)│ │ (CDN) │
│ │ ◄────────────── │ │ ◄────────── │ │
│ │ chat:receive │ │ secure_url │ │
└──────────────┘ └──────┬───────┘ └──────────────┘
│
│ Save metadata
▼
┌──────────────┐
│ MongoDB │
│ (File + │
│ Message) │
└──────────────┘
- Client sends a
chat:sendevent with anattachmentsarray containing Base64-encoded files. - Server validates room membership (user must be in the
project:{projectId}room). - For each attachment, the server:
- Uploads the Base64 data to Cloudinary using
resource_type: 'auto'(images, videos, PDFs, etc.). - Creates a
Filedocument in MongoDB storing the metadata (URL, MIME type, size, original name).
- Uploads the Base64 data to Cloudinary using
- A
Messagedocument is created with the text content and an array ofFilereference IDs in theattachmentsfield. - The complete message (with attachment references) is broadcast to all clients in the room via
chat:receive.
Event: chat:send
{
"projectId": "64f1a2b3c4d5e6f7a8b9c0d1",
"content": "Here are the design mockups for the homepage",
"attachments": [
{
"base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"originalName": "homepage-v2.png",
"mimeType": "image/png",
"size": 245760
},
{
"base64": "data:application/pdf;base64,JVBERi0xLjQKJcfs...",
"originalName": "design-spec.pdf",
"mimeType": "application/pdf",
"size": 1048576
}
]
}Event: chat:receive
{
"_id": "67c1d4e5f6a7b8c9d0e1f2a3",
"projectId": "64f1a2b3c4d5e6f7a8b9c0d1",
"senderId": "65a2b3c4d5e6f7a8b9c0d1e2",
"content": "Here are the design mockups for the homepage",
"attachments": [
"67c1d4e5f6a7b8c9d0e1f2a4",
"67c1d4e5f6a7b8c9d0e1f2a5"
],
"editedAt": null,
"deletedAt": null,
"createdAt": "2026-03-09T05:30:00.000Z",
"updatedAt": "2026-03-09T05:30:00.000Z"
}📝 Note: The
attachmentsarray contains MongoDB ObjectId references toFiledocuments. Clients should populate these to display file details (name, URL, type).
Every uploaded file is persisted with the following schema in MongoDB:
| Field | Type | Description |
|---|---|---|
projectId |
ObjectId (ref: Project) | The project this file belongs to |
uploadedBy |
ObjectId (ref: User) | The user who uploaded the file |
originalName |
String | Original filename provided by the client |
storageName |
String | Cloudinary public_id for the uploaded asset |
url |
String | Cloudinary secure_url (HTTPS CDN link) |
mimeType |
String | File MIME type (e.g., image/png, application/pdf) |
size |
Number | File size in bytes |
deletedAt |
Date | null | Soft-delete timestamp (null = active) |
createdAt |
Date | Auto-generated creation timestamp |
updatedAt |
Date | Auto-generated update timestamp |
Indexes:
projectId— Quick lookup by projectuploadedBy— Quick lookup by uploaderdeletedAt— Filter soft-deleted files- Compound:
{ projectId: 1, createdAt: -1 }— Efficient chronological queries per project
Cloudinary is configured in src/config/cloudinary.js using environment variables:
import { v2 as cloudinary } from 'cloudinary';
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});The upload utility in src/utils/cloudinary.utils.js uses resource_type: 'auto' to automatically detect and handle any file type — images, videos, documents, and raw files:
const options = {
folder: 'chat_attachments', // All uploads go to this Cloudinary folder
resource_type: 'auto', // Auto-detect: image, video, or raw
};
const result = await cloudinary.uploader.upload(base64Data, options);
// result.secure_url → HTTPS CDN URL
// result.public_id → Unique Cloudinary identifier
// result.bytes → File size
// result.format → Detected file format| Concern | How It's Handled |
|---|---|
| Unauthorized uploads | Only authenticated users in a project room can send files |
| Room validation | Server checks socket.rooms.has(room) before processing |
| File metadata integrity | Client-provided metadata is supplemented with Cloudinary's own detection |
| Soft deletion | Files are never permanently removed; deletedAt timestamp is set |
Since Cloudinary's resource_type: 'auto' is used, the following file categories are supported:
| Category | Examples |
|---|---|
| Images | PNG, JPG, JPEG, GIF, SVG, WebP, BMP, TIFF |
| Videos | MP4, MOV, AVI, WebM, MKV |
| Documents | PDF, DOCX, XLSX, PPTX, TXT, CSV |
| Archives | ZIP, RAR, 7Z, TAR.GZ |
| Audio | MP3, WAV, OGG, FLAC |
To optimize Cloudinary storage over time, ProjectOS includes an automated background job (node-cron) that compresses older media files.
- Schedule: Runs automatically every day at
2:00 AM. - Target: Finds image and video files older than 1 month that haven't been compressed yet.
- Process:
- Re-uploads the asset to Cloudinary with
quality: 'auto:low'andfetch_format: 'auto'. - Deletes the old, uncompressed original asset to save space.
- Updates the
Filedocument in MongoDB with the newsecure_url,size, and flags it withisCompressed: true.
- Re-uploads the asset to Cloudinary with
- Exclusions: Raw files (documents like PDFs, ZIPs) are flagged and skipped, since Cloudinary transformations only apply to visual/audio media.
src/
├── config/ # Database, server, and Cloudinary configurations
│ ├── cloudinary.js # Cloudinary SDK initialization
│ ├── db.js # MongoDB connection setup
│ ├── redis.js # Redis client configuration
│ ├── socket.js # Socket.io server setup
│ └── swagger.js # Swagger/OpenAPI config
├── controllers/ # Request handlers
├── middlewares/ # Custom Express middlewares (Auth, Validation, Cache, etc.)
├── models/ # Mongoose schemas
│ ├── File.js # File metadata model (Cloudinary uploads)
│ ├── Message.js # Chat message model (with attachments ref)
│ ├── Project.js # Project model
│ ├── User.js # User model
│ └── ... # ActivityLog, Notification, ProjectMember, etc.
├── routes/ # API route definitions
├── service/ # Business logic and external integrations
│ └── messageService.js # Message CRUD + mention/notification logic
├── socket/ # Socket.io event handlers
│ ├── chatHandler.js # chat:send, chat:edit, chat:delete + file uploads
│ └── ...
├── utils/ # Helper functions
│ ├── cloudinary.utils.js # uploadToCloudinary() helper
│ ├── mention.utils.js # @mention parsing
│ └── ...
└── validators/ # Data validation schemas (Joi)
- Validation: Strict input validation using Joi schemas.
- Security: Password hashing with Bcrypt and JWT for session management.
- Optimization: Redis-based rate limiting to prevent API abuse.
- File Storage: Cloud-based file storage with Cloudinary CDN for fast delivery.
- Soft Deletes: Messages and files use
deletedAtpattern for data safety. - Activity Logging: Every significant action is logged for auditability.
- Formatting: ESLint and Prettier for consistent code style.
- Git Hooks: Husky + lint-staged for linting before commits.
- Commit Standards: Conventional commits enforced via CommitLint.
- Fork the project.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
Distributed under the ISC License.