refactor(llm-api): implement clean architecture following scraper pattern

Split monolithic 1012-line main.rs into layered hexagonal architecture:
- Domain: entity types and LlmError enum
- Application: prompt building, sampler construction, tool call parsing
- Infrastructure: LlamaEngine wrapping llama-cpp-2 with isolated unsafe transmute
- Presentation: Axum handlers, middleware (auth), error chain, router
- Config: type-safe AppConfig with LazyLock
- Bootstrap: Application struct with build() + run()

Resolves build_sampler/build_sampler_params duplication.
Adds simple web chat UI at GET /.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
asepharyana
2026-07-25 15:07:19 +07:00
co-authored by Claude Code
parent dfd6fa66a7
commit e351d74fa4
29 changed files with 1826 additions and 1008 deletions
+16
View File
@@ -0,0 +1,16 @@
//! Chat UI — simple web interface for interacting with the LLM.
use axum::http::{header, HeaderValue, StatusCode};
use axum::response::{IntoResponse, Response};
const HTML: &str = include_str!("chat-ui/index.html");
/// GET / — serve the chat UI page.
pub async fn chat_ui() -> Response {
(
StatusCode::OK,
[(header::CONTENT_TYPE, HeaderValue::from_static("text/html; charset=utf-8"))],
HTML,
)
.into_response()
}