Skip to content

JonahSutch/cf_ai_study_helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Study Helper - Cloudflare Workers

IMPORTANT NOTE - This README.md was generated by AI based on changes made to the repository and overall workflow. IMPORTANT NOTE # 2 - This project is in progress. There will be changes rolling out on a weekly basis.

An intelligent study companion built with Cloudflare Workers, Workers AI (Llama 3.3), and Durable Objects for personalized test preparation.

Features

  • Serverless Architecture: Runs entirely on Cloudflare Workers
  • AI-Powered: Uses Llama 3.3 70B via Workers AI for intelligent content generation
  • Multiple Study Modes:
    • 📚 Flashcards: Generate AI-powered flashcards for any subject
    • 🎯 Multiple Choice Quiz: Practice with questions that include hint dropdowns
    • Graded Test: Take comprehensive tests with AI grading and feedback
  • Class Validation: AI verifies if your subject is valid before generating content
  • Persistent Sessions: Durable Objects store your study progress
  • Beautiful UI: Clean, responsive interface optimized for studying
  • Fast & Scalable: Global edge network deployment

Project Structure

.
├── src/
│   ├── index.js                        # Main Worker entry point & routing
│   ├── chatStorage.js                  # Durable Object for session storage
│   ├── handlers/                       # API endpoint handlers
│   │   ├── validate-class.js           # Class validation endpoint
│   │   ├── generate-flashcards.js      # Flashcard generation endpoint
│   │   ├── generate-quiz.js            # Quiz generation endpoint
│   │   ├── generate-test.js            # Test generation endpoint
│   │   ├── grade-test.js               # Test grading endpoint
│   │   └── get-session.js              # Session retrieval endpoint
│   ├── services/                       # Business logic services
│   │   ├── ai-service.js               # Workers AI integration
│   │   └── storage-service.js          # Durable Objects integration
│   └── utils/                          # Utility functions
│       ├── constants.js                # Configuration constants
│       ├── validators.js               # Input validation
│       ├── response-helpers.js         # HTTP response helpers
│       └── json-parser.js              # AI response parsing
├── wrangler.toml                       # Cloudflare Workers configuration
└── package.json                        # Project dependencies

Prerequisites

  • Node.js (v16 or later)
  • npm or yarn
  • Cloudflare account
  • Wrangler CLI

Setup

  1. Install dependencies:

    npm install
  2. Login to Cloudflare:

    wrangler login
  3. Run locally:

    npm run dev
  4. Deploy to Cloudflare:

    npm run deploy

How It Works

  1. User Interface: Clean HTML/CSS/JS study interface served directly from the Worker
  2. API Endpoints: Modular handlers process requests for validation, content generation, and grading
  3. AI Service: Centralized service layer handles all Workers AI interactions with Llama 3.3 70B
  4. Storage Service: Abstraction layer for Durable Objects manages session state and study content
  5. Durable Objects: Each study session gets a unique Durable Object instance to persist progress
  6. Persistent Sessions: Study progress, generated content, and quiz results are maintained across page refreshes

API Endpoints

  • GET / - Study helper interface
  • POST /api/validate-class - Validate if a class/subject is valid
    {
      "className": "Biology 101"
    }
  • POST /api/generate-flashcards - Generate flashcards for a subject
    {
      "className": "Biology 101",
      "topic": "Cell Structure",
      "sessionId": "optional-session-id"
    }
  • POST /api/generate-quiz - Generate multiple choice quiz
    {
      "className": "Biology 101",
      "topic": "Cell Structure",
      "sessionId": "optional-session-id"
    }
  • POST /api/generate-test - Generate a graded test
    {
      "className": "Biology 101",
      "topic": "Cell Structure",
      "sessionId": "optional-session-id"
    }
  • POST /api/grade-test - Submit test for AI grading
    {
      "answers": ["answer1", "answer2"],
      "sessionId": "session-id"
    }

Configuration

Edit wrangler.toml to customize:

  • Worker name
  • AI model
  • Durable Objects settings

Study Modes

1. Flashcards 📚

Generate interactive flashcards on any topic. Click to flip between question and answer sides.

2. Multiple Choice Quiz 🎯

Practice with AI-generated multiple choice questions. Each question includes:

  • 4 answer options
  • Expandable hint dropdown for guidance
  • Instant feedback on your answers

3. Graded Test ✅

Take a comprehensive test that the AI will grade:

  • Multiple questions covering the topic
  • Submit all answers at once
  • Receive detailed feedback and scoring
  • Review correct answers and explanations

Technologies

  • Cloudflare Workers
  • Workers AI (Llama 3.3 70B)
  • Durable Objects
  • JavaScript
  • HTML/CSS

License

MIT

About

AI powered study helper for CS classes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published