# abk1969/vigiriskeo architecture

> Architecture diagram of the GitHub repository abk1969/vigiriskeo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abk1969/vigiriskeo
- Repository: https://github.com/abk1969/vigiriskeo

## Overview

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: [`src/app/api/v1`](https://github.com/abk1969/vigiriskeo/tree/master/src/app/api/v1) (API v1), [`src/server/pipeline/orchestrator.ts`](https://github.com/abk1969/vigiriskeo/blob/master/src/server/pipeline/orchestrator.ts) (Pipeline), [`src/db/schema/index.ts`](https://github.com/abk1969/vigiriskeo/blob/master/src/db/schema/index.ts) (DB schema), [`src/app/layout.tsx`](https://github.com/abk1969/vigiriskeo/blob/master/src/app/layout.tsx) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_app_root["App shell<br/>nextjs root<br/>[layout.tsx]"]
  node_auth_login["Login<br/>auth page<br/>[page.tsx]"]
  node_dashboard_layout["Dashboard<br/>route layout<br/>[layout.tsx]"]
  node_dashboard_views["User views<br/>dashboard pages<br/>[page.tsx]"]
  node_admin_layout["Admin<br/>route layout<br/>[layout.tsx]"]
  node_admin_tools["Admin tools<br/>admin pages<br/>[page.tsx]"]
end

subgraph group_api["API"]
  node_api_v1["API v1<br/>rest api"]
  node_api_auth["Auth API<br/>nextauth endpoint<br/>[route.ts]"]
  node_api_jobs["Jobs API<br/>inngest endpoint<br/>[route.ts]"]
  node_api_cron["Warmup<br/>cron endpoint<br/>[route.ts]"]
end

subgraph group_backend["Backend"]
  node_pipeline{{"Pipeline<br/>orchestrator<br/>[orchestrator.ts]"}}
  node_agents["Agents<br/>processing stages"]
  node_connectors["Connectors<br/>source adapters"]
  node_jobs["Background jobs<br/>async jobs<br/>[pipeline.job.ts]"]
  node_chat{{"Chat stack<br/>assistant orchestration<br/>[orchestrator.ts]"}}
  node_memory["Memory<br/>context store<br/>[orchestrator.ts]"]
  node_authz["Auth/RBAC<br/>security<br/>[rbac.ts]"]
  node_services["Domain services<br/>service layer"]
end

subgraph group_data["Data"]
  node_schema[("DB schema<br/>drizzle schema<br/>[index.ts]")]
  node_migrations["Migrations"]
  node_cache[("Cache<br/>kv storage<br/>[index.ts]")]
end

node_app_root -->|"routes"| node_auth_login
node_app_root -->|"hosts"| node_dashboard_layout
node_app_root -->|"hosts"| node_admin_layout
node_dashboard_layout -->|"renders"| node_dashboard_views
node_admin_layout -->|"renders"| node_admin_tools
node_dashboard_views -->|"reads/writes"| node_api_v1
node_admin_tools -->|"operates"| node_api_v1
node_api_auth -->|"auth"| node_authz
node_api_v1 -->|"protects"| node_authz
node_api_v1 -->|"starts/inspects"| node_pipeline
node_api_v1 -->|"delegates"| node_services
node_api_v1 -->|"invokes"| node_chat
node_api_jobs -->|"triggers"| node_jobs
node_api_cron -->|"warms"| node_jobs
node_pipeline -->|"ingests"| node_connectors
node_pipeline -->|"processes"| node_agents
node_jobs -->|"runs"| node_pipeline
node_chat -->|"uses"| node_memory
node_chat -->|"stores"| node_cache
node_memory -->|"backed by"| node_cache
node_services -->|"persists"| node_schema
node_pipeline -->|"records"| node_schema
node_authz -->|"users"| node_schema
node_schema -->|"evolves"| node_migrations

click node_app_root "https://github.com/abk1969/vigiriskeo/blob/master/src/app/layout.tsx"
click node_auth_login "https://github.com/abk1969/vigiriskeo/blob/master/src/app/(auth)/login/page.tsx"
click node_dashboard_layout "https://github.com/abk1969/vigiriskeo/blob/master/src/app/(dashboard)/layout.tsx"
click node_dashboard_views "https://github.com/abk1969/vigiriskeo/blob/master/src/app/(dashboard)/page.tsx"
click node_admin_layout "https://github.com/abk1969/vigiriskeo/blob/master/src/app/(admin)/layout.tsx"
click node_admin_tools "https://github.com/abk1969/vigiriskeo/blob/master/src/app/(admin)/admin/sources/page.tsx"
click node_api_v1 "https://github.com/abk1969/vigiriskeo/tree/master/src/app/api/v1"
click node_api_auth "https://github.com/abk1969/vigiriskeo/blob/master/src/app/api/auth/[...nextauth]/route.ts"
click node_api_jobs "https://github.com/abk1969/vigiriskeo/blob/master/src/app/api/inngest/route.ts"
click node_api_cron "https://github.com/abk1969/vigiriskeo/blob/master/src/app/api/cron/warmup/route.ts"
click node_pipeline "https://github.com/abk1969/vigiriskeo/blob/master/src/server/pipeline/orchestrator.ts"
click node_agents "https://github.com/abk1969/vigiriskeo/tree/master/src/server/agents"
click node_connectors "https://github.com/abk1969/vigiriskeo/tree/master/src/server/connectors"
click node_jobs "https://github.com/abk1969/vigiriskeo/blob/master/src/server/jobs/pipeline.job.ts"
click node_chat "https://github.com/abk1969/vigiriskeo/blob/master/src/server/chat/orchestrator.ts"
click node_memory "https://github.com/abk1969/vigiriskeo/blob/master/src/server/memory/orchestrator.ts"
click node_authz "https://github.com/abk1969/vigiriskeo/blob/master/src/server/auth/rbac.ts"
click node_services "https://github.com/abk1969/vigiriskeo/tree/master/src/server/services"
click node_schema "https://github.com/abk1969/vigiriskeo/blob/master/src/db/schema/index.ts"
click node_migrations "https://github.com/abk1969/vigiriskeo/tree/master/drizzle"
click node_cache "https://github.com/abk1969/vigiriskeo/blob/master/src/server/cache/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_root,node_auth_login,node_dashboard_layout,node_dashboard_views,node_admin_layout,node_admin_tools toneBlue
class node_api_v1,node_api_auth,node_api_jobs,node_api_cron toneAmber
class node_pipeline,node_agents,node_connectors,node_jobs,node_chat,node_memory,node_authz,node_services toneMint
class node_schema,node_migrations,node_cache toneRose
```

## Components

### Presentation

Next.js route groups and shared UI

- [App shell](https://github.com/abk1969/vigiriskeo/blob/master/src/app/layout.tsx): nextjs root · Global app layout and providers · `src/app/layout.tsx`
- [Login](https://github.com/abk1969/vigiriskeo/blob/master/src/app/(auth)/login/page.tsx): auth page · Public sign-in entry · `src/app/(auth)/login/page.tsx`
- [Dashboard](https://github.com/abk1969/vigiriskeo/blob/master/src/app/(dashboard)/layout.tsx): route layout · User-facing dashboard shell · `src/app/(dashboard)/layout.tsx`
- [User views](https://github.com/abk1969/vigiriskeo/blob/master/src/app/(dashboard)/page.tsx): dashboard pages · Signals, targets, sources, analytics, and bulletins · `src/app/(dashboard)/page.tsx`
- [Admin](https://github.com/abk1969/vigiriskeo/blob/master/src/app/(admin)/layout.tsx): route layout · Admin console shell · `src/app/(admin)/layout.tsx`
- [Admin tools](https://github.com/abk1969/vigiriskeo/blob/master/src/app/(admin)/admin/sources/page.tsx): admin pages · Sources, targets, taxonomy, prompts, scoring, scheduling, users, purge · `src/app/(admin)/admin/sources/page.tsx`

### API

Application and operational endpoints

- [API v1](https://github.com/abk1969/vigiriskeo/tree/master/src/app/api/v1): rest api · Primary application contract · `src/app/api/v1`
- [Auth API](https://github.com/abk1969/vigiriskeo/blob/master/src/app/api/auth/[...nextauth]/route.ts): nextauth endpoint · Session and login handling · `src/app/api/auth/[...nextauth]/route.ts`
- [Jobs API](https://github.com/abk1969/vigiriskeo/blob/master/src/app/api/inngest/route.ts): inngest endpoint · Background job webhook entry · `src/app/api/inngest/route.ts`
- [Warmup](https://github.com/abk1969/vigiriskeo/blob/master/src/app/api/cron/warmup/route.ts): cron endpoint · Deployment warmup hook · `src/app/api/cron/warmup/route.ts`

### Backend

Pipeline, AI, chat, auth, and service logic

- [Pipeline](https://github.com/abk1969/vigiriskeo/blob/master/src/server/pipeline/orchestrator.ts): orchestrator · End-to-end ingestion and enrichment flow · `src/server/pipeline/orchestrator.ts`
- [Agents](https://github.com/abk1969/vigiriskeo/tree/master/src/server/agents): processing stages · Ingestion, dedupe, classify, tag, score, verify, write, alert · `src/server/agents`
- [Connectors](https://github.com/abk1969/vigiriskeo/tree/master/src/server/connectors): source adapters · RSS, email, and web scraping inputs · `src/server/connectors`
- [Background jobs](https://github.com/abk1969/vigiriskeo/blob/master/src/server/jobs/pipeline.job.ts): async jobs · Inngest-backed pipeline execution · `src/server/jobs/pipeline.job.ts`
- [Chat stack](https://github.com/abk1969/vigiriskeo/blob/master/src/server/chat/orchestrator.ts): assistant orchestration · Controlled assistant, tools, registry, and guardrails · `src/server/chat/orchestrator.ts`
- [Memory](https://github.com/abk1969/vigiriskeo/blob/master/src/server/memory/orchestrator.ts): context store · Short-term, long-term, and augmented memory · `src/server/memory/orchestrator.ts`
- [Auth/RBAC](https://github.com/abk1969/vigiriskeo/blob/master/src/server/auth/rbac.ts): security · NextAuth config and role-based authorization · `src/server/auth/rbac.ts`
- [Domain services](https://github.com/abk1969/vigiriskeo/tree/master/src/server/services): service layer · Bulletins, sources, and config coordination · `src/server/services`

### Data

Database schema, migrations, and runtime storage

- [DB schema](https://github.com/abk1969/vigiriskeo/blob/master/src/db/schema/index.ts): drizzle schema · Sources, signals, targets, bulletins, alerts, taxonomy, runs, cache, memory, users · `src/db/schema/index.ts`
- [Migrations](https://github.com/abk1969/vigiriskeo/tree/master/drizzle): drizzle migrations · Schema evolution and snapshots · `drizzle`
- [Cache](https://github.com/abk1969/vigiriskeo/blob/master/src/server/cache/index.ts): kv storage · Memory and Postgres-backed caching · `src/server/cache/index.ts`

## Connections

- 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
