Development Guide
Development Guide
Getting Started
Prerequisites
- Node.js 18+
- npm or yarn
- (Optional) Ollama for local AI
Quick Start
# Clone and install
git clone https://github.com/michael-borck/study-buddy.git
cd study-buddy
npm install
# Development with hot reload
npm run electron-dev
# Or run components separately
npm run dev # Next.js only
npm run electron # Electron only (after Next.js is running)
Development Scripts
| Command | Description |
|---|---|
npm run dev |
Start Next.js development server |
npm run electron |
Launch Electron app (needs Next.js running) |
npm run electron-dev |
Recommended: Start both Next.js and Electron with hot reload |
npm run build |
Build Next.js for production |
npm run dist |
Build Electron distributables |
npm run lint |
Run ESLint |
Linux Development Notes
Sandbox Issues
If you encounter sandbox errors on Linux:
FATAL:sandbox/linux/suid/client/setuid_sandbox_host.cc:163
This is already handled in our scripts with --no-sandbox flags. If you see this error, ensure youβre using:
npm run electron-dev(recommended)npm run electron
Both scripts disable the sandbox for development.
Graphics Warnings
These warnings are normal on Linux and donβt affect functionality:
MESA-INTEL: warning: Haswell Vulkan support is incomplete
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
Configuration
Environment Variables
Copy .env.example to .env.local and configure:
# AI Provider (default: ollama)
LLM_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1:8b
# Search (default: disabled)
SEARCH_ENGINE=disabled
Settings UI
Access settings at http://localhost:3000/settings or use the Settings link in the app header.
Architecture
Project Structure
study-buddy/
βββ app/ # Next.js App Router
β βββ api/ # API routes
β β βββ getChat/ # LLM streaming endpoint
β β βββ getSources/ # Search endpoint
β β βββ getParsedSources/ # Content parsing
β βββ settings/ # Settings page
β βββ page.tsx # Main app page
βββ components/ # React components
βββ utils/
β βββ providers/ # LLM provider abstractions
βββ main.js # Electron main process
βββ .github/workflows/ # CI/CD workflows
Key Components
- Provider System:
utils/providers/- Abstracted LLM providers - Search System: Optional web search with multiple backends
- Settings: Browser-based configuration UI
- Electron: Desktop app wrapper with embedded Next.js server
Testing
# Build test
npm run build
# Lint check
npm run lint
# Local distribution build
npm run dist
Debugging
Electron DevTools
In development, DevTools open automatically. In production builds, use:
- macOS/Linux:
Cmd/Ctrl + Shift + I - Windows:
F12
Logs
- Electron logs: Check terminal output
- Next.js logs: Available in Electron DevTools console
- API logs: Server-side logs in terminal
Common Issues
- Port conflicts: Next.js auto-increments ports (3000 β 3001 β 3002β¦)
- Ollama not found: Ensure Ollama is running on
localhost:11434 - Build failures: Check
npm run buildworks beforenpm run dist
Contributing
Code Style
- ESLint configuration enforced
- Prettier for formatting
- TypeScript strict mode
- Conventional commit messages
Pull Request Process
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push branch:
git push origin feature/amazing-feature - Open Pull Request
Release Process
- Update version:
npm version patch/minor/major - Push changes:
git push && git push --tags - GitHub Actions will build and release automatically
Deployment
GitHub Actions
- Build workflow: Tests and builds on every push
- Release workflow: Creates distributables on git tags
- PR checks: Code quality enforcement
Manual Release
# Update version and create release
npm version patch
git push origin main --tags
# Or build locally
npm run dist
Troubleshooting
Cannot start Electron
- Check Node.js version (18+ required)
- Clear node_modules:
rm -rf node_modules package-lock.json && npm install - Try sandbox flags:
npm run electron(uses--no-sandbox)
Build errors
- Ensure dependencies are installed:
npm ci - Check TypeScript:
npx tsc --noEmit - Test Next.js build:
npm run build
Performance issues
- Check Ollama is running:
ollama list - Monitor memory usage in Activity Monitor/Task Manager
- Close unused browser tabs/applications
Need help? Open an issue on GitHub or check our troubleshooting guide.