How abk1969/vigiriskeo works
1. What this repository is
- A Next.js App Router application that combines a user dashboard, an admin console, and a substantial backend for content monitoring and AI-assisted analysis.
- The domain centers on ingesting external sources, generating/curating “signals,” grouping them into targets, producing bulletins, and sending alerts.
2. Presentation layer
- The UI is split into three route groups: public/auth, dashboard, and admin.
- Dashboard screens focus on signals, targets, sources, analytics, and bulletins.
- Admin screens manage sources, targets, taxonomy, prompts, scoring, scheduling, LLM settings, audit, alerts, users, and purge operations.
3. API boundary
- Most application behavior is exposed through src/app/api/v1/* route handlers.
- These routes are the main contract for CRUD, operational actions, test endpoints, exports, and target/signal/bulletin workflows.
- There are also special-purpose endpoints for auth, cron warmup, Inngest webhooks, and A2A/agent invocation.
4. Core backend domain model
- The data model is database-first and lives under src/db/schema/*.
- Key entities are sources, signals, targets, bulletins, alerts, taxonomy, pipeline runs, audit log, prompt/config versions, cache, memory, and users.
- Drizzle migrations are present, so schema evolution is managed in-repo.
5. Ingestion and enrichment pipeline
- External content enters through connectors in src/server/connectors for RSS, email, and web scraping.
- The pipeline orchestration layer (src/server/pipeline, src/server/jobs, and src/server/agents) applies staged processing:
- ingestion
- deduplication
- classification
- target tagging
- scoring
- verification
- writing/generation
- alerting
- regulatory differentiation
- Pipeline runs are tracked as first-class records, and there are API routes to start, inspect, and rescore runs.
6. AI/LLM subsystem
- The app has an LLM abstraction layer in src/lib/llm.ts and Claude-specific helpers in src/lib/claude.ts.
- Prompt management is a managed feature, with prompt storage/versioning in the DB and admin UI/API for editing and syncing prompts.
- LLM usage appears in classification, writing, chat, scoring, and various admin test endpoints.
7. Chat and knowledge subsystem
- There is a dedicated chat stack under src/server/chat, including orchestration, tools, sanitization, working memory, registry, and guardrails.
- The registry includes prompt templates, refusal behavior, injection-pattern defenses, and domain knowledge documents.
- This is likely a controlled assistant over the product/domain data rather than a generic chat widget.
8. Memory and retrieval
- A separate memory subsystem exists under src/server/memory and src/db/schema/memory.ts.
- It distinguishes short-term, long-term, and augmented LLM memory, suggesting persistent conversational or agent context across sessions.
- Cache support is also explicit, with both in-memory and Postgres-backed KV implementations.
9. Agents, interoperability, and external runtimes
- There is an agent registry and A2A/MCP support under src/server/a2a and src/server/mcp.
- A separate Python service in python-services/adk-agents indicates some agent capabilities are implemented outside the Node/Next runtime.
- This makes the architecture hybrid: Next.js handles the product/API surface, while agent execution can span Node and Python.
10. Auth, authorization, and operational boundaries
- Authentication uses NextAuth in src/app/api/auth/[...nextauth] and src/server/auth.
- RBAC is explicitly modeled, which matches the split between general dashboard users and admin-only operations.
- Middleware likely enforces access and routing boundaries before requests reach the APIs/UI.
11. Background execution and automation
- Inngest is used for asynchronous/background jobs, exposed through an API route and job client.
- There is also a cron warmup endpoint and deployment scripts, implying scheduled or keep-warm operational behavior.
- Pipeline execution is therefore not purely request/response; some work is event- or job-driven.
12. Reporting, exports, and document generation
- Bulletins and insights have export paths, including PDF generation for bulletins.
- This indicates a read/transform/publish flow on top of the core signal/target data model.
- These outputs are likely the main user-facing artifacts produced from the pipeline.
13. Tooling and runtime
- The repo is TypeScript-first, uses Drizzle for DB access, Vitest for unit tests, ESLint/PostCSS, and Next.js/Vercel deployment conventions.
- A Dockerfile and docker-compose.yml suggest local/containerized deployment support.
- Python dependencies are tracked separately, reinforcing the mixed-runtime architecture.
14. High-level data flow to diagram
- External sources and user/admin inputs enter through APIs and connectors.
- Backend agents and jobs normalize, dedupe, classify, score, and tag data into signals and targets.
- Curated outputs become bulletins, alerts, and analytics views in the dashboard.
- Chat, memory, and prompt management sit alongside this pipeline as AI-enabled support systems rather than the core storage model.
Main entry points: v1 API v1 · orchestrator.ts Pipeline · index.ts DB schema · layout.tsx App shell
Components 21
Presentation
Next.js route groups and shared UI
- App shell · Global app layout and providers
src/app/layout.tsx - Login · Public sign-in entry
src/app/(auth)/login/page.tsx - Dashboard · User-facing dashboard shell
src/app/(dashboard)/layout.tsx - User views · Signals, targets, sources, analytics, and bulletins
src/app/(dashboard)/page.tsx - Admin · Admin console shell
src/app/(admin)/layout.tsx - Admin tools · Sources, targets, taxonomy, prompts, scoring, scheduling, users, purge
src/app/(admin)/admin/sources/page.tsx
API
Application and operational endpoints
Backend
Pipeline, AI, chat, auth, and service logic
- Pipeline · End-to-end ingestion and enrichment flow
src/server/pipeline/orchestrator.ts - Agents · Ingestion, dedupe, classify, tag, score, verify, write, alert
src/server/agents - Connectors · RSS, email, and web scraping inputs
src/server/connectors - Background jobs · Inngest-backed pipeline execution
src/server/jobs/pipeline.job.ts - Chat stack · Controlled assistant, tools, registry, and guardrails
src/server/chat/orchestrator.ts - Memory · Short-term, long-term, and augmented memory
src/server/memory/orchestrator.ts - Auth/RBAC · NextAuth config and role-based authorization
src/server/auth/rbac.ts - Domain services · Bulletins, sources, and config coordination
src/server/services
Data
Database schema, migrations, and runtime storage
- DB schema · Sources, signals, targets, bulletins, alerts, taxonomy, runs, cache, memory, users
src/db/schema/index.ts - Migrations · Schema evolution and snapshots
drizzle - Cache · Memory and Postgres-backed caching
src/server/cache/index.ts
Connections 24
- App shell → Login: routes · Public entry includes auth
- App shell → Dashboard: hosts · Global shell wraps dashboard
- App shell → Admin: hosts · Global shell wraps admin
- Dashboard → User views: renders · Dashboard shell serves user surfaces
- Admin → Admin tools: renders · Admin shell serves control surfaces
- User views → API v1: reads/writes · Dashboard uses the core API contract
- Admin tools → API v1: operates · Admin screens drive CRUD and actions
- Auth API → Auth/RBAC: auth · Session handling and RBAC checks
- API v1 → Auth/RBAC: protects · API endpoints are gated by roles
- API v1 → Pipeline: starts/inspects · Pipeline and run operations are exposed through API
- API v1 → Domain services: delegates · Resource and workflow handlers use domain services
- API v1 → Chat stack: invokes · Chat endpoint routes to assistant orchestration
- Jobs API → Background jobs: triggers · Background execution enters through Inngest
- Warmup → Background jobs: warms · Cron endpoint supports operational keep-warm work
- Pipeline → Connectors: ingests · Pipeline begins with external source adapters
- Pipeline → Agents: processes · Core staged enrichment happens in agents
- Background jobs → Pipeline: runs · Async jobs execute pipeline orchestration
- Chat stack → Memory: uses · Assistant persists and retrieves context
- Chat stack → Cache: stores · Chat and runtime state use cache layers
- Memory → Cache: backed by · Memory can leverage short-lived and Postgres KV storage
- Domain services → DB schema: persists · Service layer reads and writes the database model
- Pipeline → DB schema: records · Pipeline runs and produced entities are persisted
- Auth/RBAC → DB schema: users · RBAC depends on user and role records
- DB schema → Migrations: evolves · Schema changes are tracked in repo migrations