CodeTuner is a native macOS code editor with an AI-powered backend. The project consists of:
- Frontend: SwiftUI-based macOS application
- Backend: Rust-based web server providing AI integration and code execution capabilities
- Located in
CodeTuner/directory - Uses SwiftUI for declarative UI
- Native macOS UI with dark/light mode support
- Multi-tab interface for editing files
- Real-time console output
- Git integration UI
- Located in
backend/directory - Uses Axum web framework
- Provides REST API endpoints
- Integrates with multiple AI providers (Gemini, OpenAI, Codex)
- Handles code execution in isolated environments
- Git operations support
# Build both frontend and backend
./build.sh
# Or build separately
cd backend && cargo build --release
# Build frontend in Xcode# Start backend server (port 3000)
cd backend && cargo run
# Run frontend from Xcode
# Set backend URL in environment: API_URL=http://localhost:3000backend/.env- Environment variables for API keys and settingsCodeTuner/Config.swift- Frontend configuration
backend/src/models.rs- Backend data structuresCodeTuner/Models/AppState.swift- Frontend state management
backend/src/main.rs- Main routing and server setupbackend/src/git.rs- Git operationsbackend/src/runner.rs- Code executionbackend/src/ai.rs- AI provider integrations
CodeTuner/Views/ContentView.swift- Main UI viewCodeTuner/Views/CodeEditorView.swift- Code editing interfaceCodeTuner/Views/GitView.swift- Git operations UI
- Copy
backend/.env.exampletobackend/.env - Add your API keys for Gemini, OpenAI, or Codex
- Install Rust dependencies with
cargo build - Open
CodeTuner.xcodeprojin Xcode - Run backend server, then frontend application
- Update
backend/src/ai.rswith new provider implementation - Add provider enum variant in
backend/src/models.rs - Update UI in
CodeTuner/Views/AIView.swift
- Add syntax highlighting rules in
backend/src/code/highlighter.rs - Update code runner in
backend/src/runner.rs - Add language icon to frontend resources
- Implement backend logic in
backend/src/git.rs - Add API endpoints in
backend/src/main.rs - Create UI components in
CodeTuner/Views/GitView.swift
- Backend tests:
cd backend && cargo test - Frontend tests: Run through Xcode Test Navigator
- Integration tests: Test frontend against running backend
- Backend not starting: Check if port 3000 is available
- AI requests failing: Verify API keys in
.envfile - Git operations not working: Ensure git is initialized in the project directory
- Code execution failing: Check if the language runtime is installed
- Backend logs: Check console output for Rust server
- Frontend logs: Use Xcode console for SwiftUI logs
- API issues: Check Network tab in Xcode or use curl to test endpoints
- Git issues: Run git commands manually to verify repository state
- Backend uses async/await for concurrent operations
- Frontend uses Combine for reactive updates
- Large files are streamed to avoid memory issues
- AI requests have timeout configurations
- API keys are loaded from environment variables only
- Code execution is sandboxed
- File operations are restricted to project directory
- No sensitive data is logged
When making changes:
- Create a feature branch
- Update tests for new functionality
- Ensure backward compatibility for API changes
- Update documentation as needed
- Test both frontend and backend integration