Skip to content

Davidwadesmith/ailib

Repository files navigation

AILib

License: MIT

AI-powered study library with a local web app for managing course materials, generating notes, exams, and Q&A sessions.

Upload your course PDFs/PPTs, and let AI agents generate structured study notes, practice questions, mock exams, answer strategies, and tutoring sessions -- all stored locally in SQLite, rendered as beautiful HTML5 artifacts.

Quick Start

# Install dependencies (backend + frontend)
npm install
cd apps/librarian/web && npm install && cd ../..

# Start dev server (Hono API + Vite with HMR)
npm run dev

Open http://localhost:5173 for the dev server (hot reload), or http://localhost:4177 for the API server.

Production mode:

npm run start    # Build frontend + start server

Then open http://localhost:4177.

Docker

docker compose up --build

Open http://localhost:4177.

Screenshots

Dashboard Dashboard showing source counts, task queue, and data flow

Create Task Task creation with format selector (HTML5 / Markdown)

What It Does

  • Source Material Management -- Upload PDFs, PPTs, and lecture slides. Everything is registered in a searchable SQLite database with full-text search.
  • AI Study Notes -- Generate structured, exam-oriented knowledge notes from your materials with source citations.
  • Question Bank & Mock Exams -- AI generates practice questions (multiple choice, fill-in-the-blank, short answer, essay) and full mock papers with grading rubrics.
  • Q&A Tutoring -- Ask questions about your materials and get answers with exam tips, all traced back to source documents.
  • Exam Strategy Analysis -- Analyze past papers for high-value topics, common pitfalls, time allocation, and answer strategies.

Tech Stack

  • Database: SQLite via better-sqlite3 (WAL mode, FTS5 full-text search)
  • Server: Hono + @hono/node-server (TypeScript, port 4177)
  • Frontend: Vue 3 + Vite (SPA with hash routing)
  • AI Integration: Agent skills for Claude Code and Codex via CLI wrapper

Architecture

[User] --> Librarian Web UI --> Hono Server --> SQLite DB
                                               |
[User] --> AI Agent (Claude/Codex) --> CLI Wrapper --> SQLite DB
                                         |
                                  Generated Artifacts --> knowledge/, exams/, sessions/

The web UI handles CRUD and task creation. The AI agent handles semantic processing (note generation, exam creation, Q&A). The operations queue bridges the two.

Commands

Command Description
npm run dev Start dev server (Hono + Vite with HMR)
npm run build Build Vue frontend
npm run start Build + start production server
npm run librarian Start server only (production)
npm run register:sources Scan sources/raw/, update DB
npm run refresh:library Process operations queue
npm run build:indexes Rebuild FTS5 search index
npm run validate Structural validation checks
npm run test:librarian Smoke tests

Agent Skills

6 built-in skills drive the AI agent's behavior:

Skill Purpose
/knowledge-organizer Generate structured study notes from materials
/exam-generator Create practice questions, quizzes, and mock papers
/qa-tutor Answer student questions with source citations
/exam-strategy Analyze papers for answer strategy and time allocation
/refresh-library Process the operations queue (batch generation)
/init-library Bootstrap database and directory structure

Skills are defined in .claude/skills/ (Claude Code) and .codex/skills/ (Codex). They are model-agnostic prompt documents -- the CLI wrapper and templates are shared.

Directory Structure

apps/librarian/
  server/index.ts           Hono REST API server
  web/                      Vue 3 SPA (built to dist/)
scripts/
  lib/db.ts                 SQLite singleton
  lib/schema.ts             Database schema + FTS5
  lib/registry-utils.ts     Shared utilities
  librarian-cli.ts          CLI wrapper for agent data access
sources/raw/                Source materials (PDFs, PPTs)
knowledge/                  Generated study notes
exams/                      Generated exam materials
sessions/                   Q&A sessions and review plans
templates/                  Output templates for AI-generated content
data/config/library.json    Project configuration
data/librarian.db           SQLite database (gitignored, regeneratable)

Configuration

Edit data/config/library.json or use environment variables:

LIBRARIAN_HOST=0.0.0.0    # Server host (default: 127.0.0.1)
LIBRARIAN_PORT=4177       # Server port (default: 4177)
LIBRARIAN_NAME=AILib      # Library name shown in UI
LIBRARIAN_DB_PATH=./data/librarian.db  # Database path

See .env.example for all available variables.

API

All endpoints live under http://localhost:4177.

Method Path Description
GET /api/health Database summary (sources, artifacts, queued tasks)
GET /api/sources List registered sources with tags
GET /api/sources/:id Get a single source by ID
POST /api/sources Register a new source from sources/raw/
DELETE /api/sources/:id Delete a source and its file
GET /api/artifacts List generated artifacts
POST /api/artifacts/refresh Scan filesystem for new artifacts
DELETE /api/artifacts/:id Delete an artifact
GET /api/operations List task queue
POST /api/operations Create a new task for the agent
PATCH /api/operations/:id Update task status
DELETE /api/operations/:id Remove a task from queue
GET /api/search?q= Full-text search across sources and artifacts
POST /api/rebuild-indexes Rebuild FTS5 search index
GET /file/<path> Serve generated artifacts and assets

License

MIT

About

AI-powered study library with local web app for managing course materials, generating notes, exams, and Q&A sessions

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors