How leonhfr/mochi works
Main Components
a. CLI Application Layer
• Entry point through cmd/cli
• Handles user interactions and commands
• Connects to the core synchronization logic
b. GitHub Action Layer
• Separate entry point through cmd/github-action
• Handles automation and CI/CD integration
• Processes inputs and outputs for GitHub Actions
c. Core Service Layer (Internal)
• Action: Handles core operations (dump, load, sync)
• Parser: Processes markdown files
• Converter: Transforms parsed content
• Deck: Manages card collections
• Worker: Handles background tasks and file operations
d. Mochi API Client Layer
• Located in /mochi directory
• Handles API communication with Mochi service
• Manages cards, decks, and templates
e. Supporting Systems
• Configuration management
• File handling
• Request throttling
• Locking mechanism
[User/GitHub Actions]
• ↓
[Entry Points (CLI/GitHub Action)]
• ↓
[Core Services Layer]
• ↓
[Mochi API Client]
• ↓
[External Mochi Service]
Component Relationships
Key interactions:
• File system interactions (markdown files ↔ parser)
• Configuration flow (config → all components)
• API communication flow (client → external service)
• Worker orchestration (worker → various components)
Important Details
a. Data Flow
• Markdown files → Parser → Converter → Mochi Cards
• Configuration → System Components
• API Requests → Throttling → External Service
b. Key Subsystems
• Parser subsystem (headings, notes, tables, vocabulary)
• Converter transformations
• Worker pipeline
• Request handling and throttling
Architectural Patterns to Highlight
• Pipeline pattern in the conversion process
• Worker pattern for background tasks
• Repository pattern for deck management
• Service layer pattern for core operations
The role of supporting systems (throttling, locking, configuration)
• Component types and their visual representations
• Any abbreviations used
This system design should provide a clear understanding of how the tool processes markdown files and synchronizes them with Mochi cards, while highlighting the key architectural decisions and patterns used in the implementation.