This chapter is for the developer who starts from Lingo: how the project is laid out, how each part works, and where to change it. Lingo: A language learning app from every side shows the same app from the user’s side.

The sample lives in scripts/lingo. The Initializr generates it, under your own name and package, when you pick the language learning template. Everything in it’s released under MIT No Attribution, so take any part of it into your own application.

Running it

The development profile needs nothing installed:

cd scripts/lingo
CN1_PROFILE=dev backend/server.sh run
cd scripts/lingo
mvn verify -Psimulator -DskipTests -Dcodename1.platform=javase

The modules

shared is the contract. It holds the data classes both sides exchange and the @RestClient interfaces, such as LearnApi, CommunityApi, StudioApi and AdminApi, that name every call. The app’s build generates a client from them and the server’s build generates the interfaces it implements, so a change one side didn’t follow is a compile error.

common is the app, for every platform. Its packages:

learn

The learner’s screens: today, the catalogue, the three kinds of lesson, rewards, badges, the leaderboard, certificates, the wallet and the admin’s accounts.

studio

The creator’s: the studio, the course and lesson editors and the class scheduler.

ai

Choosing the tutor and running it: Tutors, and one TutorEngine per kind.

speech

Voice, which speaks and listens, and PronunciationScorer.

live

The live channel and LiveRoom, a class over WebRTC.

ui, net, notify

The shared kit, the session and the API clients, and reminders.

backend is the server. learn holds progress, XP, badges and the conversation tutor. community holds questions, live classes and payments, studio the creators' side, cert the certificates, live the WebSocket, and admin the accounts console. The entities are in domain with a repository each. The schema is the migration scripts in src/main/resources/db/migration, with a variant for each database.

The tutor

Tutors.choose picks the conversation partner, best first:

  1. the operating system’s own model, Apple Intelligence or Gemini Nano, when the device has one ready;

  2. a model the app downloads, Qwen2.5 0.5B Instruct, run on the device with llama.cpp;

  3. the cloud tutor through the server, only when the learner turned it on;

  4. a scripted partner, which always works.

choose takes four booleans and nothing else, so TutorLogicTest covers the order without a device. Each engine implements TutorEngine, which takes the scene, the level and the turns so far, and answers with a reply and an optional correction. To use a different on-device model, change MODEL_URL, MODEL_SHA256 and MODEL_BYTES in Tutors. The download goes through ModelCache, which needs the digest: iOS refuses an unpinned download, and the digest makes sure the model is the one the app was tested with.

The cloud tutor is backend/…​/ai/ClaudeClient, behind the server’s own key (lingo.ai.key), so no key ever ships in the app. Without a key the server answers from rules.

Pronunciation

Voice speaks the phrase with the device’s text to speech and listens with its speech recognizer, both in the course’s language. PronunciationScorer aligns what was heard with the phrase, word by word, using an edit distance in which swapping one word for another costs how different their letters are. A dropped word therefore costs one word and doesn’t shift the rest. Case, accents and punctuation are folded away character by character, because recognizers disagree on all three. The fold never calls toLowerCase(), whose result depends on the device’s locale.

The recognizer writes down words, not sounds, so the score measures whether a native listener understood each word. A language-specific acoustic model could replace the scorer behind the same Result.

Progress and badges

The server is the authority on progress. Learning records a finished lesson, awards its XP, extends the streak, and asks Badges what the lesson unlocked; the app only shows what comes back. Badge rules are plain Java in Badges. A new badge is a rule there and a line in the seed.

Certificates

When the last lesson of a course is done, Certificates draws the PDF: the name, the course, the date, the hours and a QR code of its verification address. It signs the PDF with the core PdfDocument.sign and a PdfSignature over CertificateKeys, and stores the bytes exactly as issued. GET /verify/{id} looks a certificate up and checks its signature again; /verify/{id} in a browser is the public page the QR code opens.

To make PDF readers trust the signature, give the server a key and a certificate from a CA they trust, in lingo.certificates.key and lingo.certificates.chain. Without them, it signs with a self-signed key it keeps in the database.

Payments and the creator’s share

Community.purchase records every sale: a course, a seat in a class, Pro or a tip. It credits the creator CREATOR_SHARE, 70%, of a sale, and the whole of a tip. Payments are simulated: every one succeeds unless its method is declined. A real deployment puts a payment provider in purchase. The rest of the server reads only the receipts it writes.

Live classes

LiveRoom makes the host the hub. Each learner holds one peer connection, to the host, and the host holds one to each learner. The signalling goes over the app’s live channel, which the server relays only between people seated in a class while it’s live. A class of more than a handful wants a selective forwarding unit (SFU) in place of the host; the signalling stays the same.

Settings and deployment

backend/application.properties lists every setting. A production start looks like this:

export CN1_PROFILE=prod
export DATABASE_URL=postgres://lingo:secret@db.example.com:5432/lingo
export LINGO_PUBLIC_URL=https://learn.example.com
export LINGO_ADMIN_EMAIL=you@example.com
export LINGO_ADMIN_PASSWORD=change-me
export LINGO_CERTIFICATES_KEY=base64-pkcs8-key
export LINGO_CERTIFICATES_CHAIN=base64-signer-cert,base64-issuer-cert
export LINGO_AI_KEY=sk-ant-your-key
export LINGO_PUSH_APP=your-push-app-id
export LINGO_PUSH_KEY=your-push-server-key
backend/server.sh run --native

Outside a development profile the only account created is the administrator, who grants the first creators from the studio’s Accounts button. The seed courses are loaded on every profile, from src/main/resources/seed/courses.json.

Tests

cd scripts/lingo
./run-e2e.sh
./run-web-e2e.sh
./check-template.sh

The server’s tests run from mvn -pl shared,backend -Dcodename1.platform=backend test, and scripts/ci/sample-server-tests-on-database.sh scripts/lingo runs them again against PostgreSQL or MySQL. run-e2e.sh starts the server and drives the app in the simulator as a learner and a creator. run-web-e2e.sh does the same in a headless browser, and check-template.sh builds a project generated from the Initializr template.