How lavantien/llm-tournament works
Main Components
• Frontend/User Interface:
– HTML templates (in the “templates” directory), CSS (e.g., style.css), and JavaScript (client-side code for handling dynamic interactions, including Chart.js and Marked.js for visualizations and markdown processing).
– The UI displays evaluation results, prompt management, and dashboards.
• Backend Server:
– The Go entry point is “main.go” which sets up the web server.
– “handlers” directory contains various HTTP endpoint handlers (models, profiles, prompts, results, stats, suites) that implement the core business logic.
– “middleware” houses utility plugins for request processing (socket management, state handling, error import utilities).
– “system_prompt_*.xml” files that define base prompt configurations or system messages.
• Data Storage:
– File-based persistence using JSON files stored in the “data” directory (profiles, prompts, results, test and default suites).
– This acts as a lightweight database that holds the system state and evaluation data.
• Real-Time Communication:
– Gorilla WebSocket (as mentioned in the README) used in middleware to provide real-time updates for scoring and collaboration.
• Complementary Tools:
– Located in “tools” (like “tts”, “bg_batch_eraser”, “openwebui”, and “ragweb_agent”), these represent auxiliary utilities that interface with the main system or extend functionality (e.g., generating podcast audio or image background removal).
Representing Interactions and Relationships
• Users interact with the Frontend via a web browser.
• Frontend and Backend Connection:
– HTTP endpoints deliver JSON or HTML responses from “handlers” with support for static file serving (assets, templates).
– WebSocket connections (managed by middleware/socket.go) provide real-time updates from the Backend to the client.
• Backend Components:
– The “handlers” interact with the file-based data storage (reading/writing JSON files) to persist evaluation state.
– Middleware components intercept calls for logging, state management, and error handling.
– The server orchestrates these components to deliver the evaluation engine (real-time scoring, state restoration, model ranking, etc.).
• Complementary Tools:
– Although these tools are not part of the core server, they are linked components (for instance, tts for audio generation or background removal will likely be triggered separately or via a UI integration).
– They can be shown as independent modules that can interact with the backend or operate as stand-alone utilities.
Architectural Patterns and Design Principles
• Separation of Concerns:
– Clearly divide the system into frontend, backend (with distinct responsibilities in Handlers and Middleware), and data storage.
• Real-Time Data Flow:
– Emphasize WebSocket communication for instantaneous client updates.
• Modular Design:
– The clear directory separation (handlers, middleware, templates, tools) reflects a modular design that can be drawn in separate component blocks.
• File-based Persistence:
– Show the JSON data storage as an integral DB substitute.
• Complementary Components:
Technologies and Frameworks
• Backend: Go (version 1.21+), Gorilla WebSocket, Blackfriday, Bluemonday.
• Frontend: HTML5, CSS3, JavaScript (ES6+), Chart.js, Marked.js.
• Data: JSON file storage with import/export support.