How brunostjohn/perplexideez works
Project Type and Purpose
• This is a monolithic full-stack web application built with SvelteKit that provides a self-hosted AI-powered search experience.
• It integrates with a Postgres database for persistence, a SearXNG search microservice for web searches, and an LLM provider (Ollama or OpenAI) for generating responses.
• It supports multi-user authentication (AuthJS/OIDC) and is deployed via Docker Compose or Kubernetes.
Top-Level Components
a. Client (Browser)
• Renders the SvelteKit front end (HTML/CSS/JS).
• Initiates API calls (tRPC) for data, search, and AI interactions.
b. SvelteKit Server
• Routes and SSR (src/routes, +layout, +page).
• tRPC API layer (src/lib/trpc/router.ts).
• AuthJS/OIDC middleware (src/lib/auth.ts, hooks.server.ts).
• Metrics endpoint for Prometheus (src/lib/metrics).
• OG image generator (src/lib/og).
c. Database Service
• Postgres (prisma/schema, migrations).
• Used by Prisma client calls in server and by the migrate container.
d. Search Microservice
• SearXNG (deploy/docker/searxng or external URL via SEARXNG_URL).
• Returns JSON search results.
e. LLM Provider
• Ollama or OpenAI endpoints (configurable via LLM_MODE, OLLAMA_URL or OPENAI_BASE_URL + API key).
• Performs embedding, summarization, follow-ups, etc.
f. Authentication Provider
• External OIDC IdP (optional).
g. Deployment & Ops
• Docker Compose stack (deploy/docker/compose.yml).
• Kubernetes Helm chart (deploy/kubernetes/perplexideez).
• Dockerfiles for app and migration.
Relationships & Data Flows
• Client → SvelteKit Server: page requests, tRPC calls.
• Server ↔ Postgres: CRUD (users, chats, favorites, sharing links).
• Server → SearXNG: web search requests.
• Server → LLM Provider: prompt completions, embeddings, image/video search.
• Server ↔ Auth/OIDC: user login, sign-up, token exchange.
• Prometheus → Server: scrapes metrics endpoint.
• CI/CD (GitHub Actions) → Builds & pushes Docker images, publishes Helm chart.
Architectural Patterns & Principles
• Monolithic application with microservice dependencies (Search, LLM, Auth).
• Layered separation:
• Presentation (SvelteKit UI)
• API layer (tRPC routers)
• Business logic (src/lib/ai, src/lib/utils)
• Persistence (Prisma + Postgres)
• Stateless pods/containers: all state in Postgres or external services.
• Configuration via 12-factor environment variables.
• Metrics-driven observability (Prometheus).