Skip to content

Slaim-app/slaim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

118 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slaim

Slaim

An AI tutor that explains lecture slides and builds your Anki deck. Built for medical students.

Just Slaim it.

🔗 slaim.app  ·  🚀 app.slaim.app  ·  ✉️ hello@slaim.app


Overview

Upload a lecture deck (PDF or PPT). Slaim reads each slide multimodally — diagrams included — explains the mechanism in your language, and builds a real Anki .apkg you can drop into your existing Anki workflow. You can annotate on top of any explanation with Apple Pencil, ask follow-up questions in chat with a cropped region of a slide as context, and get a full-deck summary with comparison tables.

Three feedback signals shape the next response:

  • Got it / Confused on any slide. Confused slides get re-explained with more depth on the next regen.
  • Thumbs-down on an Anki card. The card is removed and that style is avoided when the deck is regenerated.
  • Try again on a chat answer. Slaim retries from a different angle — simpler analogy or different reasoning path.

A Slaim is learning · N signals counter in the profile menu surfaces these signals in aggregate.


Features

Tab What it does
Explanation Per-slide multimodal walk-through. Reads the diagram, walks the mechanism, ends with Was this clear? for the closed-loop signal.
Summary Full-deck study sheet with sections, comparison tables, and exam-relevant facts only. Copy as Markdown into your notes.
Anki Deck Native .apkg builder with cloze + basic + image cards. Edit, add, or thumb-down cards. Export opens directly in Anki.
Chat Ask anything in context. Crop a region of any slide and drop it in for a focused answer.

Plus:

  • Annotation on the slide and on the explanation pane — pressure-sensitive Apple Pencil support.
  • Snap to Anki — drag-crop any region of a slide into a new image-backed card in one tap.
  • .slaim style files — portable prompt scaffolds (Default, Medical, STEM, Exam Review, custom) that swap the explanation tutor's persona per block.
  • Bookmarks — flag slides you didn't get for later.
  • PWA — installable, offline-friendly, IndexedDB scoped per user.
  • Slaim Discord — Pro / Max subscribers get an auto-issued invite to a private server with #slaim-styles (community-shared .slaim presets), by-subject channels, and weekly study sprints. Max members also get monthly founder office hours.
  • Referral rewards — each user gets a personal ?ref=XXXXXX link. 1 paid signup → +1 free month, 3 → +1 month at Max, 5+ → Max for life. Refunds roll the bonus back automatically.

Pricing

Tier Price Includes
Free $0 5 files · 100 explanation slides / month · 1 AI Anki deck + 1 Summary / month · annotation · .apkg export
Pro $19 / mo or $179 / yr Unlimited files · 1,500 slides / month · 30 AI decks + summaries / month · custom .slaim styles · 200 chat messages / month
Max $39 / mo or $379 / yr Unlimited explanations · unlimited decks + summaries · unlimited chat · marketplace publish · priority queue

All three tiers are live. Pro / Max include an auto-issued invite to the private Slaim Discord community on first paid subscription. Monthly plans ship with a 7-day free trial; yearly plans skip the trial in favor of a 30-day money-back window.


Tech stack

Layer Choice
Frontend Single-file PWA, vanilla JS, installable
PDF rendering PDF.js with a per-slide pipeline + Web Workers
Annotation Custom canvas, pressure-sensitive Apple Pencil, pointer-capture so strokes don't drop on iPad Safari, offscreen committed-strokes canvas for constant-cost redraw
Storage IndexedDB + OPFS, namespaced per user (u_<uid>:*)
Auth Supabase (Google OAuth + email/password with verification + magic-link). Session shared across slaim.app and app.slaim.app via chunked .slaim.app cookies.
AI gemini-3.1-flash-lite-preview multimodal via Google Vertex AI, behind a Vercel serverless proxy that handles auth, rate limiting, request shaping, and per-user token-cost logging
Anki export Client-side sql.js + JSZip — real Anki 2.1 SQLite (.apkg) with Slaim Basic + Slaim Cloze note types, base91 GUID, SHA-1 csum, embedded image media
Billing Polar (Merchant of Record — handles tax/VAT). Hosted checkout per product (pro/max × monthly/yearly), HMAC-verified webhook → users.plan upserts, idempotency log in polar_events.
Community Polar's built-in Discord benefit. Polar issues invites + grants the Pro/Max role on subscription.created, and revokes the role on cancellation/refund. No Slaim-side bot or OAuth flow.
Email Polar handles purchase receipts and Discord invite DMs on its own. No transactional email integration on the Slaim side.
Hosting Vercel — slaim.app (landing), app.slaim.app (agent), slaim-proxy.vercel.app (AI / billing proxy)

Repo layout

slaim/
├── app/         # app.slaim.app — single-file PWA, the agent itself
├── landing/     # slaim.app — home, pricing, marketplace, terms, privacy
├── proxy/       # slaim-proxy.vercel.app — Vertex AI + Polar + Discord + Supabase
└── README.md

