Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Django settings
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1

# Cloudflare AI credentials
CLOUDFLARE_ACCOUNT_ID=your-cloudflare-account-id
CLOUDFLARE_API_TOKEN=your-cloudflare-api-token

# Optional: Cloudflare Worker URL (if deployed)
CLOUDFLARE_WORKER_URL=https://learnpilot-ai.your-subdomain.workers.dev
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
__pycache__/
*.py[cod]
*.pyo
*.pyd
*.so
*.egg
*.egg-info/
dist/
build/
.eggs/
.env
.venv/
venv/
env/
ENV/
db.sqlite3
*.sqlite3
*.log
.DS_Store
staticfiles/
media/
.idea/
.vscode/
*.swp
*.swo
node_modules/
.node_modules/
workers/.wrangler/
workers/node_modules/
106 changes: 105 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,106 @@
# learnpilot
AI-powered personalized learning lab that adapts to each learner in real time. Combines natural language processing, adaptive curricula, intelligent tutoring, and progress tracking to create a dynamic educational experience with interactive explanations, guided practice, and continuous feedback.
AI-powered personalized learning lab that adapts to each learner in real time. Combines natural language processing, adaptive curricula, intelligent tutoring, and progress tracking to create a dynamic educational experience with interactive explanations, guided practice, and continuous feedback. Uses Cloudflare AI Python workers

## Features

- 🧠 **Adaptive Curricula** – Cloudflare Workers AI generates a personalised learning path based on each learner's skill level, learning style, and goals.
- 💬 **Intelligent Tutoring** – Real-time AI tutor chat powered by `@cf/meta/llama-3.1-8b-instruct` explains concepts, answers questions, and adapts to the learner.
- 📈 **Progress Tracking** – XP system, day streaks, per-lesson scores, and AI-generated progress insights.
- ✏️ **Guided Practice** – AI-generated practice questions with instant evaluation and constructive feedback.
- 🗺️ **Personalised Paths** – Each learner gets a unique ordered learning path tailored to their knowledge gaps and goals.

## Architecture

```
LearnPilot Django app (web UI + REST API)
│ HTTP (when CLOUDFLARE_WORKER_URL is configured)
Cloudflare Python Worker (workers/src/worker.py)
│ Workers AI binding (env.AI)
Cloudflare Workers AI (@cf/meta/llama-3.1-8b-instruct)
```

When `CLOUDFLARE_WORKER_URL` is **not** set, the Django app calls the
[Cloudflare Workers AI REST API](https://developers.cloudflare.com/workers-ai/get-started/rest-api/)
directly using your `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN`.

## Quick Start

### 1. Clone & install dependencies

```bash
git clone https://github.com/alphaonelabs/learnpilot.git
cd learnpilot
pip install -r requirements.txt
```

### 2. Configure environment

```bash
cp .env.example .env
# Edit .env and set:
# SECRET_KEY, CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN
```

### 3. Initialise the database

```bash
python manage.py migrate
python manage.py seed_data # Loads sample topics, courses, and lessons
python manage.py createsuperuser
```

### 4. Run the development server

```bash
python manage.py runserver
```

Open [http://127.0.0.1:8000/](http://127.0.0.1:8000/) in your browser.

## Deploy Cloudflare Python Worker (optional)

See [`workers/README.md`](workers/README.md) for step-by-step deployment instructions.

Once deployed, set `CLOUDFLARE_WORKER_URL` in your `.env` to route AI
requests through the edge worker for lower latency.

## Running Tests

```bash
python manage.py test tests
```

## Project Structure

```
learnpilot/
├── manage.py
├── requirements.txt
├── .env.example
├── learnpilot/ # Django project settings & root URLs
├── learning/ # Main Django app
│ ├── models.py # Topic, Course, Lesson, LearnerProfile, Progress, …
│ ├── views.py # Dashboard, course list, tutoring session, progress
│ ├── urls.py
│ ├── admin.py
│ ├── ai/
│ │ ├── cloudflare_ai.py # Cloudflare Workers AI HTTP client
│ │ ├── tutor.py # IntelligentTutor – explain, practice, evaluate
│ │ └── adaptive.py # AdaptiveCurriculum – path generation, difficulty
│ └── management/commands/
│ └── seed_data.py # Sample topics, courses, and lessons
├── templates/ # Django HTML templates (Tailwind CSS via CDN)
├── static/
│ ├── css/main.css
│ └── js/tutor.js # Real-time tutor chat UI
├── tests/ # Unit & integration tests
└── workers/ # Cloudflare Python Worker
├── wrangler.toml
├── src/worker.py # Edge worker with Cloudflare AI bindings
└── README.md
```

Empty file added learning/__init__.py
Empty file.
69 changes: 69 additions & 0 deletions learning/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""Admin registration for learning models."""

from django.contrib import admin

from .models import (
AdaptivePath,
Course,
Lesson,
LearnerProfile,
LearningSession,
Message,
PathLesson,
Progress,
Topic,
)


@admin.register(Topic)
class TopicAdmin(admin.ModelAdmin):
list_display = ("name", "difficulty", "icon")
search_fields = ("name",)


@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
list_display = ("title", "topic", "difficulty", "estimated_hours", "is_published")
list_filter = ("topic", "difficulty", "is_published")
search_fields = ("title",)


@admin.register(Lesson)
class LessonAdmin(admin.ModelAdmin):
list_display = ("title", "course", "lesson_type", "order", "xp_reward")
list_filter = ("course__topic", "lesson_type")
search_fields = ("title",)
ordering = ("course", "order")


@admin.register(LearnerProfile)
class LearnerProfileAdmin(admin.ModelAdmin):
list_display = ("user", "skill_level", "learning_style", "total_xp", "streak_days")
search_fields = ("user__username",)


@admin.register(Progress)
class ProgressAdmin(admin.ModelAdmin):
list_display = ("learner", "lesson", "score", "completed", "attempts")
list_filter = ("completed",)


@admin.register(AdaptivePath)
class AdaptivePathAdmin(admin.ModelAdmin):
list_display = ("learner", "topic", "is_active", "created_at")
list_filter = ("topic", "is_active")


admin.register(PathLesson)(admin.ModelAdmin)


@admin.register(LearningSession)
class LearningSessionAdmin(admin.ModelAdmin):
list_display = ("learner", "lesson", "started_at", "is_active")
list_filter = ("is_active",)


@admin.register(Message)
class MessageAdmin(admin.ModelAdmin):
list_display = ("session", "role", "created_at")
list_filter = ("role",)
Empty file added learning/ai/__init__.py
Empty file.
Loading