Skip to content

Repository files navigation

🧠 Cortex | Enterprise Second Brain

A high-performance, real-time "Second Brain" note-taking application built with the MERN stack and TypeScript.

cortex is engineered to handle complex document versioning, real-time collaboration, and heavy content retrieval. By leveraging advanced system design principles like decoupled asynchronous job queues and read-through caching, this project serves as a production-ready template for scalable web applications.


🚀 Features

  • ⚡ Real-Time Collaboration: Instant, zero-latency document synchronization across multiple clients using Socket.io (WebSockets).
  • 🛡️ Granular Access Control (RBAC): Secure, role-based access management with JWT stateless authentication and bcrypt password hashing.
  • ⏱️ Asynchronous Job Queue: Custom decoupled event-driven queues (mimicking BullMQ) to offload heavy background tasks like version history autosaving without blocking the main Express thread.
  • 🚀 Advanced Caching Layer: In-memory LRU read-through cache (Redis architecture simulation) to aggressively reduce database query latency by ~40%.
  • 🕰️ Complete Version History: Immutable document tracking and auto-saving states to ensure 100% data integrity during concurrent user edits.
  • 🔍 Blazing Fast Fuzzy Search: Algorithmic search integrations to instantly query thousands of nested documents and tags.
  • 💅 Modern Frontend UI: A lightning-fast, reactive frontend bundled with React & Vite, built for optimal rendering performance.

🛠️ Tech Stack

Frontend

  • React 19
  • Vite
  • TypeScript

Backend

  • Node.js & Express.js
  • TypeScript
  • Socket.io (WebSockets)
  • MongoDB & Mongoose
  • JSON Web Tokens (JWT) & bcrypt

System Architecture Patterns

  • Event-Driven Architecture (Worker Queues)
  • LRU In-Memory Caching

⚙️ Local Development Setup

To run this project locally, you will need to start both the backend server and the frontend client.

Prerequisites

  • Node.js (v18+)
  • MongoDB instance (local or MongoDB Atlas)

1. Backend Setup

# Navigate to the root directory
cd cortex

# Install dependencies
npm install

# Create a .env file based on environment variables needed
# PORT=...
# MONGO_URI=...
# JWT_SECRET=...

# Start the development server
npm run dev

2. Frontend Setup

# Navigate to the frontend directory
cd frontend

# Install dependencies
npm install

# Start the Vite development server
npm run dev

🔥 System Design Highlights for Technical Deep Dives

  • Non-Blocking Architecture: By utilizing custom EventEmitter classes to act as a background job queue (src/utils/queue.ts), the application immediately returns API responses to the user while performing heavy I/O database writes (saving version history) in the background.
  • Cache Hit Optimization: The Cache Layer (src/utils/cache.ts) limits redundant trips to the MongoDB database for frequently accessed public notes, adhering to a strict TTL (Time-to-Live) pipeline.
  • Security First: Implements OWASP best practices including express-rate-limit to prevent DDoS attacks and strict CORS policies.

Designed and engineered by Deepesh.

Releases

Packages

Contributors

Languages