Backend Packages¶
internal/config¶
Viper-based configuration with four-tier loading:
- Built-in defaults (stealth flags, window size, scheduler)
config.yamlfile (.and$HOME/.stargrazersearch paths)- CLI flags (
--cdp-port,--headless,--chromium-path) and environment variables (STARGRAZER_prefix) - Runtime mutations via
Update()from the frontend UI
Structs: WindowConfig, BrowserConfig, SchedulerConfig, AppConfig.
Accessors: Get(), GetBrowser(), GetWindow(), GetScheduler(), Update(), Reset().
internal/browser¶
Singleton Chromium lifecycle manager (Manager). Responsibilities:
- Start/stop browser process with
--user-data-dir, CDP flags, and stealth flags - Load the bundled cookies extension and pin it in the Chrome toolbar via
Preferences - CDP helpers over WebSocket:
GetCookiesForDomains()— reads cookies via extension service worker or page fallbackSetCookiesViaCDP()— injects cookies viaNetwork.setCookieNavigateToURL()—Page.navigateon the first page targetOpenNewTab()— creates a tab via/json/newClickElement(),TypeText(),EvaluateExpression(),ScrollToElement()— automation primitives- Parse Netscape cookie format (
ParseNetscapeCookies) - Export/load cookies to/from JSON on disk (
ExportCookiesToDisk,LoadCookiesFromDisk) - Resolve bundled Chromium binary automatically (exe-relative and cwd-relative
assets/search)
internal/social¶
Platform definitions and session persistence:
- 6 platforms: Facebook, Instagram, TikTok, YouTube, LinkedIn, X
- Each
PlatformInfohas login URL, session domains, and login cookie names SessionStore— thread-safe, JSON-backed account status (accounts.json)SharedSessionDir()— single shared Chromium profile for all platformsEnsureSessionDir()— creates profile directory on first useFindPlatform()helper used byapp.go,scheduler, andkeepalive
internal/scheduler¶
Cron-based job scheduler using robfig/cron/v3:
- Job types:
session_keepaliveandupload - CRUD with JSON persistence to
schedules.json EnsureKeepAlive()— auto-creates a keep-alive job on cookie import; derives cron interval from cookie expiry (75% of shortest, clamped to 12 h – 7 d)- Keep-alive execution (
keepalive.go): auto-starts browser if needed, opens a tab, waits, re-exports cookies; auto-stops browser when done - Upload execution (stub in
keepalive.go): auto-starts browser; logs intent; full orchestration viaTriggerUploadinapp.go registerJob/unregisterJobmaintaincron.EntryIDper job
internal/logger¶
Thread-safe ring buffer (1 000 entries max):
- Levels:
info,warn,error,debug - Dual output: stdout + in-memory ring buffer
GetAll()returns entries in chronological order (handles wrap-around)Export()returns JSON bytes for the logs modalClear()flushes the buffer
internal/workflow¶
Upload workflow engine:
- Step types:
navigate,click,type,upload_file,wait,wait_navigation,evaluate - Template substitution in step values:
{{file}},{{caption}},{{hashtags}} PrepareSteps()— replaces placeholders without mutating originals- JSON persistence in
workflows/<platform>_upload.json(resolved relative to exe or cwd) DefaultWorkflows()— built-in steps for all 6 platforms
internal/automation¶
Per-platform, user-defined browser automation sequences:
- Step actions:
navigate,click,type,wait,evaluate,scroll Config— named automation with ordered[]Step; tracksRunCountandLastRunStore— thread-safe JSON persistence; one file per platform (automations/<platformID>.json)Save()— creates (assigns UUID) or updates (replaces by ID)Delete()— removes by ID; returnsfalsewhen not foundRecordRun()— incrementsRunCountand setsLastRun- Executed step-by-step via CDP from
app.go:executeStep()
app.go (Wails bindings surface)¶
All methods callable from the frontend via Wails bindings:
| Group | Methods |
|---|---|
| Browser | StartBrowser, StopBrowser, GetBrowserStatus, RestartBrowser |
| Config | GetBrowserConfig, UpdateBrowserConfig, ResetBrowserConfig |
| Social | GetPlatforms, OpenPlatform, CheckLoginStatus, CheckAllLoginStatus, PurgeSession, ImportCookies |
| Schedules | GetSchedules, CreateSchedule, UpdateSchedule, DeleteSchedule, PauseSchedule, ResumeSchedule, GetScheduleStats |
| Logs | GetLogs, ExportLogs, ClearLogs |
| Upload | SelectFile, TriggerUpload |
| Automation | GetAutomations, SaveAutomation, DeleteAutomation, RunAutomation |