Each subproject is its own Vercel deployment. No build step — landing/ and app/ are static; proxy/ is plain ESM serverless functions.


Architecture notes

Per-slide as the unit of understanding. Each slide is its own model call with slide-specific context. Whole-PDF prompts wash out figure-level detail; per-slide preserves it.

Edge-proxied AI. API keys never touch the client. Every Gemini call routes through proxy/api/generate.js, which signs JWTs with the GCP service account, swaps for an access token (50-min cache), and forwards to Vertex AI. Per-request token usage is logged to public.token_usage keyed by user_id for cost analysis.

Real .apkg, not TSV. proxy/-free, fully client-side. sql.js builds an Anki 2.1 SQLite collection (col, notes, cards, revlog, graves) with proper indexes, default conf / dconf / decks / models, two note types, embedded image media, and a stable per-card GUID so re-imports update existing notes instead of duplicating the deck.

Cross-subdomain auth. Supabase's default localStorage storage doesn't carry across subdomains. Custom storage adapter writes the session to chunked .slaim.app cookies (1.8 KB chunks to stay under the per-cookie limit after URL encoding) so signing in on slaim.app propagates to app.slaim.app and the marketing pages without a re-login.

Pointer capture on annotation canvas. iPad Safari drops Apple Pencil pointer events mid-stroke when a hover or scroll-arbitration race kicks in. Setting setPointerCapture(e.pointerId) on pointerdown pins the pointer to the canvas until pointerup / pointercancel, eliminating the "I have to write the same line two or three times" symptom.

Constant-cost redraw. Long explanations make #draw-cvs 5–8k px tall. Replaying every stroke from the strokes array on each pointermove (highlighter mode does this) makes per-frame work proportional to history × canvas height. Slaim caches finalized strokes onto an offscreen canvas; aiRedraw() is a single drawImage blit, so per-move work is constant regardless of page length or stroke history.

Discord delivered by Polar, not by us. Polar's built-in Discord benefit is installed on the Slaim guild and toggled on each paid product. Polar issues the invite DM, grants the Pro/Max role on subscription.created, and revokes it on cancellation/refund — no Slaim-side bot, OAuth flow, role IDs, or webhook side-effects required.

Effective-plan with referral bonus. users.plan reflects what the user is paying for; users.bonus_plan + bonus_until reflect referral rewards. The client computes the effective plan as max(paid_plan, bonus_plan if active) so a Pro subscriber holding 3 successful referrals temporarily gets Max-tier quotas without any plan upgrade in Polar. The webhook stacks bonus months (extends from bonus_until if still in the future) instead of overwriting, and order.refunded rolls back exactly one month of bonus per refunded referee.


Local development

Each subproject is independent.

# Landing
cd landing && python3 -m http.server 8000     # then open http://localhost:8000

# App
cd app && python3 -m http.server 8001         # http://localhost:8001
# requires the proxy URL hardcoded in app/index.html (PROXY_URL constant)

# Proxy (Vercel serverless)
cd proxy && cp .env.example .env              # fill in real values
vercel dev

Production is git push → Vercel auto-deploy for each project (root dirs landing/, app/, proxy/).

Required environment variables (proxy/)

Var Purpose
GCP_PROJECT_ID / GCP_LOCATION / GCP_SA_EMAIL / GCP_SA_PRIVATE_KEY Vertex AI access
GEMINI_MODEL Defaults to gemini-3.1-flash-lite-preview
SUPABASE_URL / SUPABASE_SERVICE_KEY Token-usage logging + webhook plan upserts
POLAR_WEBHOOK_SECRET HMAC verification on incoming Polar events
POLAR_PRODUCT_ID_PRO_MONTHLY / _PRO_YEARLY / _MAX_MONTHLY / _MAX_YEARLY Product → plan + interval mapping
APP_URL / PROXY_URL Public URLs (used by checkout success redirect, CORS)
ALLOWED_ORIGINS CORS allowlist (CSV)

See proxy/README.md for proxy-specific details, proxy/polar-supabase.sql for the billing/community/referral schema migration, and proxy/waitlist-supabase.sql for the email-waitlist migration.


Status

Launched May 4, 2026. Free tier live; full agent flow (upload → multimodal explanation → annotate → Anki deck → chat → summary) functional end-to-end. Pro / Max paid tiers live via Polar with auto-issued Discord invites. Privacy and Terms live, GDPR-aware, no third-party trackers.

Roadmap (near-term):

  • AnkiConnect failure-rate ingestion — read the user's Anki review log and regenerate the source slide's explanation targeting the cards they keep missing.
  • .slaim marketplace v1 — community-shared block presets (cardio, pharm, neuro), seeded by what gets shared in #slaim-styles on Discord.
  • Native iPad app.

License

Source-available. See LICENSE. The repo is open for reading, learning, and forking for personal study; redistribution and competing commercial use are not permitted. Contributions via pull request are welcome but the upstream copyright remains with the project.


Contact

About

The AI tutor that reads your med-school slides — diagrams and all — and builds your Anki deck. Free during beta.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors