How gaurav-gosain/gollama works
Project Type & Purpose
• Gollama is a terminal application written in Go that provides both a chat TUI and CLI mode to interact with Ollama’s models.
• It combines chat functionalities, offline conversation history (with local SQLite storage as mentioned in the README), and Ollama model management (via the integrated Ollamanager library).
• External libraries (e.g., Bubble Tea for TUI, Glamour for markdown rendering, Lipgloss for style management) define much of the user interface and experience.
File Structure for Architectural Clues
• Top-level Files & Folders: You have general configuration files (.github workflows, Dockerfile, go.mod, go.sum) for CI/CD, containerization, and dependency management.
• Core Application Entry Points: main.go and ollamanager.go that likely kick off primary routines.
• internal/ Folder: Contains subdirectories such as:
• internal/api: Handles interactions with the Ollama API.
• internal/chat: Manages chat logic, conversation flows, and possibly handling session data (chat.go, keys.go, newchat.go).
• internal/client: Likely wraps client-side interactions with the Ollama server.
• internal/chatpicker: Manages the selection/display of chats.
• internal/roles and internal/utils: Provide modularized functionality and shared utilities.
• Additional files such as flags.go, generate.go, and tui.go suggest command-line flag parsing and terminal UI routines.
Key Components
a. Terminal User Interface (TUI):
• Build this component to include the chat interface.
• Chat display, chat picker, and modal management screens referenced in the README.
b. API & Client Integration:
• An API component for interacting with the Ollama servers.
• Internal/api module (handling requests/responses) in combination with internal/client.
• Dependency on Ollama’s official Go SDK, which can be wrapped in your client logic.
c. Model Management:
• Model management module, driven by the integrated Ollamanager library.
• This module handles installing, updating, and monitoring models.
d. Chat Management & Persistence:
• Although not explicitly detailed in the file tree, the README mentions storing previous conversations locally (SQLite).
• Demonstrate how chat sessions are saved, retrieved, and manipulated by the internal/chat and possibly other helper utilities.
e. External Dependencies/Services:
• External services such as the Ollama server (running either locally or remotely) as an external dependency that the client interacts with.
• That API interactions use the env variable (OLLAMA_HOST) for connectivity.
f. Build & Deployment:
• Components for CI/CD using GitHub Actions/workflows (from the .github/workflows directory).
• Mention containerization (Dockerfile and docker-publish.yml) which allow Gollama to be run in Docker.
• UI sends user commands/input to the chat logic (internal/chat) which then may call client functions (internal/client) to interact with the Ollama API.
• The model management section interacts with the external Ollamanager library for model installation and maintenance.
• Persistence (SQLite) receives data from chat sessions for future retrieval.
• Distinctly label components (e.g., “Chat TUI”, “API Wrapper”, “Model Manager”, “Local Persistence”, “External Ollama Server”).