How codesmith28/lazyai works
Main Components
• Entry Point & Application Core: The main.go file in the lazyAi directory acts as the application’s entry point.
• TUI Dashboard: The “panes” directory contains various files (e.g., apiWindow.go, historyPane.go, inputPane.go, outputPane.go, modelsPane.go, promptPane.go, keybindingsPane.go, sysNavPane.go, layout.go, theme.go) that together build the interactive dashboard.
• Internal Business Logic: The “internal” directory holds several important modules:
• Clipboard Module: Located in internal/clipboard for managing clipboard operations.
• History Manager: Found in internal/history to manage past interactions.
• Query Maker: Inside internal/queryMaker with the logic to build queries for the AI.
• Models & Utility: Various files like internal/models.go and internal/loc.go handle data representations and supplementary logic.
• API Integration: The “api” directory contains files (api.go, analytics.go, checkCred.go) for managing interactions with external AI services, analytics tracking, and possibly credential checking.
• Public Assets & Configurations: The “public” directory is used for assets like screenshots, and there are also configuration files such as go.mod, go.sum, and GitHub Actions config in .github.
Relationships and Interactions
• The entry point (main.go) initializes the TUI dashboard and connects all modules.
• The TUI panes interact with the internal modules (e.g., the clipboard module to detect copied text, history module to log interactions, and query maker to format requests).
• When new text is detected (via the clipboard module), the request is passed to the API layer which is responsible for sending the request to the AI service.
• The response from the API is then routed back to the TUI for display (in the outputPane) and may also be re-copied to the clipboard.
• There is integration with external libraries (e.g., clipboard by atotto, tview for TUI management, tcell for terminal control) that enhance the functionality.
Architectural Patterns & Design Principles
• Separation of Concerns: The code structure divides responsibilities among a clear set of directories (e.g., UI logic under panes, business logic under internal, API integrations under api).
• Modularity: Components are encapsulated in their respective packages, which facilitates easier maintenance and potential future enhancements.
• Event-Driven: Clipboard events trigger the processing flow—clipboard monitoring initiates query creation, API calls, and UI updates.
• Dependency Isolation: The modular structure ensures that external dependencies and third-party libraries are used in appropriate modules.