System Architecture
Stack overview
| Component | Choice | Cost |
|---|---|---|
| Frontend | Next.js + shadcn/ui | $0 |
| State management | useState | $0 |
| Backend | FastAPI (Python) | $0 |
| Database | SQLite | $0 |
| Auth | JWT + MFA (email code) | $0 |
| RAG framework | LangChain | $0 |
| Embeddings | Gemini Embedding 001 | ~$27 for all Sefaria ($0.15/1M tokens) |
| Vector DB | Weaviate (Elestio) | ~$6/month |
| LLM | Gemini 2.5 Flash | ~$0 (free tier) |
| Reranking | Cohere Rerank | $0 (free tier) |
| Observability | LangFuse (Elestio) | $0 |
| Parashah data | Sefaria API /calendars | $0 |
| Hosting | Elestio | ~$10/month |
| Total POC | ~$20-30/month |
Embeddings
Sefaria tested 18 models on their own texts and published the results:
| Model | Recall@1 | Cost for all Sefaria | Type |
|---|---|---|---|
| Gemini Embedding 001 | 93.9% | ~$27 ($0.15/1M tokens) | API |
| OpenAI text-embedding-3-large | 69.9% | ~$55 | API |
| OpenAI text-embedding-3-small | ~65% | ~$8 | API |
| DictaBERT (Hebrew specialized) | 1.7% | $0 | Local |
Our choice: Gemini Embedding 001. 3x cheaper AND 40% more accurate than OpenAI on Rabbinic texts.
Database and Auth
Database: SQLite. A single file on disk. No server to manage. Good enough for a POC. We move to PostgreSQL when we need multiple concurrent users.
Auth: JWT + MFA with email code.
- User registers with email
- Receives a verification code by email (MFA)
- Gets a JWT token after verification
- Token sent with every API request
- Stateless auth, no session storage needed
RAG Pipeline
Parashah of the week
Uses Sefaria's /calendars API endpoint which returns the current week's Torah portion. We display it as a suggested study topic when the user opens the app.
What Sefaria gives us (HuggingFace)
| Resource | What it is | Impact |
|---|---|---|
hebrew_library | 3.55M text segments, already chunked | Skip manual chunking |
english_library | 886K English segments | Ready to embed directly |
links | 3.74M cross-references | Knowledge graph for V2 |
| NER models | Detect citations in text | Auto-extract Sefaria refs |
| Embedding Leaderboard | 18 models benchmarked | Proved Gemini is best |
Acknowledgment
This project would not exist without Sefaria and their incredible work making Jewish texts accessible to everyone. Their open-source datasets on HuggingFace, their embedding benchmark, their NER models, and their API are what makes projects like this possible. As Sara Wolkenfeld (Chief Learning Officer at Sefaria) said: "Making our data available for others to use creatively has always been a core part of Sefaria's mission."