Skip to content

About

Your personal learning environment. Local-first, open-source, and built for learning anything.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

OpenStudia

A local-first learning app built on installable content packs. A pack is a course or subject with levels, sections, Markdown theory, and authored or AI-generated test sets. Packs are fetched from a public manifest, stored in IndexedDB, and work offline.

Stack

  • React 19
  • TypeScript 6
  • Vite 8
  • TanStack Router
  • TanStack DB
  • AI SDK + OpenAI-compatible provider
  • shadcn/ui-style components on Radix + Tailwind CSS 4
  • dnd-kit
  • react-markdown + remark-gfm
  • Zod
  • i18next / react-i18next
  • Vite PWA
  • Vitest
  • Biome

Requirements

  • Node.js 24.8.0 (see .nvmrc)
  • npm

Getting Started

npm install
npm start

Vite starts on port 3000 by default. Change it with VITE_PORT.

Scripts

Command Description
npm start Start the Vite dev server.
npm run build Type-check, then build into VITE_OUTPUT_DIR.
npm run check Run Biome and tsc.
npm run typecheck Type-check only.
npm test Run Vitest once.
npm run test:watch Run Vitest in watch mode.
npm run biome:lint Run Biome lint.
npm run biome:format Format source files with Biome.

App Structure

src/
  components/ui/              shadcn-style primitives
  contexts/                   language, theme, PWA
  core/
    i18n/                     i18next setup
    router/                   TanStack Router setup
  features/
    ai/                       provider client and errors
    packs/                    pack schemas, install/update service, manifest provider, AI generation and grading
    settings/                 provider settings schema
    storage/                  TanStack DB collections, API-key storage
    subjects/                 active-subject state
    sync/                     global Git snapshot, GitHub contents API, conflict resolution
    theory/                   Markdown renderer
  layouts/
  pages/
    library/                  subjects, catalog, entry, theory and test runner
    progress/                 subject-scoped results
    settings/                 AI · Sync · Data
