Project Structure
Understand the Yap codebase architecture
Overview
Yap is built with Wails, combining a Go backend with a React frontend.
yap/
├── app.go # Main application logic
├── main.go # Wails entry point
├── internal/ # Go packages
├── frontend/ # React application
└── build/ # Build assets and output
Entry Points
main.go
Wails application entry point. Configures:
- Window size and properties
- Menu binding
- Asset handling
app.go
Core application struct with methods exposed to the frontend:
- Recording state management
- Transcription coordination
- History management
- Configuration
Internal Packages
internal/audio
Audio recording using PortAudio.
| File | Purpose |
|---|---|
recorder.go | PortAudio recording at 16kHz mono |
wav.go | WAV file encoding/decoding |
Key types:
Recorder— Manages audio captureAudioLevel— Real-time level monitoring
internal/hotkey
Global hotkey detection.
| File | Purpose |
|---|---|
hotkey_darwin.go | macOS implementation (CGO/Cocoa/Carbon) |
hotkey_other.go | Stub for other platforms |
Supports:
- Right/Left Option keys
- Fn key
- Double-tap detection
internal/models
Configuration and model management.
| File | Purpose |
|---|---|
config.go | App settings (JSON persistence) |
manager.go | Model download from HuggingFace |
stats.go | Usage statistics tracking |
internal/transcribe
Transcription engine implementations.
| File | Purpose |
|---|---|
engine.go | Interface definition, types |
whisper_local.go | whisper.cpp CLI integration |
openai.go | OpenAI API client |
type Engine interface {
Transcribe(audioPath string) (string, error)
}
internal/overlay
Native recording overlay.
| File | Purpose |
|---|---|
overlay_darwin.go | macOS NSPanel with waveform |
overlay_other.go | Stub for other platforms |
internal/system
System integration utilities.
| File | Purpose |
|---|---|
clipboard.go | Cross-platform clipboard |
clipboard_darwin.go | macOS CGEvent paste simulation |
clipboard_other.go | Other platforms |
internal/tray
System tray / menu bar integration.
| File | Purpose |
|---|---|
tray.go | Systray menu with Start/Stop, Show, Quit |
internal/sounds
Audio feedback.
| File | Purpose |
|---|---|
sounds.go | Sound playback manager |
start.mp3 | Recording start sound |
stop.mp3 | Recording stop sound |
Frontend
React 18 + TypeScript + Vite.
frontend/
├── src/
│ ├── App.tsx # Main UI component
│ ├── App.css # Styles
│ ├── RecordingOverlay.tsx # Web fallback overlay
│ ├── main.tsx # React entry
│ └── wailsjs/ # Generated Wails bindings
├── package.json
├── tsconfig.json
└── vite.config.ts
Wails Bindings
frontend/src/wailsjs/ contains auto-generated TypeScript bindings for Go methods:
import { ToggleRecording, GetState } from '../wailsjs/go/main/App';
// Call Go methods from React
await ToggleRecording();
const state = await GetState();
Build Directory
build/
├── appicon.png # Application icon (PNG)
├── appicon.icns # macOS icon
├── darwin/ # macOS-specific
│ └── Info.plist # App metadata
├── windows/ # Windows-specific
│ ├── icon.ico
│ └── installer/ # NSIS installer config
└── bin/ # Build output
Data Flow
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Hotkey │────▶│ app.go │────▶│ Audio │
│ Detection │ │ (Wails) │ │ Recording │
└─────────────┘ └──────┬───────┘ └──────┬──────┘
│ │
▼ ▼
┌──────────────┐ ┌─────────────┐
│ Frontend │ │ Transcribe │
│ (React) │◀────│ Engine │
└──────────────┘ └─────────────┘
│
▼
┌──────────────┐
│ Clipboard │
│ + Paste │
└──────────────┘
Key Technologies
| Component | Technology |
|---|---|
| Desktop Framework | Wails v2 |
| Backend | Go 1.23 |
| Frontend | React 18 + TypeScript |
| Build Tool | Vite |
| Audio | PortAudio |
| Local Transcription | whisper.cpp |
| Cloud Transcription | OpenAI API |