# 💻 Developer Guide

Want to contribute, fork, or understand how LearnAI TV works under the hood? You're in the right place!

🚀 Quick Start

Prerequisites

  • Git installed

  • Modern browser

  • Code editor (VS Code recommended)

  • (Optional) n8n instance for backend testing

Clone & Run

# Clone repository
git clone https://github.com/iavendas62-collab/learnai-tv.git
cd learnai-tv

# No build step needed! Just open in browser:
open index.html

# Or use a local server:
python -m http.server 8000
# Visit: http://localhost:8000

That's it! No npm install, no dependencies, no build tools.


📁 Project Structure

Why so simple?

  • ✅ No build complexity

  • ✅ Easy to understand for students

  • ✅ Deploy anywhere (GitHub Pages, Netlify, Vercel)

  • ✅ Fast load times (no frameworks)


🏗️ Architecture Overview

Frontend (Static HTML/CSS/JS)

Technology Choices:

Tech
Why We Chose It

Vanilla JS

No React overhead, easier debugging

CSS Grid/Flexbox

Modern layout without frameworks

KaTeX CDN

Math rendering without local build

No bundler

Direct deployment, transparent code

Backend (n8n Workflow)

Hosted on: Easypanel (Docker containers) Endpoint: https://iavendas-n8n.tkxtrv.easypanel.host/webhook/[id]

Workflow Components:

  1. Webhook node (receives POST)

  2. AI Agent node (orchestrates LLM + tools)

  3. OpenAI Chat Model (GPT-4.1-mini)

  4. Memory Buffer (session storage)

  5. 7x Tool nodes (MCP servers + Wolfram)

  6. Response node (returns JSON)


🔧 Configuration

Environment Variables

Frontend (app.js):

To use your own n8n instance:

  1. Deploy n8n (Easypanel, Railway, or self-host)

  2. Import workflow JSON (Hackathon CS girlies (final).json)

  3. Update WEBHOOK_URL in app.js

  4. Configure API credentials (OpenAI, Wolfram)

API Credentials Needed

Service
Purpose
Get Key

OpenAI

Primary LLM

https://platform.openai.com

Wolfram Alpha

Math computation

https://products.wolframalpha.com/api

Google Docs API

Curriculum content

https://console.cloud.google.com


🛠️ Development Workflow

1. Frontend Changes

Edit HTML:

Edit CSS:

Edit JavaScript:

2. Testing Locally

Open Browser DevTools (F12):

3. Deploy to Production


📊 Code Architecture

State Management

Global Variables (app.js lines 10-22):

Why Globals?

  • Single-page application (no routing)

  • State resets on page reload

  • Easier debugging (inspect in console)

  • No state management library needed

Function Organization

app.js structure (~1,200 lines):

Key Functions

Topic Extraction:

Quiz Parsing:

API Call:


🎨 Design System

Color Palette

Typography

Spacing System

Component Patterns

Button Variants:

Card Components:


🧪 Testing

Manual Testing Checklist

Functional Tests:

Cross-Browser Tests:

Responsive Tests:

Automated Testing (Future)


🔌 API Reference

Webhook Endpoint

URL: POST https://iavendas-n8n.tkxtrv.easypanel.host/webhook/313ee9cc-b465-4154-8cc9-4e8145dbd38b

Headers:

Request Body:

Response:

Study Modes

Mode
Purpose
Expected Response

list_topics

Get 8 topic names

Numbered list of topics

explicacao

Explain a topic

Detailed explanation with examples

chat

Conversational Q&A

Natural language answer

quiz

Generate 5 questions

Formatted quiz with separators

challenge

Generate 1 hard question

Single quiz question


🐛 Common Issues & Fixes

Issue: Topics show "Tópico 1, Tópico 2"

Cause: AI didn't respond with proper format, or parsing failed.

Fix:

Issue: Quiz parsing fails

Cause: AI used unexpected format.

Debug:

Solution: Expand parseQuiz() to handle more formats.

Issue: Chat doesn't show math formulas

Cause: KaTeX not loading or wrong syntax.

Fix:


🚀 Deployment Guide

GitHub Pages (Current)

Alternative: Vercel

Alternative: Netlify

n8n Deployment

Option 1: Easypanel (Current)

  • Docker-based

  • One-click deploy

  • Includes SSL

Option 2: Railway

Option 3: Self-Host


🤝 Contributing

How to Contribute

  1. Fork the repository

  2. Create a feature branch

  1. Make your changes

  2. Test thoroughly

  3. Commit with clear message

  1. Push and create PR

Code Style Guidelines

JavaScript:

  • Use const/let, not var

  • Descriptive function names: extractTopics() not getT()

  • Comments for complex logic

  • Error handling with try/catch

  • Console logs for debugging (remove in production)

CSS:

  • BEM-like naming: .quiz-option, .btn-primary

  • Group related styles

  • Use CSS variables for colors

  • Mobile-first media queries

HTML:

  • Semantic tags: <nav>, <main>, <section>

  • Accessible: aria-label, tabindex, alt text

  • No inline styles (use classes)

Feature Ideas

Good First Issues:

Advanced Features:


📚 Additional Resources

Learning Resources

  • Vanilla JS: https://javascript.info

  • CSS Grid: https://cssgrid.io

  • n8n Documentation: https://docs.n8n.io

  • Wolfram API: https://products.wolframalpha.com/api/documentation

  • MCP Protocol: https://modelcontextprotocol.io

Inspirations

  • Duolingo - Gamification mechanics

  • Khan Academy - Educational content structure

  • Netflix - TV-style interface

  • Quizlet - Quiz generation patterns


💬 Support

Questions?

  • 📧 Email: [your-email]

  • 💬 Discord: [hackathon-channel]

  • 🐙 GitHub Issues: https://github.com/iavendas62-collab/learnai-tv/issues

Found a bug? Open an issue with:

  1. Steps to reproduce

  2. Expected vs actual behavior

  3. Browser/device info

  4. Screenshots if applicable


📜 License

This project was created for the CS Girlies Hackathon 2025.

Open Source License: MIT

You're free to:

  • ✅ Use for personal/commercial projects

  • ✅ Modify and distribute

  • ✅ Fork and create derivatives

Attribution appreciated but not required! 🙏

Last updated