/* --- Title: ARCHITECTURE.md Version: 1.1 --- */ /* --- Section 1: System Architecture Flow --- */ 1. THE FRONTEND (User Interface) - Built with plain HTML, CSS, and Vanilla JavaScript. - Splits into two views: Student Mode and Parent Mode (protected by a PIN). - Does NOT directly access the database or the AI. - Sends requests to the Rust backend using Tauri's "invoke" commands. 2. THE TAURI BRIDGE (The Middleman) - Acts as a secure wall between the web interface and the computer. - Ensures the frontend can only call specific, pre-approved Rust functions. - Passes data back and forth in JSON format. 3. THE RUST BACKEND (The Brains) - Command Handlers: Receive requests from the frontend (e.g., "save this card", "check this answer"). - SQLite Manager: Reads and writes data to the local database safely. - Auth Manager: Verifies the Parent PIN using a secure, slow hashing algorithm. - AI & Process Manager: Checks if the bundled "ollama.exe" is running in the background. If not, silently starts it. Sends prompts to it and receives generated questions. 4. LOCAL SYSTEM RESOURCES (The Files) - app_data.db: The SQLite database storing all cards, students, and scores. - ollama.exe: The portable AI engine, hidden in the app's resources folder. - Model Files (.gguf): The actual AI "brain" (e.g., a 2B model), downloaded by the parent through the Settings screen and saved to the Windows AppData folder. /* --- Section 2: Project Folder Structure --- */ homeschool-app/ │ ├── src/ # Frontend vanilla web assets │ ├── index.html # Main entry point for the single-page app │ ├── css/ │ │ └── styles.css # All application styling │ └── js/ │ ├── app.js # Main app initialization, routing, Tauri listeners │ ├── parent.js # Parent mode DOM logic (create cards, dashboard) │ ├── student.js # Student mode DOM logic (answer cards, feedback) │ └── db-helpers.js # Frontend wrappers that call Tauri commands │ ├── src-tauri/ # Rust backend and Tauri configuration │ ├── Cargo.toml # Rust dependencies (e.g., rusqlite, reqwest, sha2) │ ├── tauri.conf.json # Tauri app config, window settings, security rules │ ├── capabilities/ # Tauri v2 security permissions │ │ └── default.json # Strictly defines which JS commands are allowed to run │ ├── resources/ # Static files bundled into the final Windows installer │ │ └── ollama.exe # The portable Ollama executable for Windows │ └── src/ │ ├── main.rs # Tauri entry point, sets up DB, starts Ollama process │ ├── commands/ │ │ ├── mod.rs # Registers all commands with Tauri │ │ ├── parent_commands.rs# Handles creating/editing cards, reviewing AI suggestions │ │ ├── student_commands.rs# Handles submitting answers, fetching next card │ │ └── ai_commands.rs # Handles triggering AI generation, validating JSON │ ├── db/ │ │ ├── mod.rs # Database initialization logic │ │ ├── migrations.rs # SQL scripts to create tables on first run │ │ └── queries.rs # Reusable functions to insert/select data │ └── ai/ │ ├── mod.rs # AI module entry point │ ├── process.rs # Logic to find and silently start ollama.exe │ └── validator.rs # Strict checks to ensure AI output is safe/valid │ └── README.md # Project instructions (optional) /* --- End of ARCHITECTURE.md Version: 1.1 --- */