System Architecture
Umo Office Convert is a document conversion service built with Node.js and Express. It converts various office documents into formats supported by Umo Office Viewer. The system integrates MySQL to persist conversion task information, supports cross-origin access, and provides Swagger API documentation.
Architecture Components
- Application service:
Expressprovides HTTP APIs. - Routing layer:
src/routesincludes base routes, conversion routes, and OpenAPI documentation routes. - Conversion engine: converts Office documents into formats supported by Umo Office Viewer.
- Database:
MySQLstores conversion tasks (table:convert_tasks). You can replace it with another database. See: Database. - Storage: supports local filesystem or network object storage.
- Configuration: configured via environment variables (
.env). See: Environment Variables. - Authentication & security: file size limits and MIME type validation. See: Security & Compliance.
- Documentation: Swagger API documentation (mounted at
/openapiin non-production). See: API Documentation. - Logging: the log directory is configured via the
LOG_DIRenvironment variable (PM2 optional).
Main Data Flow
- An uploaded document or a document provided via path/URL is stored under
UPLOAD_DIR(if configured). - The service generates an ID for the task and writes it to the
convert_taskstable (status transitions: uploaded → converted/failed). - The document conversion engine converts the document.
- The result file is written under
CONVERTED_DIR. - The service returns the file stream and includes metadata in response headers (such as
X-Task-Id). - You can download the converted file or the original file via
/convert/{taskId}. - If
CONVERTED_WEBHOOK_URLis configured, callbacks will be sent at the corresponding stages with conversion information.
Key Paths and Modules
src/index.mjs: application entry, middleware and route mountingsrc/routes/base.mjs: basic health routesrc/routes/convert.mjs: upload/convert/download and cachingsrc/routes/openapi.mjs: Swagger UIsrc/utils/mysql.mjs: MySQL connection and table initializationsrc/utils/env.mjs: environment variable loading
Deployment Topology
- Single service instance (PM2 / container)
- External MySQL service (recommended)
- Mount persistent volumes: upload directory, converted file storage directory, and log storage directory
Performance & Scalability
- Use caching (based on file hash) to avoid duplicate conversions.
- Move storage to object storage (such as S3) to reduce disk IO pressure.
- Use Nginx proxying and rate-limiting strategies to protect the service.
Observability
- Standardized log directory (
LOG_DIR) and PM2 log collection - Record key exceptions
Security Highlights
- Limit upload file size (
MAX_FILE_SIZE). - Validate MIME type and file extension consistency.
- Handle paths and URLs to avoid directory traversal and SSRF risks.