feat: integrate CoreDoc documentation system
- Add CoreDoc maintenance documentation (8 files) - Create route module for documentation serving - Set up static file structure with symbolic links - Support dual documentation systems (Legacy WASM + New Modular) Documentation includes: - README.md: System overview - DIRECTORY_STRUCTURE.md: Complete directory mapping - ARCHITECTURE.md: System design and data flow - MAINTENANCE_GUIDE.md: Daily maintenance procedures - INTEGRATION_GUIDE.md: Integration details - API_REFERENCE.md: All API endpoints - INTEGRATION_REPORT.md: Complete integration report - QUICK_START.md: Quick reference for team Route module: markbase-core/src/api/docs.rs - /docs/legacy/* → Legacy WASM system - /docs/api/* → API documentation - /docs/cli/* → CLI documentation Static files: - static/docs/legacy -> momentry_core/docs_v1.0/doc_wasm/ - static/docs/api -> momentry_core/docs_v1.0/API_WORKSPACE/ - static/docs/cli -> momentry_core/docs_v1.0/CLI_WORKSPACE/ Pending: Manual route addition to server.rs Team: Markbase team to complete integration
This commit is contained in:
@@ -0,0 +1,586 @@
|
||||
---
|
||||
title: CoreDoc API Reference
|
||||
version: 1.0.0
|
||||
date: 2026-10-25
|
||||
author: Momentry Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
# CoreDoc API Reference
|
||||
|
||||
## Overview
|
||||
|
||||
This document provides a complete reference for all CoreDoc API endpoints, including the legacy WASM system and new modular documentation systems.
|
||||
|
||||
---
|
||||
|
||||
## Authentication
|
||||
|
||||
All CoreDoc endpoints require HTTP Basic Authentication.
|
||||
|
||||
**Headers**:
|
||||
```
|
||||
Authorization: Basic base64(username:password)
|
||||
```
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/
|
||||
```
|
||||
|
||||
**Default Credentials**:
|
||||
- Username: `admin`
|
||||
- Password: `admin123`
|
||||
|
||||
---
|
||||
|
||||
## Base URL
|
||||
|
||||
```
|
||||
http://localhost:11438/docs/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Legacy WASM System Endpoints
|
||||
|
||||
### GET /docs/legacy/
|
||||
|
||||
**Description**: Main UI for legacy documentation system
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/html`
|
||||
- Status: 200 OK
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/legacy/
|
||||
```
|
||||
|
||||
**HTML Content**:
|
||||
- Sidebar with module list
|
||||
- Content viewer
|
||||
- WASM integration script
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/legacy/modules/
|
||||
|
||||
**Description**: List of documentation modules (directory listing)
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/html` (auto-generated directory index)
|
||||
- Status: 200 OK
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/legacy/modules/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/legacy/modules/{module_name}
|
||||
|
||||
**Description**: Retrieve a specific documentation module
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Parameters**:
|
||||
- `module_name` (path): Module filename (e.g., `001_Auth_v1.3.5.md`)
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/markdown`
|
||||
- Status: 200 OK or 404 Not Found
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
# Get specific module
|
||||
curl -u admin:admin123 http://localhost:11438/docs/legacy/modules/001_Auth_v1.3.5.md
|
||||
|
||||
# Response:
|
||||
# # Authentication API
|
||||
#
|
||||
# ## Overview
|
||||
# ...
|
||||
```
|
||||
|
||||
**Available Modules**: 68 total
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/legacy/pkg/md_wasm_bg.wasm
|
||||
|
||||
**Description**: WASM binary for Markdown rendering
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `application/wasm`
|
||||
- Status: 200 OK
|
||||
- Size: 291KB
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/legacy/pkg/md_wasm_bg.wasm \
|
||||
--output md_wasm_bg.wasm
|
||||
```
|
||||
|
||||
**Usage**:
|
||||
```javascript
|
||||
// Load WASM
|
||||
const module = await import('/docs/legacy/pkg/md_wasm.js');
|
||||
await module.default();
|
||||
|
||||
// Use render function
|
||||
const html = module.render(markdown_text);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/legacy/pkg/md_wasm.js
|
||||
|
||||
**Description**: JavaScript bindings for WASM
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `application/javascript`
|
||||
- Status: 200 OK
|
||||
- Size: 7.2KB
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/legacy/pkg/md_wasm.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/legacy/logout.html
|
||||
|
||||
**Description**: Logout page
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/html`
|
||||
- Status: 200 OK
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/legacy/logout.html
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Documentation Endpoints
|
||||
|
||||
### GET /docs/api/
|
||||
|
||||
**Description**: API documentation home
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/html` (auto-generated index)
|
||||
- Status: 200 OK
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/api/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/api/modules/{module_name}
|
||||
|
||||
**Description**: Retrieve API documentation module
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Parameters**:
|
||||
- `module_name` (path): Module filename (e.g., `001_Auth_API.md`)
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/markdown`
|
||||
- Status: 200 OK or 404 Not Found
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/api/modules/001_Auth_API.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## CLI Documentation Endpoints
|
||||
|
||||
### GET /docs/cli/
|
||||
|
||||
**Description**: CLI documentation home
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/html` (auto-generated index)
|
||||
- Status: 200 OK
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/cli/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### GET /docs/cli/modules/{module_name}
|
||||
|
||||
**Description**: Retrieve CLI documentation module
|
||||
|
||||
**Authentication**: Required
|
||||
|
||||
**Parameters**:
|
||||
- `module_name` (path): Module filename (e.g., `101_Register_CLI.md`)
|
||||
|
||||
**Response**:
|
||||
- Content-Type: `text/markdown`
|
||||
- Status: 200 OK or 404 Not Found
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -u admin:admin123 http://localhost:11438/docs/cli/modules/101_Register_CLI.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## WASM JavaScript API
|
||||
|
||||
### render(markdown: string) → string
|
||||
|
||||
**Description**: Render Markdown to HTML using WASM
|
||||
|
||||
**Parameters**:
|
||||
- `markdown` (string): Markdown text
|
||||
|
||||
**Returns**:
|
||||
- HTML string
|
||||
|
||||
**Example**:
|
||||
```javascript
|
||||
import init, { render } from '/docs/legacy/pkg/md_wasm.js';
|
||||
|
||||
// Initialize WASM
|
||||
await init();
|
||||
|
||||
// Render Markdown
|
||||
const markdown = '# Hello World\n\nThis is **bold**.';
|
||||
const html = render(markdown);
|
||||
|
||||
console.log(html);
|
||||
// Output: <h1>Hello World</h1>\n<p>This is <strong>bold</strong>.</p>
|
||||
```
|
||||
|
||||
**Supported Features**:
|
||||
- CommonMark standard
|
||||
- GFM tables
|
||||
- Code blocks
|
||||
- HTML tags (sanitized)
|
||||
|
||||
---
|
||||
|
||||
## Response Formats
|
||||
|
||||
### Successful Response
|
||||
|
||||
**Headers**:
|
||||
```
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: text/markdown
|
||||
Content-Length: 1234
|
||||
Cache-Control: public, max-age=3600
|
||||
```
|
||||
|
||||
**Body**:
|
||||
```markdown
|
||||
# Documentation Content
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Error Responses
|
||||
|
||||
#### 401 Unauthorized
|
||||
|
||||
**Headers**:
|
||||
```
|
||||
HTTP/1.1 401 Unauthorized
|
||||
WWW-Authenticate: Basic realm="CoreDoc"
|
||||
Content-Type: text/plain
|
||||
```
|
||||
|
||||
**Body**:
|
||||
```
|
||||
Unauthorized
|
||||
```
|
||||
|
||||
**Cause**: Missing or invalid authentication
|
||||
|
||||
---
|
||||
|
||||
#### 404 Not Found
|
||||
|
||||
**Headers**:
|
||||
```
|
||||
HTTP/1.1 404 Not Found
|
||||
Content-Type: text/plain
|
||||
```
|
||||
|
||||
**Body**:
|
||||
```
|
||||
Not Found
|
||||
```
|
||||
|
||||
**Cause**: Requested module does not exist
|
||||
|
||||
---
|
||||
|
||||
#### 500 Internal Server Error
|
||||
|
||||
**Headers**:
|
||||
```
|
||||
HTTP/1.1 500 Internal Server Error
|
||||
Content-Type: text/plain
|
||||
```
|
||||
|
||||
**Body**:
|
||||
```
|
||||
Internal Server Error
|
||||
```
|
||||
|
||||
**Cause**: Server-side error
|
||||
|
||||
---
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
**Current Status**: No rate limiting
|
||||
|
||||
**Recommendation**: Implement rate limiting for production:
|
||||
- 100 requests per minute per user
|
||||
- 1000 requests per minute per IP
|
||||
|
||||
---
|
||||
|
||||
## CORS Configuration
|
||||
|
||||
**Current Headers**:
|
||||
```
|
||||
Access-Control-Allow-Origin: *
|
||||
Access-Control-Allow-Methods: GET, OPTIONS
|
||||
Access-Control-Allow-Headers: Authorization
|
||||
```
|
||||
|
||||
**Preflight Requests**:
|
||||
```bash
|
||||
curl -X OPTIONS http://localhost:11438/docs/ \
|
||||
-H "Access-Control-Request-Method: GET" \
|
||||
-H "Origin: http://example.com"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Content Types
|
||||
|
||||
| File Type | Content-Type | Extension |
|
||||
|-----------|--------------|-----------|
|
||||
| Markdown | `text/markdown` | `.md` |
|
||||
| HTML | `text/html` | `.html` |
|
||||
| WASM | `application/wasm` | `.wasm` |
|
||||
| JavaScript | `application/javascript` | `.js` |
|
||||
|
||||
---
|
||||
|
||||
## Caching
|
||||
|
||||
### Browser Caching
|
||||
|
||||
**Headers**:
|
||||
```
|
||||
Cache-Control: public, max-age=3600
|
||||
ETag: "abc123"
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
```bash
|
||||
curl -u admin:admin123 \
|
||||
-H "If-None-Match: abc123" \
|
||||
http://localhost:11438/docs/legacy/modules/001_Auth_v1.3.5.md
|
||||
|
||||
# Response: 304 Not Modified (if ETag matches)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Complete Endpoint List
|
||||
|
||||
| Method | Endpoint | Description | Auth |
|
||||
|--------|----------|-------------|------|
|
||||
| GET | `/docs/legacy/` | Main UI | ✅ |
|
||||
| GET | `/docs/legacy/modules/` | Module list | ✅ |
|
||||
| GET | `/docs/legacy/modules/{name}` | Get module | ✅ |
|
||||
| GET | `/docs/legacy/pkg/md_wasm_bg.wasm` | WASM binary | ✅ |
|
||||
| GET | `/docs/legacy/pkg/md_wasm.js` | JS bindings | ✅ |
|
||||
| GET | `/docs/legacy/logout.html` | Logout page | ✅ |
|
||||
| GET | `/docs/api/` | API docs home | ✅ |
|
||||
| GET | `/docs/api/modules/{name}` | API module | ✅ |
|
||||
| GET | `/docs/cli/` | CLI docs home | ✅ |
|
||||
| GET | `/docs/cli/modules/{name}` | CLI module | ✅ |
|
||||
|
||||
---
|
||||
|
||||
## SDK Examples
|
||||
|
||||
### JavaScript/TypeScript
|
||||
|
||||
```javascript
|
||||
class CoreDocClient {
|
||||
constructor(baseUrl, username, password) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.auth = btoa(`${username}:${password}`);
|
||||
}
|
||||
|
||||
async getModule(system, moduleName) {
|
||||
const response = await fetch(
|
||||
`${this.baseUrl}/docs/${system}/modules/${moduleName}`,
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Basic ${this.auth}`
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
async getLegacyModule(moduleName) {
|
||||
return this.getModule('legacy', moduleName);
|
||||
}
|
||||
|
||||
async getApiModule(moduleName) {
|
||||
return this.getModule('api', moduleName);
|
||||
}
|
||||
|
||||
async getCliModule(moduleName) {
|
||||
return this.getModule('cli', moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
// Usage
|
||||
const client = new CoreDocClient('http://localhost:11438', 'admin', 'admin123');
|
||||
const module = await client.getLegacyModule('001_Auth_v1.3.5.md');
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Python
|
||||
|
||||
```python
|
||||
import requests
|
||||
from base64 import b64encode
|
||||
|
||||
class CoreDocClient:
|
||||
def __init__(self, base_url, username, password):
|
||||
self.base_url = base_url
|
||||
self.auth = b64encode(f"{username}:{password}".encode()).decode()
|
||||
self.headers = {'Authorization': f'Basic {self.auth}'}
|
||||
|
||||
def get_module(self, system, module_name):
|
||||
url = f"{self.base_url}/docs/{system}/modules/{module_name}"
|
||||
response = requests.get(url, headers=self.headers)
|
||||
response.raise_for_status()
|
||||
return response.text
|
||||
|
||||
def get_legacy_module(self, module_name):
|
||||
return self.get_module('legacy', module_name)
|
||||
|
||||
def get_api_module(self, module_name):
|
||||
return self.get_module('api', module_name)
|
||||
|
||||
def get_cli_module(self, module_name):
|
||||
return self.get_module('cli', module_name)
|
||||
|
||||
# Usage
|
||||
client = CoreDocClient('http://localhost:11438', 'admin', 'admin123')
|
||||
module = client.get_legacy_module('001_Auth_v1.3.5.md')
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Rust
|
||||
|
||||
```rust
|
||||
use reqwest::blocking::Client;
|
||||
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
|
||||
|
||||
pub struct CoreDocClient {
|
||||
client: Client,
|
||||
base_url: String,
|
||||
auth: String,
|
||||
}
|
||||
|
||||
impl CoreDocClient {
|
||||
pub fn new(base_url: &str, username: &str, password: &str) -> Self {
|
||||
let auth = BASE64.encode(format!("{}:{}", username, password));
|
||||
Self {
|
||||
client: Client::new(),
|
||||
base_url: base_url.to_string(),
|
||||
auth,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_module(&self, system: &str, module_name: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let url = format!("{}/docs/{}/modules/{}", self.base_url, system, module_name);
|
||||
let response = self.client
|
||||
.get(&url)
|
||||
.header("Authorization", format!("Basic {}", self.auth))
|
||||
.send()?;
|
||||
|
||||
Ok(response.text()?)
|
||||
}
|
||||
|
||||
pub fn get_legacy_module(&self, module_name: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||
self.get_module("legacy", module_name)
|
||||
}
|
||||
}
|
||||
|
||||
// Usage
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let client = CoreDocClient::new("http://localhost:11438", "admin", "admin123");
|
||||
let module = client.get_legacy_module("001_Auth_v1.3.5.md")?;
|
||||
println!("{}", module);
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Related Documents
|
||||
|
||||
- [Integration Guide](./INTEGRATION_GUIDE.md) - How to integrate CoreDoc
|
||||
- [Architecture](./ARCHITECTURE.md) - System design
|
||||
- [Maintenance Guide](./MAINTENANCE_GUIDE.md) - API maintenance
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0.0 | 2026-10-25 | Initial API reference |
|
||||
Reference in New Issue
Block a user