# CodiMD CLI Harness - Standard Operating Procedure ## Overview CodiMD is a collaborative markdown editor built on Node.js with real-time collaboration via Socket.IO. This document defines the standard operating procedure for building a CLI harness for CodiMD. ## Architecture Summary ### Technology Stack - **Backend**: Node.js with Express - **Real-time**: Socket.IO - **Database**: Sequelize ORM (supports PostgreSQL, MySQL, MariaDB, SQLite, MSSQL) - **Authentication**: Multiple providers (Facebook, Google, GitHub, Dropbox, Twitter, GitLab, LDAP, SAML, OAuth2, Email) ### Data Models #### Note - `id` (UUID): Primary key - `shortid`: Short unique identifier for sharing - `alias`: Custom URL alias - `permission`: One of: freely, editable, limited, locked, protected, private - `viewcount`: Number of views - `title`: Note title (extracted from content) - `content`: Markdown content - `authorship`: JSON array tracking contributions - `lastchangeAt`: Last modification timestamp - `savedAt`: Last save timestamp #### User - `id` (UUID): Primary key - `profileid`: External profile ID - `profile`: JSON profile data - `history`: User history - `accessToken`: OAuth access token - `refreshToken`: OAuth refresh token - `deleteToken`: Token for account deletion - `email`: User email - `password`: Hashed password #### Revision - `id` (UUID): Primary key - `patch`: Diff-match-patch format - `lastContent`: Previous content snapshot - `content`: Full content at revision time - `length`: Content length - `authorship`: Authorship tracking ### Permission Model | Permission | Description | |------------|-------------| | `freely` | Anyone can view and edit | | `editable` | Anyone can view, logged-in users can edit | | `limited` | Logged-in users can view and edit | | `locked` | Anyone can view, only owner can edit | | `protected` | Logged-in users can view, only owner can edit | | `private` | Only owner can view and edit | ## CLI Architecture ### Command Groups #### 1. Note Commands (`note`) - `note list` - List user's notes - `note get ` - Get note content - `note create` - Create new note - `note update ` - Update note content - `note delete ` - Delete note - `note publish ` - Get publish link - `note info ` - Get note metadata #### 2. User Commands (`user`) - `user me` - Get current user info - `user export` - Export user data - `user delete` - Delete user account #### 3. Export Commands (`export`) - `export markdown [file]` - Export as markdown - `export pdf [file]` - Export as PDF (if enabled) - `export html [file]` - Export as HTML #### 4. Revision Commands (`revision`) - `revision list ` - List note revisions - `revision get