Mika

Legaci — Your story, in motion.

Production‑grade web app that models a user’s personality and memories, stores context in a vector DB, and presents an interactive 3D disco ball. Privacy‑first, passkey auth, RAG via Qdrant, and optional streaming TTS.

Monorepo layout

Prerequisites

Quick start (local development)

1) Install dependencies

pnpm -C backend install
pnpm -C frontend install

2) Create and fill environment file

3) Start local services (optional, if not using managed providers)

docker run --name legaci-pg -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=legaci -p 5432:5432 -d postgres:16
docker run -p 6333:6333 -p 6334:6334 -d qdrant/qdrant:latest
docker run -p 6379:6379 --name legaci-redis -d redis:7

4) Database push (create tables)

cd backend
npx prisma db push --schema=prisma/schema.prisma
cd ..

5) Run dev servers

pnpm -C backend dev
pnpm -C frontend dev
npx ts-node backend/src/worker/embeddingsWorker.ts

Ensure backend/.env is loaded in your shell before starting the worker (or use dotenvx). On Windows, you can run it in a terminal where you’ve set the env vars or use cross-env.

Environment variables (backend/.env)

Use backend/.env.example as a reference. Minimal local-only configuration:

NODE_ENV=development
NEXTAUTH_URL=http://localhost:3000
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/legaci
FIELD_ENCRYPTION_KEY=REPLACE_WITH_64_HEX_CHARS
OPENROUTER_API_KEY=your_openrouter_key
CHAT_MODEL=anthropic/claude-3.5-sonnet
EMBEDDING_MODEL=text-embedding-3-large
QDRANT_URL=http://localhost:6333
QDRANT_COLLECTION=legaci_vectors
QDRANT_VECTOR_SIZE=3072
REDIS_URL=redis://localhost:6379
RP_NAME=Legaci
RP_ID=localhost

Generate FIELD_ENCRYPTION_KEY with:

openssl rand -hex 32

Important: QDRANT_VECTOR_SIZE must match your embedding model:

Provider-specific guidance (production)

1) Postgres (Neon)

2) Qdrant Cloud

3) Redis (Upstash)

4) OpenRouter (LLM + embeddings)

5) ElevenLabs (TTS)

6) WebAuthn

7) OAuth providers

Running in production

1) Set all env vars in backend/.env (do not commit)

2) Build and start

pnpm -C backend build && pnpm -C backend start

3) Start the embeddings worker

4) Ensure Qdrant collection exists; the app auto-creates it on first upsert/search

5) Configure HTTPS and secure cookies (production sets Secure; SameSite=Strict automatically)

Security notes

Testing

Troubleshooting

License

MIT