Expand description
§gglib-core
Pure domain types, ports, and traits for gglib — the foundation of the hexagonal architecture.
§Architecture
This crate is the Core Layer — the innermost ring of the architecture. All other crates depend on it; it depends on none.
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ Core Layer │
│ ┌─────────────────────────────────────────────────────────────────────────────┐ │
│ │ ►►► gglib-core ◄◄◄ │ │
│ │ Pure domain types, ports & traits (no infra deps) │ │
│ └─────────────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────┐
│ gglib-db, gglib-gguf, gglib-hf, gglib-mcp, │
│ gglib-download, gglib-runtime │
└───────────────────────────────────────────────────────┘See the Architecture Overview for the complete diagram.
§Internal Structure
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ gglib-core │
├─────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ domain/ │ │ ports/ │ │ services/ │ │ events/ │ │
│ │ Pure types │ │ Traits │ │ Use cases │ │ App events │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ paths/ │ │ download/ │ │ utils/ │ │ settings │ │
│ │ Path config │ │Download DTOs│ │ Helpers │ │ Config │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────────┘Modules
| Module | LOC | Complexity | Coverage |
|---|---|---|---|
settings.rs | |||
contracts/ | |||
domain/ | |||
download/ | |||
events/ | |||
paths/ | |||
ports/ | |||
services/ | |||
utils/ |
Module Descriptions:
domain/— Pure domain types:Model,ModelFile,McpServer,Conversationports/— Trait definitions (repository ports, HF client port, event emitter)services/— Application use cases and business logic orchestrationevents/— Strongly-typed application events for UI/adapter notificationpaths/— Path configuration and platform-specific directory handlingdownload/— Download-related DTOs and progress tracking typesports/mcp_dto.rs— Cross-boundary DTOs for MCP resolution status (Tauri/Axum/TypeScript)utils/— Shared utility functions and helperssettings.rs— Application settings and configuration types
§Design Principles
- No Infrastructure Dependencies — No
SQLx, no HTTP clients, no filesystem I/O - Trait-Based Ports — All external capabilities defined as traits for DI
- Pure Data Types — Domain types are serializable, cloneable, and testable
- Event-Driven —
AppEventEmittertrait enables decoupled UI updates
§Usage
use gglib_core::domain::Model;
use gglib_core::ports::{ModelRepository, RepositoryError};
use gglib_core::services::ModelService;
use gglib_core::events::AppEvent;
// Ports define capabilities
async fn example<R: ModelRepository>(repo: &R) -> Result<Vec<Model>, RepositoryError> {
let models = repo.list().await?;
Ok(models)
}Re-exports§
pub use domain::ChatMessage;pub use domain::Conversation;pub use domain::ConversationUpdate;pub use domain::McpEnvEntry;pub use domain::McpServer;pub use domain::McpServerConfig;pub use domain::McpServerStatus;pub use domain::McpServerType;pub use domain::McpTool;pub use domain::McpToolResult;pub use domain::Message;pub use domain::MessageRole;pub use domain::Model;pub use domain::ModelCapabilities;pub use domain::ModelFilterOptions;pub use domain::NewConversation;pub use domain::NewMcpServer;pub use domain::NewMessage;pub use domain::NewModel;pub use domain::RangeValues;pub use domain::UpdateMcpServer;pub use domain::infer_from_chat_template;pub use domain::transform_messages_for_capabilities;pub use download::AttemptCounts;pub use download::CompletionDetail;pub use download::CompletionKey;pub use download::CompletionKind;pub use download::DownloadError;pub use download::DownloadEvent;pub use download::DownloadId;pub use download::DownloadResult;pub use download::DownloadStatus;pub use download::DownloadSummary;pub use download::FailedDownload;pub use download::Quantization;pub use download::QueueRunSummary;pub use download::QueueSnapshot;pub use download::QueuedDownload;pub use download::ShardInfo;pub use events::AppEvent;pub use events::McpServerSummary;pub use events::ModelSummary;pub use events::ServerSnapshotEntry;pub use ports::AppEventBridge;pub use ports::AppEventEmitter;pub use ports::ChatHistoryError;pub use ports::ChatHistoryRepository;pub use ports::CompletedDownload;pub use ports::CoreError;pub use ports::DownloadEventEmitterPort;pub use ports::DownloadManagerConfig;pub use ports::DownloadManagerPort;pub use ports::DownloadRequest;pub use ports::DownloadStateRepositoryPort;pub use ports::GgufCapabilities;pub use ports::GgufMetadata;pub use ports::GgufParseError;pub use ports::GgufParserPort;pub use ports::HfClientPort;pub use ports::HfFileInfo;pub use ports::HfPortError;pub use ports::HfQuantInfo;pub use ports::HfRepoInfo;pub use ports::HfSearchOptions;pub use ports::HfSearchResult;pub use ports::McpErrorCategory;pub use ports::McpErrorInfo;pub use ports::McpRepositoryError;pub use ports::McpServerRepository;pub use ports::McpServiceError;pub use ports::ModelRegistrarPort;pub use ports::ModelRepository;pub use ports::NoopDownloadEmitter;pub use ports::NoopEmitter;pub use ports::NoopGgufParser;pub use ports::ProcessError;pub use ports::ProcessHandle;pub use ports::ProcessRunner;pub use ports::QuantizationResolver;pub use ports::Repos;pub use ports::RepositoryError;pub use ports::Resolution;pub use ports::ResolvedFile;pub use ports::ServerConfig;pub use ports::ServerHealth;pub use ports::SettingsRepository;pub use services::ChatHistoryService;pub use services::ModelRegistrar;pub use settings::DEFAULT_LLAMA_BASE_PORT;pub use settings::DEFAULT_PROXY_PORT;pub use settings::Settings;pub use settings::SettingsError;pub use settings::SettingsUpdate;pub use settings::validate_settings;pub use paths::DEFAULT_MODELS_DIR_RELATIVE;pub use paths::DirectoryCreationStrategy;pub use paths::ModelsDirResolution;pub use paths::ModelsDirSource;pub use paths::PathError;pub use paths::data_root;pub use paths::database_path;pub use paths::default_models_dir;pub use paths::ensure_directory;pub use paths::env_file_path;pub use paths::is_prebuilt_binary;pub use paths::llama_cli_path;pub use paths::llama_config_path;pub use paths::llama_cpp_dir;pub use paths::llama_server_path;pub use paths::persist_env_value;pub use paths::persist_models_dir;pub use paths::resolve_models_dir;pub use paths::resource_root;pub use paths::verify_writable;
Modules§
- contracts
- Transport contract constants.
- domain
- Core domain types.
- download
- Download domain types, events, errors, and traits.
- events
- Canonical event union for all cross-adapter events.
- paths
- Path utilities for gglib data directories and user-configurable locations.
- ports
- Port definitions (trait abstractions) for external systems.
- services
- Core services - the application’s business logic layer.
- settings
- Settings domain types and validation.
- utils
- Utility modules for gglib-core.