Content Intelligence Platform

Year2026
TechnologyJava, Spring Boot, PostgreSQL, Kafka, OpenSearch, pgvector, Gemini, OpenAI, Flyway, 全文搜索, 检索增强生成, 事务发件箱, 索引重建

Architecture overview

From published content to searchable knowledge

Search and RAG share a source of truth, but maintain separate, rebuildable indexes.

Publish

1 / 5
Responsibility
The content API validates the document and its publication state.
Data
Article or project content with its version.
Design boundary
Draft and restricted content are not automatically public.

Publishing is authoritative; keyword and vector indexes are derived views.

Project

Platform Case Study · Content Intelligence

Content Intelligence Platform

From Admin Commit to Search and RAG Projections

This system turns one authoritative content mutation into independently rebuildable search and retrieval projections. The synchronous write path ends at PostgreSQL; Kafka carries post-commit work to OpenSearch and pgvector without coupling authoring latency to model or index availability.

Repository Wiki

Explore the architecture and implementation with source-linked repository documentation.

AI-generated repository documentation; it may lag behind the code. Devin sign-in and workspace access may be required.

1. Problem and Design Thesis

A portfolio article must be editable and immediately durable, but search enrichment, semantic chunking and embeddings are slower and less reliable than a database transaction. Calling those dependencies inline would make publishing fragile and create a dual-write problem.

Commit the source of truth once, then derive every search and AI projection asynchronously.

2. Architecture

flowchart LR Admin[Admin UI] --> API[Admin Service] API --> TX[(Postgres transaction)] TX --> Source[Content tables + versions] TX --> Outbox[Transactional outbox] Outbox --> Kafka{{Kafka content topics}} Kafka --> Search[Search Indexer] Kafka --> RAG[RAG Indexer] Search --> Enrich[Gemini doc2query] Search --> OS[(OpenSearch BM25 index)] RAG --> Chunk[Chunk + embed] Chunk --> Vector[(pgvector knowledge chunks)] OS --> Query[Search API] Vector --> Agent[Agent retrieval]

3. Write and Publication Contract

StageResponsibilityGuarantee
ValidateJWT allow-list, schema and optimistic versionUnauthorized or stale writes are rejected
CommitSource row, content version, audit and outboxOne atomic PostgreSQL transaction
PublishPost-commit outbox dispatcherAt-least-once Kafka delivery
ProjectSearch and RAG consumersIdempotent upsert by source ID and version

4. Search Projection

The search consumer fetches the committed source document, applies deterministic field mapping and optionally generates query expansions. It writes a versioned document to OpenSearch. Retrieval combines BM25 fields, query-time synonyms and bounded expansion terms; failed enrichment degrades to the original document instead of blocking indexing.

5. RAG Projection

The RAG consumer normalizes HTML, splits content into stable chunks and creates embeddings. New chunks become ACTIVE only after the new version is complete. Previous chunks can then be retired, preventing a partially indexed article from becoming visible to the agent.

  • Chunk identity is derived from source ID, version and ordinal.
  • Embedding calls are retryable and isolated from the admin request.
  • The projection can be rebuilt from source content without data loss.
  • Retrieval permission filters run before candidate ranking.

6. Failure and Replay Model

stateDiagram-v2 [*] --> PENDING PENDING --> PROCESSING PROCESSING --> DONE PROCESSING --> RETRYABLE: transient dependency failure RETRYABLE --> PROCESSING: backoff elapsed PROCESSING --> FAILED: retry budget exhausted FAILED --> PENDING: admin retry or replay

Consumers acknowledge only after a durable projection write. Poison events move to a dead-letter path with the source ID, version and failure category. Admin operators can retry a single job or replay from source data after an index mapping change.

7. Observability

Every content version shares correlation fields across the outbox, Kafka headers, indexing jobs and target documents. Dashboards expose queue age, indexing latency, retry count, zero-result rate and projection version drift.

8. Trade-offs

The design accepts eventual consistency: a published article can be durable before it becomes searchable. In return, authoring remains available during model or OpenSearch outages, and every derived store remains disposable and rebuildable.

9. Engineering Outcome

The platform unifies admin CRUD, versioning, OpenSearch and RAG behind one event-driven content lifecycle while preserving clear ownership: PostgreSQL owns truth; consumers own projections; Kafka owns delivery between them.