Meta Llama 4 Hackathon 1st Place winning project - https://x.com/MetaforDevs/status/1937233386453762423
A macOS application that monitors student activity during class using AI analysis and stores the data in MongoDB. The app automatically retrieves assignments from teachers and analyzes student screen activity in real-time.
- Real-time screen capture using ScreenCaptureKit (every 10 seconds)
- AI-powered activity monitoring using Llama-4-Scout-17B-16E-Instruct-FP8
- Automatic assignment retrieval from MongoDB (every 5 seconds)
- Image optimization - scales screenshots to 720p for faster AI inference
- Focus score tracking with intelligent scoring algorithm
- Active/inactive status tracking with automatic updates
- 4-field analysis:
- Score (0-5) for on-task behavior
- Description (1-sentence summary of student activity)
- Short Description (3-word max summary)
- Suggestion for teacher (on-task/sussy/needs reminder)
- Color-coded UI for quick status assessment
- Context-aware analysis considering active windows and screen content
The app uses two MongoDB collections:
Each document contains comprehensive student data:
{
"id": "1",
"name": "Kevin",
"focusScore": 8,
"description": "Student is working on math problems in Google Docs",
"shortDescription": "Math homework",
"suggestion": "on-task",
"history": [
"Working on math problems",
"Reading assignment instructions",
"Taking notes in notebook app"
],
"screenshot": "base64_encoded_image_data",
"classroom": "1",
"active": true,
"lastUpdated": "2025-06-22T10:30:00Z"
}
Teachers can set assignments that students automatically receive:
{
"description": "Watch MrBeast",
"classroom": "1"
}
The focus score (0-10) is dynamically updated based on Llama AI analysis:
- Llama score ≤ 2: Decrease focus score by 1 (minimum 0)
- Llama score ≥ 4: Increase focus score by 1 (maximum 10)
- Llama score = 3: Keep focus score unchanged
- Initial score: 10 for new students
- Maintains rolling history of last 60 student activities
- Stores full descriptions for pattern analysis
- Automatically managed with newest entries first
- macOS 13.0+ (for ScreenCaptureKit support)
- Xcode 14.0+
- MongoDB Atlas account or local MongoDB instance
-
Copy and configure the config file:
cp Config.template.swift LlamaProctor/Config.swift
-
Update MongoDB connection in
LlamaProctor/Config.swift
:struct Config { static let mongoDBURI = "your_mongodb_connection_string_here" }
-
Set up MongoDB collections:
- Create database:
LlamaProctorDB
- Create collections:
students
andassignments
- Add initial assignment document for testing
- Create database:
- Open
LlamaProctor.xcodeproj
in Xcode - Build and run the project (⌘+R)
- Grant screen recording permissions when prompted:
- System Settings → Privacy & Security → Screen Recording
- Enable for LlamaProctor
- The app automatically starts monitoring once permissions are granted
- MongoDB integration with real CRUD operations
- Automatic assignment retrieval from teachers
- Real-time screen capture and AI analysis
- Focus score calculation and history tracking
- Screenshot storage with base64 encoding
- Active/inactive status management
- Secure credential management
- Image scaling for optimized AI inference
- Color-coded UI with 4-field analysis display
- Screenshot capture: Every 10 seconds
- Window detection: Every 1 second
- Assignment sync: Every 5 seconds
- AI analysis: Triggered after each screenshot (when assignment exists)
- MongoDB updates: After each successful AI analysis
- StreamManager: Handles screen capture using ScreenCaptureKit
- MongoDBService: Manages all database operations
- ContentView: Main UI and coordination logic
- AI Integration: Direct API calls to Llama service
- Teacher sets assignment in MongoDB
- Student app retrieves assignment every 5 seconds
- App captures screenshot every 10 seconds
- Screenshot sent to Llama AI for analysis
- AI response parsed and stored in MongoDB
- UI updated with latest analysis and focus score
- Local processing: Screenshots analyzed via API, not stored permanently
- Secure credentials: MongoDB URI stored in gitignored Config.swift
- Base64 encoding: Screenshots stored efficiently in database
- Permission-based: Requires explicit screen recording permission
- Masked logging: Database credentials masked in console output
To fully utilize the system, teachers need to:
- Access MongoDB to set assignments in the
assignments
collection - Monitor student data in the
students
collection - Use classroom field to manage multiple classes
Example assignment creation:
db.assignments.replaceOne(
{ classroom: "1" },
{ description: "Complete Chapter 5 math exercises", classroom: "1" },
{ upsert: true }
)