KnowledgeRefinery/daemon-go/internal/api/ingest.go
oho 38a99476d6 Knowledge Refinery: local-first semantic search & 3D concept visualization
macOS app for corpus ingestion, semantic search, and concept universe
visualization powered by local LLMs via LM Studio.

Architecture:
- Go daemon (17MB single binary, zero dependencies)
  - chi router, pure-Go SQLite, tiktoken tokenizer
  - 6-stage pipeline: scan → extract → chunk → embed → annotate → conceptualize
  - Brute-force cosine vector search in memory
  - 89 tests across 8 packages
- SwiftUI app (macOS 15+)
  - Multi-workspace management with auto-start daemons
  - Live pipeline progress, search, concept browser
  - WebGPU 3D universe renderer with Canvas2D fallback
  - Custom crystal app icon
2026-02-13 18:09:46 +01:00

46 lines
1,021 B
Go

package api
import (
"encoding/json"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/oho/knowledge-refinery-daemon/internal/pipeline"
)
type startIngestRequest struct {
Paths []string `json:"paths"`
}
func IngestRouter(orch *pipeline.Orchestrator) chi.Router {
r := chi.NewRouter()
r.Post("/start", func(w http.ResponseWriter, r *http.Request) {
if orch.IsRunning() {
http.Error(w, "Pipeline is already running", http.StatusConflict)
return
}
var req startIngestRequest
json.NewDecoder(r.Body).Decode(&req) // may be empty body
jobID, err := orch.RunPipeline(req.Paths)
if err != nil {
http.Error(w, err.Error(), http.StatusConflict)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{
"job_id": jobID,
"status": "started",
})
})
r.Get("/status", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(orch.GetStatus())
})
return r
}