Open Source Developer Tools 1 vues

Stop Losing Code Notes! Host CodiMD and Own Your Data

M
Mohamed IDBRAHIM
Auteur
Stop Losing Code Notes! Host CodiMD and Own Your Data

Stop Losing Code Notes! Host CodiMD and Own Your Data

Ever watched your team's critical documentation vanish into a proprietary black hole? One acquisition, one pricing change, one API shutdown—and years of collaborative knowledge evaporate overnight. Developers everywhere are waking up to a brutal reality: the tools you don't control, control you.

Enter CodiMD, the open-source powerhouse that lets you host real-time collaborative markdown↗ Smart Converter notes on your own terms. Built from the same DNA as HackMD—the beloved editor used by thousands of developer communities—CodiMD hands you the keys to your data kingdom. No vendor lock-in. No sneaky price hikes. Just pure, self-hosted collaboration that moves at the speed of your ideas.

In this deep dive, you'll discover why engineering teams are racing to deploy CodiMD, how to get your instance running in under 10 minutes, and the advanced tricks that separate amateur deployments from production-grade setups. Whether you're documenting APIs, running incident response, or building a knowledge base that outlasts your tenure, this guide exposes everything you need to know.

Ready to stop renting your team's brain and start owning it? Let's get technical.


What is CodiMD? The Open-Source HackMD You Control

CodiMD is the free, open-source software version of HackMD, the real-time collaborative markdown editor↗ Smart Converter that took developer documentation by storm. Born from the same codebase but stripped of commercial licensing constraints, CodiMD represents a philosophical commitment: your team's knowledge belongs to you, not a SaaS provider.

The HackMD team deliberately maintains CodiMD as a parallel project—think of it as HackMD's rebellious twin. While HackMD chases enterprise features like granular permission controls and book mode for commercial customers, CodiMD stays laser-focused on what open communities actually need: frictionless real-time editing, diagram support, and complete data sovereignty.

Here's where it gets interesting. The name itself carries battle scars. "CodiMD" emerged from a community discussion about naming confusion—originally, both projects shared the "HackMD" name, causing deployment nightmares and identity crises. The rebranding to CodiMD ("Community" + "HackMD") clarified the ecosystem: HackMD for managed commercial use, CodiMD for self-hosted freedom.

Why it's trending now: The 2020s have been a wake-up call for developer tooling independence. Notion's API changes, Confluence's pricing explosions, and Google Docs' enterprise lock-in have fueled a mass migration toward self-hosted alternatives. CodiMD rides this wave with mature WebSocket-based real-time collaboration, broad browser support, and a Docker↗ Bright Coding Blog deployment so smooth it feels like cheating. The project actively maintains CI/CD pipelines, translation communities, and Matrix/Gitter chat channels—signals of a healthy, sustainable open-source project.

For teams handling sensitive documentation—financial services, healthcare, government, or any organization with compliance requirements—CodiMD isn't just convenient. It's non-negotiable.


Key Features That Make CodiMD Irresistible

Let's dissect what separates CodiMD from glorified text editors pretending to be collaboration tools.

Real-Time Collaborative Editing via WebSockets

CodiMD leverages operational transformation algorithms over persistent WebSocket connections. Multiple users edit the same document simultaneously with millisecond-level synchronization. The conflict resolution happens server-side, meaning you won't see the janky "whoever saves last wins" behavior that plagues simpler tools. Cursor positions, selections, and edits propagate in real time—critical for pair programming sessions or incident war rooms where every second counts.

Full Markdown with Extended Syntax

Beyond standard CommonMark, CodiMD supports:

  • GitHub-flavored markdown (tables, task lists, strikethrough)
  • LaTeX mathematical expressions via MathJax
  • Mermaid diagrams for flowcharts, sequence diagrams, and Gantt charts
  • Graphviz for complex graph visualization
  • abc notation for music sheets

This isn't markdown as an afterthought. It's a documentation-native platform where diagrams live as code, version-controlled and diffable.

Multiple Presentation Modes

Transform the same source document into:

  • Edit mode for raw markdown composition
  • View mode for rendered reading
  • Slide mode for reveal.js-powered presentations
  • Book mode (HackMD exclusive; CodiMD focuses on core stability)

Granular Privacy Controls

Per-document settings control visibility:

  • Private: Owner-only access
  • Limited: Accessible via direct link
  • Editable: Community can edit
  • Freely: Full public access
  • Locked: Owner edits, everyone views

Self-Hosted Data Sovereignty

The killer feature isn't a feature—it's the absence of external dependencies. Your database, your asset storage, your authentication. CodiMD supports PostgreSQL↗ Bright Coding Blog, MySQL↗ Bright Coding Blog, MariaDB, and SQLite. Image uploads can route to local filesystem, S3-compatible storage, or Imgur. LDAP, OAuth2, SAML, and local authentication give you identity flexibility.

Broad Browser Compatibility

Production deployments need to support diverse user environments. CodiMD officially supports Chrome ≥47, Safari ≥9, Firefox ≥44, Edge ≥12, and Opera ≥34—including mobile variants. This isn't theoretical; the project maintains automated testing matrices validating these combinations.


Use Cases: Where CodiMD Destroys the Competition

1. Incident Response War Rooms

When production explodes at 3 AM, your team needs a single source of truth that updates faster than Slack threads fragment. CodiMD becomes the living incident document: timeline construction, command outputs, decision logs, and post-mortem drafts—all in one URL that refreshes in real time for every responder. No more "scroll up to find the current status."

2. API Design and Documentation

Engineering teams at scale use CodiMD for collaborative API specification. Write OpenAPI snippets in markdown code blocks, embed sequence diagrams showing auth flows, and iterate on endpoint designs with product managers watching live. The markdown source exports cleanly to static site generators for public documentation.

3. Remote Team Onboarding Playbooks

New hire onboarding dies in static wikis. With CodiMD, senior engineers co-author runbooks while new hires annotate with questions—in real time, without edit conflicts. The resulting document becomes a living artifact that improves with every cohort.

4. Academic and Research Collaboration

LaTeX math support makes CodiMD viable for technical paper drafts. Multiple authors edit sections simultaneously, embed figures via Mermaid, and maintain version history through the underlying Git integration. Self-hosting satisfies institutional data residency requirements that commercial tools fail.

5. Open Source Project Governance

Public CodiMD instances serve as community hubs: meeting notes anyone can observe, RFCs with inline commentary, and release planning documents that maintain transparency. The permission model lets core contributors lock critical sections while keeping discussion open.


Step-by-Step Installation & Setup Guide

CodiMD offers two deployment paths: Docker for immediate gratification, manual deployment for customization. We'll cover both.

Docker Deployment (Recommended for Production)

Prerequisites: Docker Engine 20.10+ and Docker Compose v2.

# Clone the official repository
git clone https://github.com/hackmdio/codimd.git
cd codimd

# Copy environment template
cp .env.example .env

# Edit critical variables
nano .env

Your .env file needs these minimum configurations:

# Database configuration (PostgreSQL recommended for production)
CMD_DB_URL=postgres://codimd:your_secure_password@postgres:5432/codimd

# Session secret - generate with: openssl rand -hex 32
CMD_SESSION_SECRET=replace_this_with_random_64_char_hex_string

# Domain configuration
CMD_DOMAIN=notes.yourcompany.com
CMD_PROTOCOL_USESSL=true

# Image upload backend (local filesystem for simplicity, S3 for scale)
CMD_IMAGE_UPLOAD_TYPE=filesystem
CMD_IMAGE_UPLOADS_PATH=./uploads

# Default document permissions
CMD_DEFAULT_PERMISSION=editable

Launch with Docker Compose:

# The official docker-compose.yml includes PostgreSQL and CodiMD services
docker-compose up -d

# Verify health
docker-compose ps
docker-compose logs -f codimd

Access your instance at http://localhost:3000 (or your configured domain).

Manual Deployment (For Developers and Custom Builds)

Prerequisites: Node.js 16+, npm 8+, and database server.

# Install system dependencies (Ubuntu/Debian example)
sudo apt-get update
sudo apt-get install -y build-essential git postgresql-client

# Clone and enter repository
git clone https://github.com/hackmdio/codimd.git
cd codimd

# Install Node dependencies
npm install

# Copy and configure environment
cp .env.example .env
# Edit .env with your database credentials and secrets

# Build frontend assets with webpack
npm run build

# Run database migrations
npm run migrate

# Start application
npm start

For development with hot reloading:

# Terminal 1: Webpack dev server
npm run dev

# Terminal 2: Node.js server
npm start

Database Connection Setup

CodiMD abstracts database access through Sequelize ORM. Supported configurations in .env:

# PostgreSQL (recommended)
CMD_DB_URL=postgres://user:pass@host:5432/database

# MySQL/MariaDB
CMD_DB_URL=mysql://user:pass@host:3306/database

# SQLite (development only)
CMD_DB_URL=sqlite://data/codimd.sqlite

For production PostgreSQL, create dedicated user and database:

-- Run in psql as superuser
CREATE USER codimd WITH PASSWORD 'your_secure_password';
CREATE DATABASE codimd OWNER codimd;
GRANT ALL PRIVILEGES ON DATABASE codimd TO codimd;

Reverse Proxy Configuration (Nginx)

