How marcusolsson/obsidian-projects works
The provided project is an Obsidian plugin that helps users manage projects by visualizing notes in different views (Table, Board, Calendar, Gallery, Developer, etc.). The codebase is split between core logic (data-handling, file system interaction, datasources, metadata, etc.), and a rich, Svelte-based user interface. With multiple layers of abstraction, the system is designed to integrate seamlessly with Obsidian’s native environment and to offer several customizable views and tools for project management.
Main Components
• Plugin Entry Point & Integration:
– Highlight src/main.ts which boots up the plugin.
– Include integration points with Obsidian (e.g., src/obsidianProjects.d.ts and src/lib/obsidian.ts) which bridge the plugin with the Obsidian API.
• Core Library (Data & Business Logic):
– In the src/lib directory, you have several submodules:
– Datasources: Under src/lib/datasources, there are dedicated modules for dataview, folder, frontmatter, and tag. These represent how data is extracted and standardized.
– Filesystem: Handling both in-memory (inmem) and Obsidian-specific filesystem integrations.
– Metadata: Encoding/decoding metadata from notes.
– Stores: Managing state for capabilities, custom views, settings, translations, and events.
– Templates and Helpers: For processing note templates and utility functions.
• User Interface (UI):
– The src/ui directory contains a rich Svelte-based frontend.
– UI/views: Separate directories for each view (Board, Calendar, Gallery, Table, Developer) with components for layout, options, settings, and interactions.
– UI/app: Main application components like App.svelte, onboarding, toolbar, and view switching.
– UI/components and UI/modals: Specific reusable widgets and modal dialogs.
– UI/settings: Components for adjusting user settings.
• Configuration, Testing, and Build Infrastructure:
– Build/build config files (esbuild.config.mjs, jest.config.js)
– Testing mocks (__mocks__), TypeScript configurations, and shared project settings.
– Continuous integration and release workflows in the .github directory.
Relationships and Interactions
• The Plugin Launch:
– The plugin is initialized via src/main.ts, which registers commands and integrates with Obsidian.
• Data Flow between Modules:
– The UI layer (Svelte components) interacts with the core logic through the stores (found in src/lib/stores) to fetch, update, and reflect project data.
– The datasources modules provide abstraction to fetch notes data from different sources (e.g., dataview queries, folder structures, front matter, and tags). Their output is standardized and fed into the user interface.
• State & Event Handling:
– Events and state updates are managed by the events module (src/events.ts) and the stores, ensuring a reactive UI.
• File/Data Persistence:
– The filesystem modules (both in-memory and Obsidian integrated) handle reading and writing operations, ensuring that the plugin does not leave any persistent configuration traces in the user’s notes (in line with the “leave no trace” design philosophy).
Architectural Patterns and Design Principles
• Modular Architecture: Each concern is isolated—datasources, filesystem integration, metadata handling, and UI component rendering are all encapsulated in their respective modules.
• Separation of Concerns: UI components (Svelte files), business logic (lib and settings), and plugin integration (main.ts and Obsidian APIs) are clearly segregated.
• Native Experience: The project emphasizes native usage of Obsidian’s APIs and a familiar UI experience for consistency.
• Testability: The presence of __mocks__ and Jest configurations underscores an architecture that values robust testing.
– A top-level view that starts with Obsidian’s environment, through which the plugin is loaded (from manifest.json to src/main.ts).
– A breakdown of the Plugin Core:
• Data Management Cluster (comprising datasources, filesystem, metadata).
• State Handling and Business Logic (stores and events).
– A separate yet interacting cluster for the User Interface:
• Main Application view, with decomposed sub-components (views, modals, and smaller UI components).
– Interconnections between these clusters should show the data flow and event propagation.
– Annotation of integration points with external platforms (like the native Obsidian API) and testing/infrastructure aspects (CI workflows, build scripts).