How xvalentim/neroedu-gemma3n works
Project Type and Purpose
• NeroEdu is a full-stack, cross-platform AI application for offline exam preparation. It provides three AI agents (essay grading, flashcard generation, mock exam creation) powered by a local Gemma 3n LLM (via Ollama) and TF-IDF retrieval. Multiple clients (Electron desktop, iOS app, Python scripts/notebooks) consume a FastAPI backend that orchestrates the AI flows.
File Structure Analysis
• Top-level directories:
• agent/ – LangGraph API store (vector indexes, pickles)
• app/ – FastAPI backend (main.py, routers, internal modules, database layer)
• mobile-ios/ – SwiftUI mobile client (Views, ViewModels, Services)
• neroedu-desktop/ – Electron + React desktop client (bundled FastAPI backend & Ollama via NSIS)
• neroedu-lp/ – Next.js landing page (static marketing site)
• data/, vectorstore/ – Exam corpora, TF-IDF CSVs and pickled models
• storage/ – Local JSON database for user data and settings
• notebooks/ & src/ – Research scripts and CLI utilities
README Insights
• Architecture is offline-first, uses:
• FastAPI (backend API & orchestration)
• Gemma 3n via Ollama as a local LLM runtime
• TF-IDF + cosine similarity for document retrieval
• Electron for desktop packaging, NSIS installer
• SwiftUI + local services for iOS
a. Main Components
• Clients:
• Desktop App (Electron + React)
• iOS App (SwiftUI)
• CLI/Notebooks (Python scripts)
• Marketing Site (Next.js)
• Backend API: FastAPI service with modular routers (essay, flashcards, exams)
• AI Agent Orchestrator: LangChain-style flows in app/internal
• Vector Store: TF-IDF indexes (CSV + .pkl files in vectorstore/)
• LLM Runtime: Ollama server hosting Gemma 3n (local container/process)
• Data Storage: JSON DB (storage/database.json) or SQLite abstraction (app/database.py)
• OCR Engine (mobile-iOS service) for scanning paper essays
b. Relationships & Interactions
• Clients → HTTP/IPC calls → FastAPI endpoints
• FastAPI → TF-IDF retrieval module → fetch relevant passages
• FastAPI → prompt builder → sends structured prompts → Ollama/Gemma 3n → LLM responses
• FastAPI → post-processing (parse JSON, score mapping) → returns to client
• Mobile iOS: camera input → OCRService → text → LLMService or backend API
• Electron desktop bundles and launches local FastAPI + Ollama; uses IPC or HTTP internally
c. Architectural Patterns & Principles
• Layered architecture: presentation (clients), API layer, orchestration layer, data layer
• Modular services: one router per AI agent
• “Lite RAG”: retrieval (TF-IDF) + generation (LLM)
• Offline-first: all components run locally, no cloud dependencies
• Bundling strategy: NSIS packs Python backend + Ollama with desktop app
d. Key Technologies & Frameworks
• Backend: Python 3.10+, FastAPI, LangChain, Ollama CLI/HTTP, TF-IDF (scikit-learn or custom)
• Desktop: Electron, React, TypeScript, NSIS installer
• Mobile: SwiftUI, Combine/ViewModels, custom OCRService & LLMService wrappers
• Landing: Next.js, TailwindCSS
• Storage: JSON file or SQLite via SQLAlchemy