Typesense Plan — Phase 1: Deploy Typesense + Repo Indexer
This plan covers deploying the Typesense instance on Railway and building the repo-wide indexer. Phase 1 is the foundation — all other phases depend on a working Typesense instance with indexed repo content.
Prerequisites
- Railway project access (already have)
- OpenAI API key with access to
text-embedding-3-small - Typesense admin key (generated during setup)
Tasks
-
Create Typesense Railway service
- Deploy
typesense/typesense:latestDocker image - Set custom start command:
--data-dir /data --api-port 8108 --api-key $TYPESENSE_ADMIN_KEY - Add persistent volume at
/data(5GB) - Set environment variables:
TYPESENSE_ADMIN_KEY,OPENAI_API_KEY - Enable internal networking (no public domain)
- Verify health:
curl http://typesense.railway.internal:8108/health
- Deploy
-
Create the
uvilocollection- Write a script (
scripts/create-collection.ts) that sends the schema to Typesense - Schema includes:
id,title,summary,content,path,department(facet),project(facet),type(facet),source(facet),status(facet),visibility(facet),owner(facet),embedding(float[] withembedconfig foropenai/text-embedding-3-small, fromtitle + summary + content + project + status) - Run the script against the Railway Typesense instance
- Verify collection exists via Typesense API
- Write a script (
-
Build the repo indexer (
scripts/index-repo.ts)- Walk repo tree, find all
.mdfiles - Parse YAML frontmatter (title, status, owner, visibility)
- Extract body text (strip frontmatter, keep code fences as plain text)
- Derive
departmentfrom root-level folder name - Derive
typefrom path heuristics (knowledge, skill, spec, plan, state, project) - Derive
projectfrom path — folder name insideProjects/(e.g.,Forge/Projects/TypeSense/→TypeSense), empty string for non-project files - Extract
status,visibility,ownerfrom frontmatter (default to empty string if absent) - Generate AI summary: call gpt-4o-mini with file content, prompt for ≤100-word summary. One summary per file — chunks inherit the parent file’s summary.
- Set
source=repoon all documents - Chunk files >800 words into overlapping segments (~400 words, ~50-word overlap)
- Generate unique IDs: relative path for whole files,
path#chunk-Nfor chunks - Upsert into Typesense via
POST /collections/uvilo/documents/import - Support
--incrementalflag:git diff --name-only HEAD~1to find changed files, only re-index those - Add
npm run index:reposcript topackage.json
- Walk repo tree, find all
-
Test the indexer
- Run full index against the repo
- Verify document count matches expected file count
- Test search via Typesense API: keyword query, semantic query, hybrid query
- Test facet filtering: by department, project, type, source, status, visibility, owner
-
Add sidebar entries for Spec and Plan pages
- Add
Typesense_SpecandTypesense_Plan_Phase_1to.internal/astro.config.mjssidebar
- Add
-
Update project INDEX and README
- Add new files to
INDEX.md - Update
README.mdfolder structure
- Add new files to
-
Commit and push to
dev
Verification
-
curl http://typesense.railway.internal:8108/healthreturns{"ok":true} -
GET /collections/uviloreturns the schema - Full index completes without errors
- Search query
memory architecturereturnsForge/Knowledge/Memory_Architecture.mdas a top result - Incremental re-index processes only changed files