server {
    listen 443 ssl http2;
    server_name notes.yourcompany.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # Critical for WebSocket real-time collaboration
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

The Upgrade and Connection headers are non-negotiable—without them, WebSocket connections fail and real-time editing degrades to manual refresh.


REAL Code Examples: From the CodiMD Repository

Let's examine actual patterns from CodiMD's architecture and configuration.

Example 1: Environment Configuration Structure

The .env.example from the repository reveals CodiMD's extensive customization:

# Core application settings
CMD_PORT=3000                          # HTTP server port
CMD_HOST=localhost                     # Bind address (0.0.0.0 for all interfaces)
CMD_PROTOCOL_USESSL=false              # Enable HTTPS redirects
CMD_URL_ADDPORT=false                  # Append port to generated URLs
CMD_USECDN=true                        # Serve assets from CDN (disable for air-gapped)

# Database configuration
CMD_DB_URL=                            # Full connection string (overrides individual vars)
CMD_DB_HOST=                           # Legacy: database hostname
CMD_DB_PORT=                           # Legacy: database port
CMD_DB_DATABASE=                       # Legacy: database name
CMD_DB_USERNAME=                       # Legacy: database user
CMD_DB_PASSWORD=                       # Legacy: database password

# Security
CMD_SESSION_SECRET=                    # 64-character hex for session signing
CMD_ALLOW_ANONYMOUS=true               # Enable editing without account
CMD_ALLOW_FREEURL=true                 # Allow custom note URLs
CMD_FORBIDDEN_NOTE_IDS=robots.txt      # Reserved URL slugs

# Upload configuration
CMD_IMAGE_UPLOAD_TYPE=imgur            # Options: imgur, s3, minio, filesystem, azure
CMD_IMAGE_UPLOADS_PATH=uploads/        # Local path when using filesystem

Key insight: CodiMD uses a cascading configuration system. CMD_DB_URL as a connection string takes precedence, but individual variables provide backward compatibility. The CMD_SESSION_SECRET requires cryptographically secure generation—never commit defaults to version control.

Example 2: Docker Compose Service Definition

From the official docker-compose.yml:

version: '3'
services:
  database:
    image: postgres:11.6-alpine
    environment:
      - POSTGRES_USER=codimd
      - POSTGRES_PASSWORD=change_password
      - POSTGRES_DB=codimd
    volumes:
      - "database-data:/var/lib/postgresql/data"
    restart: always

  codimd:
    image: nabo.codimd.dev/hackmdio/hackmd:2.4.1
    environment:
      - CMD_DB_URL=postgres://codimd:change_password@database:5432/codimd
      - CMD_USECDN=false
    depends_on:
      - database
    ports:
      - "3000:3000"
    volumes:
      - upload-data:/home/hackmd/app/public/uploads
    restart: always

volumes:
  database-data:
  upload-data:

Critical observations: The depends_on ensures database readiness before CodiMD starts, though production deployments should add health checks. Volume mounts persist data across container restarts—never run database containers without named volumes. The CMD_USECDN=false keeps assets local, essential for offline or compliance-restricted environments.

Example 3: Webpack Build Configuration

For developers customizing CodiMD, the build pipeline matters:

# From package.json scripts section
{
  "scripts": {
    "build": "webpack --config webpack.prod.js --progress",
    "dev": "webpack --config webpack.dev.js --watch --progress",
    "start": "node app.js",
    "migrate": "sequelize db:migrate"
  }
}

The dual webpack configuration separates development (with watch mode and source maps) from production (with minification and optimization). The sequelize db:migrate command runs database schema updates idempotently—safe to execute repeatedly without data loss.

Example 4: Authentication Provider Configuration

CodiMD supports multiple authentication strategies via Passport.js:

# LDAP authentication for enterprise integration
CMD_LDAP_URL=ldap://ldap.company.com
CMD_LDAP_BINDDN=cn=admin,dc=company,dc=com
CMD_LDAP_BINDCREDENTIALS=password
CMD_LDAP_SEARCHBASE=ou=users,dc=company,dc=com
CMD_LDAP_SEARCHFILTER=(uid={{username}})
CMD_LDAP_PROVIDERNAME=Company LDAP

# OAuth2 / OpenID Connect
CMD_OAUTH2_CLIENT_ID=your_client_id
CMD_OAUTH2_CLIENT_SECRET=your_client_secret
CMD_OAUTH2_AUTHORIZATION_URL=https://auth.company.com/oauth/authorize
CMD_OAUTH2_TOKEN_URL=https://auth.company.com/oauth/token
CMD_OAUTH2_USER_PROFILE_URL=https://auth.company.com/api/user

# SAML for SSO
CMD_SAML_IDPSSOURL=https://sso.company.com/saml/login
CMD_SAML_IDPCERT=/path/to/idp-cert.pem
CMD_SAML_ISSUER=codimd.company.com

Implementation pattern: CodiMD's authentication system chains strategies—if LDAP fails, it can fall through to local authentication based on CMD_ALLOW_EMAIL_REGISTER settings. This hybrid approach supports migration scenarios where you're transitioning from local accounts to centralized identity.


Advanced Usage & Best Practices

Performance Optimization

Database connection pooling: For teams above 50 concurrent editors, tune Sequelize pool settings via CMD_DB_URL query parameters:

CMD_DB_URL=postgres://user:pass@host/db?pool_max=20&pool_idle=10000

Redis for session storage: Replace in-memory sessions with Redis for horizontal scaling:

CMD_SESSION_SECRET=your_secret
# Add to configuration: session store backend
CMD_REDIS_URL=redis://redis:6379

Backup Strategy

Your notes are only as safe as your backups. Implement this 3-2-1 approach:

#!/bin/bash
# Automated daily backup script
DATE=$(date +%Y%m%d)
docker exec codimd_database_1 pg_dump -U codimd codimd > /backups/codimd-${DATE}.sql
tar czf /backups/codimd-uploads-${DATE}.tar.gz /var/lib/docker/volumes/codimd_upload-data/
# Sync to offsite storage
rclone sync /backups remote:codimd-backups

Security Hardening

  • Disable anonymous editing in production: CMD_ALLOW_ANONYMOUS=false
  • Restrict free URL creation to prevent squatting: CMD_ALLOW_FREEURL=false
  • Enable HSTS headers at your reverse proxy
  • Run database on internal network only, never expose port 5432 publicly
  • Rotate session secrets quarterly and force re-authentication

Monitoring Integration

Expose health metrics via application logs and integrate with your observability stack. The Node.js process exposes standard HTTP metrics suitable for Prometheus scraping with a simple exporter sidecar.


Comparison with Alternatives

Feature CodiMD HackMD (SaaS) Notion Confluence Etherpad
Self-hosted ✅ Full control ❌ Cloud-only ❌ Cloud-only ⚠️ Server license only ✅
Real-time collaboration ✅ WebSocket OT ✅ ✅ (limited) ❌ Lock-based ✅ Basic
Markdown native ✅ Core format ✅ ⚠️ Export only ❌ Proprietary ❌ Plain text
Diagram support ✅ Mermaid, Graphviz ✅ ⚠️ Embed only ⚠️ Plugin required ❌
LaTeX math ✅ MathJax ✅ ❌ ⚠️ Plugin ❌
Data sovereignty ✅ You own everything ⚠️ Export possible ❌ ⚠️ Server version ✅
Cost ✅ Free (self-hosted infra) $ Freemium $$$ Subscription $$$$ Enterprise ✅ Free
Open source ✅ AGPL ❌ Proprietary ❌ Proprietary ❌ Proprietary ✅ Apache
Active maintenance ✅ HackMD team ✅ Commercial ✅ Commercial ✅ Commercial ⚠️ Community

When to choose CodiMD over HackMD SaaS: Compliance requirements, data residency laws, cost predictability at scale, or customization needs. The trade-off is operational responsibility—you become your own SRE.

When to choose CodiMD over Notion/Confluence: Your team thinks in markdown, values version control, or needs real-time pair editing without lock-based conflicts.

When to choose CodiMD over Etherpad: You need rich formatting, diagrams, and presentation modes—not just colored cursors in plain text.


FAQ: CodiMD Answered

Is CodiMD completely free?

Yes. CodiMD is licensed under AGPL and free to use, modify, and distribute. You pay only for your own infrastructure. Commercial support isn't officially offered—community channels (Gitter, Matrix) provide assistance.

Can I migrate from HackMD to CodiMD?

Absolutely. HackMD provides bulk export functionality. Import markdown files into CodiMD via API or manual upload. For large migrations, script the process using CodiMD's undocumented but functional REST endpoints.

Does CodiMD support mobile editing?

Yes, through responsive web design. Native apps don't exist, but mobile browsers (iOS Safari ≥8.4, Chrome for Android ≥47) provide full functionality. The editing experience is optimized for tablets; phones work best for viewing.

How does CodiMD handle conflict resolution?

Operational transformation algorithms resolve concurrent edits server-side. Unlike Git's merge conflicts, OT guarantees convergence—no manual resolution needed. The worst case is temporary cursor jitter while synchronization completes.

What's the maximum document size?

Practical limits depend on your database and client hardware. PostgreSQL handles megabyte-scale documents fine. Browser rendering becomes sluggish beyond ~100KB of raw markdown. For monolithic documents, consider splitting or using book mode (HackMD exclusive).

Can I integrate CodiMD with CI/CD pipelines?

Yes, though not natively. Use the API to create documents from build outputs, or export markdown to static site generators (MkDocs, Hugo, Docusaurus) for versioned documentation. Webhook support isn't built-in but achievable with middleware.

Is CodiMD suitable for 1000+ users?

With proper infrastructure: yes. Scale horizontally behind a load balancer with sticky sessions for WebSocket affinity, use Redis for shared session state, and provision PostgreSQL with read replicas. The HackMD team has validated this architecture commercially.


Conclusion: Own Your Team's Knowledge or Rent It Forever

CodiMD represents more than a tool choice—it's a stance on digital autonomy. Every note your team creates in a proprietary platform becomes leverage for future price increases, feature removals, or acquisition-driven shutdowns. CodiMD breaks that cycle without sacrificing the real-time collaboration experience developers expect.

The deployment is approachable. The feature set is production-grade. The community is active and welcoming. Whether you're a solo developer documenting side projects or an engineering organization of hundreds, self-hosting CodiMD pays dividends in control, compliance, and cost predictability.

The repository awaits at github.com/hackmdio/codimd. Fork it, star it, deploy it—and never lose another critical document to someone else's business model. Your team's collective intelligence deserves a home you actually own.

Deploy today. Thank yourself tomorrow.

Commentaires 0

Aucun commentaire pour l'instant. Soyez le premier à réagir !

Laisser un commentaire