How l10nmonster/llm-lab works
Project Type and Purpose
• This is a full-stack, single-page Express.js web application (“LLM Lab”) whose purpose is to let users configure and execute translation experiments on Google Sheets data via LLM providers. The frontend is plain HTML/CSS/JS, the backend is Node.js/Express, and the “database” is Google Sheets via the Google Sheets API.
File Structure Analysis
• Top-level files:
• server.js — entry point for the Express server
• package.json, jsconfig.json — project metadata and module resolution
• .gitignore, LICENSE, README.md
• public/ — static UI assets (index.html, style.css, script.js)
• routes/apiRoutes.js — Express route handlers for the API endpoints (/api/providers, /api/project)
• services/ — core business logic split into:
• googleAuth.js — handles OAuth2 authentication flow with Google
• googleSheets.js — reads/writes data to Sheets, handles formatting
• l10nMonster.js — orchestrates translation calls to LLM providers
• utils/spreadsheetUtils.js — helper functions (parsing IDs, range calculations)
Key Architectural Insights from README
• Single-page UI served by Express
• Two REST endpoints:
GET /api/providers → returns list of LLM providers
POST /api/project → handles test configuration, orchestrates data flow
• Google OAuth2 for secure authentication (credentials.json, token.json)
• Modular codebase following a simple “routes → services → utils” layering
• External dependencies: Google Sheets API, multiple LLM provider APIs (mocked or real)
1) Browser Client (UI)
2) Express Server
• Static File Server (public/)
• API Layer (routes/apiRoutes.js)
• Service Layer (services/googleAuth, googleSheets, l10nMonster)
• Utility Layer (utils/spreadsheetUtils)
3) External Service: Google OAuth2 / Google Sheets API
4) External Service: LLM Provider APIs (e.g., Lara, MMT, Gemini, GCT)
1) Browser → Express (HTTP GET /) → serves index.html, CSS, JS
2) Browser → Express (AJAX GET /api/providers) → returns provider list
3) Browser → Express (AJAX POST /api/project with config payload)
→ Express calls googleAuth to ensure valid token
→ googleSheets.readData(spreadsheetID, range)
→ l10nMonster.translateBatch(data, instructions) calls LLM APIs in parallel
→ l10nMonster returns translated results to service layer
→ googleSheets.writeData(newSheetID, formattedResults)
→ Express returns success + results‐sheet URL to Browser
c. Architectural Patterns and Principles:
• Layered architecture:
Presentation (public/) → API (routes) → Business Logic (services) → Utilities
• Separation of concerns: authentication, data I/O, translation logic each in its own module
• Asynchronous orchestration: promise‐based calls to Google and LLM APIs
• No persistent in‐app database; Google Sheets acts as both input and output store
d. Technologies & Frameworks:
• Node.js, Express.js
• googleapis Node.js client (OAuth2 + Sheets API)
• Vanilla HTML/CSS/JS on the client
• External LLM provider endpoints (REST/HTTP)
Essential Elements to Capture
• OAuth2 flow: client ↔ googleAuth ↔ Google OAuth2 endpoint
• Sheets read/write loop: config → googleSheets → Google Sheets API
• Translation loop: data → l10nMonster → LLM provider APIs → results
• Final result return path back to the Browser UI