| Security Aspect | Cloud AI | Local LLM | Winner |
|---|---|---|---|
| Data Privacy | ✗ Data sent to third party | ✓ All data stays local | Local LLM |
| API Key Security | ✗ Exposed in client | ✓ No API key needed | Local LLM |
| Network Security | ~ HTTPS but external | ✓ localhost only | Local LLM |
| Compliance (GDPR/CCPA) | ✗ Third-party processing | ✓ No data transfer | Local LLM |
| Cost | ✗ Per-request pricing | ✓ One-time hardware | Local LLM |
| Performance | ✓ Fast, cloud-scale | ~ Depends on hardware | Cloud AI |
| Model Quality | ✓ State-of-the-art | ~ Good but smaller | Cloud AI |
| Offline Capability | ✗ Requires internet | ✓ Works offline | Local LLM |
| Setup Complexity | ✓ Simple API call | ~ Requires installation | Cloud AI |
Use Ollama or LM Studio on Mac Mini. Eliminates data exfiltration risk and API key exposure. Recommended models: llama3.1:8b, codellama:13b
Add Content Security Policy to prevent XSS: script-src 'self'; connect-src 'self' http://localhost:11434
Use DOMPurify to sanitize all user-generated content before rendering. Prevent script injection in task notes and code.
Use crypto-js to encrypt sensitive data before storing. Derive key from user session or device fingerprint.
Configure Mac Mini firewall to only accept connections from 127.0.0.1. Block external network access to port 11434.
Replace eval() with Web Workers or iframe sandbox for safer code execution. Limit available APIs.
Implement client-side rate limiting for AI requests to prevent abuse even in local setup.
Log all AI interactions locally for security auditing. Store in encrypted format with timestamps.
curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3.1:8b
ollama serve (runs on localhost:11434)
const API_URL = 'http://localhost:11434/api/generate'
Switch to Local LLM (Ollama on Mac Mini) for maximum security and privacy. This architecture:
Trade-off: Slightly lower model quality compared to Claude, but significantly better security posture. For a learning application with sensitive student code, this is the right choice.