feat: build Go-based SearXNG-compatible search service

Implement an API-first Go rewrite with local engine adapters, upstream fallback, and Nix-based tooling so searches can run without matching the original UI while preserving response compatibility.

Made-with: Cursor
This commit is contained in:
Franz Kafka 2026-03-20 20:34:08 +01:00
parent 7783367c71
commit dc44837219
32 changed files with 3330 additions and 0 deletions

View file

@ -0,0 +1,50 @@
package contracts
// OutputFormat matches SearXNG's `/search?format=...` values.
type OutputFormat string
const (
FormatHTML OutputFormat = "html" // accepted for compatibility (not yet implemented)
FormatJSON OutputFormat = "json"
FormatCSV OutputFormat = "csv"
FormatRSS OutputFormat = "rss"
)
type SearchRequest struct {
// Format is what the client requested via `format=...`.
Format OutputFormat
Query string
Pageno int
Safesearch int
TimeRange *string
TimeoutLimit *float64
Language string
// Engines and categories are used for deciding which engines run locally vs are proxied.
// For now, engines can be supplied directly via the `engines` form parameter.
Engines []string
Categories []string
// EngineData matches SearXNG's `engine_data-<engine>-<key>=<value>` parameters.
EngineData map[string]map[string]string
// AccessToken is an optional request token used to gate paid/limited engines.
// It is not part of the upstream JSON schema; it only influences local engines.
AccessToken string
}
// SearchResponse matches the JSON schema returned by SearXNG's `webutils.get_json_response()`.
type SearchResponse struct {
Query string `json:"query"`
NumberOfResults int `json:"number_of_results"`
Results []MainResult `json:"results"`
Answers []map[string]any `json:"answers"`
Corrections []string `json:"corrections"`
Infoboxes []map[string]any `json:"infoboxes"`
Suggestions []string `json:"suggestions"`
UnresponsiveEngines [][2]string `json:"unresponsive_engines"`
}