TextBookLive is a web application that transforms images of study materials and textual prompts into live, interactive language learning exercises.
Disclaimer: This project is intended for educational purposes. Users are solely responsible for ensuring they have the legal rights to any content they upload or generate.
- Upload Anything: Upload an image or provide a description of the material you want to learn from.
- AI Generation: The system analyzes the image and generates interactive exercises.
- Live Feedback: Complete the exercises and get immediate validation.
- Backend (
/backend): Written in Go. Handles file uploads and integration with the Gemini VLM API to generate exercises. - Frontend (
/frontend): Built with Lit web components and TypeScript. Implements the A2UI (Agent-to-User Interface) framework and communicates via ag-ui.
- Gemini API Key: Get a valid API key from Google AI Studio.
- Firebase Project: Set up Authentication (Email/Password & Google) and generate a Service Account Key. See the Firebase docs for more details.
- Copy
.env.exampleto.envin the root directory:cp .env.example .env
- Fill in the
.envfile with your Gemini API Key and Firebase Configuration (Web API Key, domains, etc.). - Place your Firebase Service Account JSON file in
backend/textbooklive-service-key.json.
You can launch the entire project (database, backend, frontend) using Docker Compose:
docker compose up --build -dApply the database schema:
docker compose exec -T db psql -U postgres -d textbooklive < backend/internal/db/schema.sqlThe application will be available at:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8080
If you prefer to run the backend and frontend locally for development, you can run them without containerization.
- Start only the database:
docker compose up db -d
- Follow the backend and frontend setup below.
- Place your Firebase Service Account JSON file in
backend/textbooklive-service-key.jsonor explicitly export theGOOGLE_APPLICATION_CREDENTIALSenvironment variable to its path. - Set the following environment variables:
GEMINI_API_KEY="your_api_key"
GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/textbooklive-service-key.json"- Run the go project from the
backend/directory:
go run cmd/server/main.go- Create a
.envfile in thefrontend/directory (or use the root.envif your Vite config resolves it) with the following content matched from your Firebase config:VITE_FIREBASE_API_KEY=your_firebase_api_key
- Build and run:
npm install
npm run dev- Access the frontend at
http://localhost:3000.
- A2UI: The UI is dynamically rendered based on the AI's response. The backend returns a JSON description of the UI components (inputs, questions), which the frontend interprets and renders. The spec is available in the
frontend/specificationdirectory after runningmake spec-setup. - ag-ui: Handles the communication protocol between the client and the agentic backend.