public/content/
  manifest.json               available subjects
  packs/<id>/pack.json        groups, catalog entries, prompts, theory and test references
  packs/<id>/theory/*.md      Markdown theory
  packs/<id>/tests/*.json     authored test sets

Routes

  • /subjects — choose a subject; accessible without an active subject
  • /settings — global AI provider, Git sync, and data management
  • /catalog — catalog of the active subject, grouped by type
  • /catalog/:entryId — entry with Test, Cards, and Theory review
  • /catalog/:entryId/tests/:testSetId — mode-specific runner
  • /theory — theory list of the active subject
  • /theory/:entryId — Markdown theory
  • /progress — attempts for the active subject
  • old /library, /tests, and related routes redirect to /subjects

Without an active subject only /subjects and /settings are available. The active subject is stored in localStorage.

There is no authentication. The app is a static SPA with local browser storage.

Subject catalog and test modes

A subject is a pack. Its catalog groups entries by a type such as A1 and gives each entry a name such as Present Simple.

Every entry has three test modes:

  • Test — all tasks on one page, one final result.
  • Cards — one task at a time with immediate feedback.
  • Theory review — one task at a time, deeper rule checking.

All modes use the same task types: single choice, multiple choice, short answer, cloze, spot the error, and open response.

AI generation merges prompts from the pack, the catalog entry, and the selected mode. Entry-level prompts can forbid ambiguous tasks; for example, the Adverbs of Frequency entry requires a decisive context instead of interchangeable adverbs.

Page Transitions

Page content uses a small CSS enter animation (.page-enter) keyed by the current pathname. The sidebar and header never animate, and there is no shared-element morphing between routes.

The animation is disabled when prefers-reduced-motion: reduce is set.

Adding a pack

Add a folder under public/content/packs/<id>/ with:

pack.json
theory/*.md
tests/*.json

Add the pack to public/content/manifest.json with its id, version, localized title/description, language, tags, and packUrl.

pack.json declares groups, catalog entries, order, prompts, theory file paths, and test set references with a mode (test, cards, theory-review). Every entry and test set is validated with Zod before it reaches storage. To update a pack, bump the version in both the manifest and pack.json; installed subjects then show Update in the library.

Theory Markdown supports GFM tables, nested lists, blockquotes, and code blocks. Test sets support single-choice, multiple-choice, short-answer, cloze, spot-error, and open-response tasks. Open responses are graded by AI against the task rubric.

Data Storage

TanStack DB is the only data layer:

  • settings — localStorageCollectionOptions (openstudia:settings:v1)
  • packs — installed pack configs and downloaded theory
  • packTestSets — downloaded, user-added, and AI-generated test sets
  • packAttempts — mode-specific test results
  • active subject — localStorage key openstudia:active-subject
  • legacy English collections (tests, attempts, cardSessions, theoryDrills, theorySessions)

The API key is stored outside TanStack DB:

  • sessionStorage by default;
  • localStorage only when “Remember on this device” is enabled.

The key is never included in the JSON backup.

AI Provider

The app supports any OpenAI-compatible endpoint:

  • OpenAI
  • OpenRouter
  • Groq
  • Ollama / LM Studio
  • custom base URL

Provider setup is a strict flow:

  1. Enter the base URL and API key.
  2. Click Check API to verify the endpoint and load models.
  3. Choose a model from the searchable combobox (or enter a custom model ID if the provider does not expose /models).
  4. Click Test model to verify that the selected model responds.
  5. Only then Save becomes available.

Changing the base URL, API key, or model invalidates the relevant checks. A saved configuration stores lastVerifiedAt; pack pages only enable AI generation with a verified configuration.

Generation and evaluation use AI SDK structured outputs with Zod validation and one repair attempt. If a provider does not support JSON schema, turn off Structured outputs in Settings → AI.

Because this is a client-side app, the key is visible to the browser. For a public multi-user deployment, put the provider behind a server-side proxy. The provider must also allow browser requests (CORS); local Ollama requires OLLAMA_ORIGINS.

Git sync

Sync is global across every installed pack and attempt. It is manual by default, with optional auto-sync on launch and on meaningful events: Settings → Sync.

  1. Create a private GitHub repository and add a README (the repository needs its first commit): https://github.com/new.
  2. Create a fine-grained token with Contents: read and write for that repository: https://github.com/settings/personal-access-tokens/new.
  3. Paste owner/repo, the branch, and the token, then press Sync.

The app stores one JSON snapshot in the repository. If both local and remote data changed, it asks whether to replace local with remote or remote with local. The AI API key and the GitHub token are never included in the snapshot; public repositories are rejected.

Localization

The UI uses ru-RU and en-US, with ru-RU as the fallback. Locale files live at:

public/locales/ru-RU/translation.json
public/locales/en-US/translation.json

Topic definitions use the same ru-RU / en-US keys for localized labels.

Scoring

clozeScore   = correct blanks / total blanks * 100
writingScore = average AI score across writing tasks
attemptScore = 0.6 * writingScore + 0.4 * clozeScore
masteryAfter = first attempt
               ? attemptScore
               : 0.65 * previous mastery + 0.35 * attemptScore

The AI recommends a review interval, and the app clamps it to a score-based band. Three consecutive strong attempts at 90+ mastery schedule the next review in 30 days.

PWA

PWA support is configured in vite.config.ts. The service worker is registered only in prod mode. The app can detect updates and reset its cache from the AI → Data section.

Generated icons and the service worker are build artifacts. Do not edit them manually.

Environment

Copy .env.template to .env.local for local work.

Variable Purpose
VITE_DEFAULT_NAME Full app name for HTML and the PWA manifest.
VITE_DEFAULT_NAME_SHORT Short app name.
VITE_DEFAULT_THEME_COLOR Theme color for the PWA manifest.
VITE_DEFAULT_DESCRIPTION App description.
VITE_BASE_PATH Public base path for assets, router, and PWA scope.
VITE_NODE_ENV prod, dev, or test. Controls robots meta.
VITE_PORT Dev server port.
VITE_OUTPUT_DIR Build output directory.

Deployment

GitHub Pages

The Deploy to GitHub Pages workflow builds and publishes the app from main.

  • Enable Settings → Pages → Build and deployment → Source: GitHub Actions once for the repository.
  • The workflow sets VITE_BASE_PATH=/<repository>/, because project Pages are served from a subpath.
  • It copies build/index.html to build/404.html for SPA deep links and adds .nojekyll.
  • For a custom domain served from /, override VITE_BASE_PATH in the workflow to /.
  • The published URL is https://<owner>.github.io/<repository>/.

Static hosting

  • Build with npm run build.
  • Serve the output as a static SPA with fallback to index.html.
  • Keep VITE_BASE_PATH aligned with the actual hosting path.
  • Provide a production VITE_NODE_ENV and branding values.

Troubleshooting

  • AI request fails immediately — usually CORS or an invalid base URL. Check the provider's browser-access settings.
  • No model list — some providers do not expose /models; enter the model manually.
  • Data disappeared — local data is tied to the browser profile and origin. Clearing site data removes it.
  • PWA update does not appear — service worker registration is enabled only in prod mode.

About

Your personal learning environment. Local-first, open-source, and built for learning anything.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages