RefMD is a modern, real-time collaborative markdown editor with advanced features for document management, sharing, and team collaboration. Built with a Rust backend and Next.js frontend, it provides a robust platform for creating and editing markdown documents with live synchronization.
- Real-time Collaborative Editing: Multiple users can edit documents simultaneously with instant synchronization
- CRDT-based Conflict Resolution: Uses Yjs/Yrs for robust conflict-free replicated data types ensuring consistency
- User Authentication: Secure JWT-based authentication with refresh tokens
- Document Management: Create, edit, delete, and organize documents with folder structure
- Scrap Functionality: Thread-based collaborative memo spaces for discussions and quick notes
- File Attachments: Upload and manage images and files within documents
- Document Sharing: Share documents with specific users or generate public share links
- Live User Presence: See who's online, their cursor positions, and active selections
- Rich Markdown Support: Full GitHub-flavored markdown with extensions
- Live Preview: Side-by-side markdown editor and preview pane
- Syntax Highlighting: Code blocks with language-specific highlighting
- Table of Contents: Auto-generated, navigable table of contents
- File Drag & Drop: Drag files directly into the editor to upload
- Mermaid Diagrams: Render Mermaid diagrams directly in documents
- PlantUML Support: Create UML diagrams with PlantUML syntax
- CSV Preview: Render CSV files as formatted tables
- Alert Blocks: GitHub-style alert blocks (note, tip, important, warning, caution)
- Real-time Cursors: See other users' cursor positions and selections
- Connection Status: Visual indicators for connection and sync status
- Awareness Protocol: Track user presence and activity
- Persistent Sessions: Rejoin documents with maintained state
- Thread-based Discussions: Create collaborative spaces for team discussions and brainstorming
- Post Management: Add, edit, delete, and pin posts with rich markdown support
- Comment System: Nested comments on individual posts for detailed discussions
- Real-time Collaboration: Multiple users can contribute simultaneously with live updates
- User Presence: See active participants and their contributions
- Public Sharing: Share scraps publicly via secure tokens
- Metadata Support: Pin important posts and track user contributions
- Framework: Axum web framework
- Database: PostgreSQL with SQLx
- CRDT: Yrs (Rust implementation of Yjs)
- WebSockets: Socket.IO via socketioxide
- Authentication: JWT with Argon2 password hashing
- File Storage: Local filesystem with configurable upload directory
- Framework: Next.js 15 with React 19
- Editor: Monaco Editor (VS Code editor)
- Markdown: react-markdown with custom plugins
- Styling: Tailwind CSS with shadcn/ui components
- Real-time: Socket.IO client with Yjs provider
- State Management: React Context API
- API Client: Auto-generated TypeScript client from OpenAPI spec
- Containerization: Docker with multi-stage builds
- Database Migrations: SQLx migrate
- API Documentation: OpenAPI 3.0 specification
- Docker and Docker Compose (recommended)
- OR for native development:
- Rust 1.75+
- Node.js 18+
- PostgreSQL 15+
- pnpm (recommended) or npm
- Clone the repository:
git clone <repository-url>
cd refmd
- Start the application:
docker-compose up -d
This will start:
- PostgreSQL database on port 5432
- Rust API server on port 8888
- Next.js frontend on port 3000
Access the application at http://localhost:3000
Start PostgreSQL:
docker-compose up -d postgres
Or use your local PostgreSQL installation.
cd api
# Create .env file
cat > .env << EOF
DATABASE_URL=postgresql://refmd:refmd@localhost:5432/refmd
PORT=8888
JWT_SECRET=your-secret-key-change-this-in-production
JWT_EXPIRY=3600
REFRESH_TOKEN_EXPIRY=604800
BCRYPT_COST=12
UPLOAD_MAX_SIZE=10485760
UPLOAD_DIR=../documents
EOF
# Run migrations
cargo install sqlx-cli
sqlx migrate run
# Start the backend
cargo run
cd app
# Create .env.local file
cat > .env.local << EOF
NEXT_PUBLIC_API_URL=http://localhost:8888/api
NEXT_PUBLIC_SOCKET_URL=http://localhost:8888
NEXT_PUBLIC_SITE_URL=http://localhost:3000
EOF
# Install dependencies
pnpm install
# Start the frontend
pnpm dev
- Navigate to http://localhost:3000
- Click "Sign Up" and create an account
- Sign in with your credentials
- Create Document: Click "New Document" in the dashboard
- Edit Document: Click on any document to open the editor
- Delete Document: Use the context menu on document cards
- Organize: Documents support parent-child relationships for folder structure
- Create Scrap: Click "New Scrap" to create a thread-based discussion space
- Add Posts: Click "Add Post" to contribute to the discussion
- Pin Posts: Use the pin icon to highlight important posts
- Comment: Add nested comments to individual posts for detailed discussions
- Share Scraps: Generate public share links for external collaboration
- Real-time Updates: See live updates as team members contribute
- Open a document
- Click "Share" in the toolbar
- Add collaborators by email or generate a public link
- Collaborators see real-time changes and cursor positions
- Drag and drop files into the editor
- Or use the upload button in the toolbar
- Supports images, CSVs, and other file types
- Files are stored securely and accessible only to authorized users
- users: User accounts and authentication
- documents: Document metadata and content (includes scraps)
- document_updates: CRDT update history for synchronization
- scrap_posts: Individual posts within scrap threads
- attachments: File attachment metadata
- shares: Document sharing permissions
- user_tokens: Refresh token management
/api/auth/*
: Authentication endpoints/api/documents/*
: Document CRUD operations/api/scraps/*
: Scrap management and post operations/api/files/*
: File upload and retrieval/api/shares/*
: Sharing management/socket.io/*
: WebSocket connections for real-time sync
- JWT-based authentication with refresh tokens
- Argon2 password hashing
- Permission-based access control
- Secure file uploads with type validation
- CORS protection
Backend tests:
cd api
cargo test
Frontend tests:
cd app
pnpm test
Using Docker:
docker-compose -f docker-compose.yml up -d
Manual build:
# Backend
cd api
cargo build --release
# Frontend
cd app
pnpm build
DATABASE_URL
: PostgreSQL connection stringPORT
: API server port (default: 8888)JWT_SECRET
: Secret key for JWT signingJWT_EXPIRY
: Access token expiry in secondsREFRESH_TOKEN_EXPIRY
: Refresh token expiry in secondsBCRYPT_COST
: Argon2 hashing costUPLOAD_MAX_SIZE
: Maximum file upload size in bytesUPLOAD_DIR
: Directory for file uploads
NEXT_PUBLIC_API_URL
: Backend API URLNEXT_PUBLIC_SOCKET_URL
: Socket.IO server URLNEXT_PUBLIC_SITE_URL
: Frontend application URL
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Backend: Follow Rust standard formatting (
cargo fmt
) - Frontend: ESLint and Prettier configuration included
MIT License - see LICENSE file for details
- Yjs - CRDT framework
- Monaco Editor - Code editor
- shadcn/ui - UI components
- Socket.IO - Real-time communication