How galihlprakoso/logseq-plugin-assistseq-ai-assistant works
Project type and purpose
• This is a Logseq plugin (“AssistSeq”) built with React + TypeScript + Vite, intended to run embedded inside the Logseq desktop/web app.
File structure
• Top level:
• config files (.eslintrc.json, tailwind.config.js, vite.config.ts, etc.)
• README, demo assets, package.json, lockfile
• src/ hierarchy:
• screens – top‑level UI entry points (MainScreen, Onboarding, Terms)
• modules/chat – UI components (ChatBubble), state (useChatStore), hooks (useChat), prompts/constants
• modules/langchain – React context provider, hooks, abstractions for document retrievers, storage adapters, tools (cheerio, Tavily, LogSeq search)
• modules/logseq – adapters to the Logseq host API (services: get‑current‑page, append‑block, get‑graph; hooks for settings/UI control; stores for settings)
• modules/navigation, modules/shared – shared UI components (Card, DiagramRenderer, MarkdownRenderer), service helpers (copy to clipboard), navigation store
• Build & deployment: Vite (vite.config.ts), PostCSS, tailwind, CI/CD workflows (GitHub Actions), release tooling.
README for additional insights
• Core features: Contextual conversation, smart visualization, search engine integration, web scraping
• Supported external LLM providers
1. Browser/Logseq Host Environment
– Loads the plugin’s index.html + bundled JS (main.tsx → App.tsx)
– Exposes the Logseq JS API
2. UI Layer (React)
– screens/ (MainScreen, Onboarding, Terms)
– chat components (ChatBubble), navigation view, shared components (Card, MarkdownRenderer, DiagramRenderer, LoadingIndicator)
3. State & Business Logic
– Chat Store & Hooks (useChatStore, useChat)
– LangChain Context Provider & Hooks (useLangChain)
– Settings Store, Navigation Store
4. Data Access & Services
– modules/logseq/services: get‑current‑page, get‑documents, append block, get‑graph
– modules/langchain/libs/document-retrievers: LogSeqRelatedDocumentRetriever
– modules/langchain/tools: web scrapper (cheerio), Tavily search, Logseq query
– modules/langchain/libs/storage: LocalStorageStore
5. External Systems
– Logseq App (graph + plugin host API)
– LLM Providers (OpenAI, Gemini, Ollama, Groq)
– Tavily Search Engine API
– Third‑party websites (for web scraping)
b. Relationships & data flow
1. User interacts with the React UI →
2. UI invokes Chat Hooks →
3. Chat Hooks call LangChain Hooks / Context →
4. LangChain orchestrates:
• Retriever fetches Logseq context via Logseq services
• Optionally scrapes web pages or calls Tavily
• Aggregates context, stores scratch data (LocalStorage)
• Sends request to selected LLM provider → receives response
6. For persistence/updates, services call Logseq API to append blocks or update pages
c. Architectural patterns & principles
• Component-based UI (React)
• Context Providers (LangChainContextProvider) for cross‑cutting concerns
• Hooks + Zustand-like stores for state management (separation of state from view)
• Clear separation of concerns: UI / state / domain logic (retrievers, tools) / external interfaces
d. Key technologies & libraries
• React + TypeScript + Vite + Tailwind CSS
• Zustand or custom store hooks for state
• LangChain abstractions for LLM orchestration
• Cheerio for DOM parsing (web scraping)
• Tavily API for search
• Logseq JavaScript Plugin API for host integration
Summary & detail level
• Expose the key data paths: Logseq content ingestion, context assembly, LLM invocation, result rendering, page updates.
• Major configuration/build nodes (Vite bundler, Tailwind) off to the side if needed.