How hi-day/lisanai works
Purpose and Runtime
Lisan.ai is a multi-tenant Indonesian oral-assessment platform for teachers, students, and admins. It creates rubric-based assessments, collects spoken or typed responses, evaluates them through a trustworthy AI harness, and exposes operational and research dashboards. The runtime is Node.js with a static browser SPA, SQLite persistence, and Vercel-compatible serverless API routes.
Entry Points and Delivery
• Local bootstrapping and HTTP composition begin in local-server.js and server/bootstrap.js.
• The browser app starts from src/js/main.js, composes application state/UI in src/js/app.js, and is bundled to public/js/app.bundle.js.
• Vercel routes API requests through api/v1.js and feature handlers such as api/assessment.js; static delivery is handled by server/static.js.
• API documentation is served from api/docs.js and the generated contract api/openapi.json.
Identity, Tenancy, and Access Boundary
• Authentication, sessions, CSRF, password handling, and role authorization are centered in server/auth-service.js and server/api-auth.js.
• Teacher/student/admin workflows are represented client-side by src/js/auth-ui.js, src/js/class-management.js, and src/js/student-flow.js.
• Public API consumers use separately managed API keys through server/api-key-service.js and api/apikeys.js.
• Authorization is a critical boundary: tenant, class membership/approval, and role constraints must be enforced before assessment, submission, complaint, or research access.
Assessment Authoring and Submission Flow
• Teachers create and manage assessments through server/assessment-service.js, exposed by api/assessment.js; UI authoring is in src/js/assessment-wizard.js and src/js/assessment-factory.js.
• Question generation/alignment uses AI-provider abstractions in server/ai/provider.js, server/ai/openrouter-provider.js, and response normalization in server/ai/response-parser.js.
• Students enter an assessment flow, perform microphone checks, and submit recorded or manually transcribed answers via src/js/student-flow.js, src/js/mic-check.js, and src/js/recorder.js.
• Database schema evolution includes assessments, submissions, question banks, and evaluation intelligence in server/migrations/001_initial_schema.sql, server/migrations/013_question_bank.sql, and server/migrations/014_evaluation_intelligence.sql.
Trustworthy Evaluation Harness
• All AI scoring is orchestrated by server/harness/harness.js and server/harness/pipeline.js, rather than a direct evaluator path.
• The harness compiles rubrics, invokes plugins/evaluators, validates evidence, calculates reliability/risk, and records traceability through server/harness/rubric-compiler.js, server/harness/evidence-validator.js, and server/harness/trace.js.
• Verification and publication are distinct gates: failed results are withheld; review-required results require human approval. Related controls live in server/harness/validator.js, server/evaluation/human-approval.js, and server/harness/reproducibility.js.
• The provider boundary supports OpenRouter production calls and deterministic mock execution for CI/development: server/ai/openrouter-provider.js, server/ai/mock-provider.js.
Data, Observability, and Research
• SQLite access is centralized in server/database.js; local data is persisted under data/, with migrations in server/migrations/.
• AI telemetry, latency/token/cost semantics, and observability APIs are implemented in server/ai/pricing.js, server/evaluation/trace-persister.js, and api/observability.js.
• Research workflows compute AI-vs-human and experiment metrics through server/evaluation/research.js, server/evaluation/metrics.js, and server/evaluation/benchmark/benchmark.js; the UI is src/js/research.js.
• Benchmark inputs are file-based datasets, including data/datasets/bench-mark-rater.json.
Infrastructure and External Services
• OpenRouter is the external AI gateway, configured through environment variables and mediated by server/openrouter.js.
• Security and abuse controls are server-level middleware concerns: server/rate-limit.js and server/security-headers.js.
• Deployment configuration is vercel.json; frontend assets are built from src/js/ into public/.
Main entry points: database.js SQLite persistence · app.js Application SPA · assessment-service.js Assessment service · assessment.js Assessment API
Components 21
Browser SPA
- Application SPA
src/js/app.js - Auth & role UI
src/js/auth-ui.js - Assessment authoring
src/js/assessment-wizard.js - Student response flow · Includes microphone checks and recording.
src/js/student-flow.js - Research dashboard
src/js/research.js
Delivery & API
- Vercel API router
api/v1.js - Assessment API
api/assessment.js - Observability API
api/observability.js
Core services
- Auth & tenancy boundary · Enforces sessions, CSRF, roles, tenant and membership constraints.
server/api-auth.js - API key service
server/api-key-service.js - Assessment service
server/assessment-service.js - AI provider boundary · Selects OpenRouter or deterministic mock execution.
server/ai/provider.js
Evaluation & research
- Evaluation harness · Compiles rubrics, invokes evaluators, and produces traceable results.
server/harness/pipeline.js - Evidence & validation · Withholds failed evaluations before publication.
server/harness/evidence-validator.js - Human approval · Publishes review-required results only after approval.
server/evaluation/human-approval.js - Trace & telemetry
server/evaluation/trace-persister.js - Research metrics · Computes AI-vs-human and experiment metrics.
server/evaluation/research.js
Data & external
- SQLite persistence · Stores tenant, assessment, submission, and evaluation data.
server/database.js - Schema migrations
server/migrations/014_evaluation_intelligence.sql - Benchmark dataset
data/datasets/bench-mark-rater.json - OpenRouter gateway
server/openrouter.js
Connections 26
- Application SPA → Auth & role UI
- Application SPA → Assessment authoring
- Application SPA → Student response flow
- Application SPA → Research dashboard
- Auth & role UI → Vercel API router: authenticated requests
- Assessment authoring → Assessment API: author assessments
- Student response flow → Assessment API: submit responses
- Research dashboard → Observability API: view metrics
- Vercel API router → Auth & tenancy boundary: protect routes
- Auth & tenancy boundary → Assessment API: authorized access
- Auth & tenancy boundary → API key service: public consumer access
- Assessment API → Assessment service
- Assessment service → SQLite persistence: assessments and submissions
- Assessment service → AI provider boundary: generate questions
- Assessment service → Evaluation harness: evaluate submissions
- Evaluation harness → Evidence & validation: verify evidence
- Evidence & validation → Human approval: review-required results
- Evidence & validation → Trace & telemetry: record trace
- Human approval → SQLite persistence: publish outcome
- Trace & telemetry → SQLite persistence: persist telemetry
- Observability API → Trace & telemetry: query telemetry
- Research dashboard → Research metrics: analyze studies
- Research metrics → SQLite persistence: evaluation data
- Research metrics → Benchmark dataset: benchmark inputs
- AI provider boundary → OpenRouter gateway: production inference
- Schema migrations → SQLite persistence: evolve schema