# weayabo/chat-with-remus architecture

> Architecture diagram of the GitHub repository weayabo/chat-with-remus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/weayabo/chat-with-remus
- Repository: https://github.com/weayabo/chat-with-remus

## Overview

This is a portfolio chat application: visitors ask about Remus’s professional background, and the server either retrieves relevant profile material for an answer or evaluates a pasted job description and narrates the fit. A separate ingestion script prepares the retrieval corpus. The main call paths are visible in the sampled page, API route, matching function, and ingestion script; the README is only a stock Next.js template and documents no additional product capabilities.

Main entry points: [`app/api/query/route.ts`](https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts) (Query endpoint), [`app/page.tsx`](https://github.com/weayabo/chat-with-remus/blob/main/app/page.tsx) (Chat interface), [`scripts/ingest.ts`](https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.ts) (Corpus ingestion), [`lib/check-fit.ts`](https://github.com/weayabo/chat-with-remus/blob/main/lib/check-fit.ts) (Fit analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_chat["Chat interface<br/>[page.tsx]"]
  node_shell["Page shell<br/>[layout.tsx]"]
end

subgraph group_orchestration["Query orchestration"]
  node_query["Query endpoint<br/>[route.ts]"]
  node_router["Intent router<br/>[route.ts]"]
  node_retrieval["Context retrieval<br/>[route.ts]"]
  node_answer["Answer generation<br/>[route.ts]"]
  node_fit_tool["Fit tool<br/>[route.ts]"]
end

subgraph group_knowledge["Knowledge and matching"]
  node_fit["Fit analysis<br/>[check-fit.ts]"]
  node_profile["Candidate profile<br/>[remus-profile.json]"]
  node_corpus["Source text<br/>[sample.txt]"]
  node_pinecone[("Pinecone index")]
end

subgraph group_ingestion["Corpus ingestion"]
  node_ingest["Corpus ingestion<br/>[ingest.ts]"]
  node_splitter["Text chunking<br/>[ingest.ts]"]
  node_embed_store["Embedding and upsert<br/>[ingest.ts]"]
end

node_visitor(("Visitor"))
node_gemini{{"Google Gemini"}}

node_visitor -->|"sends question"| node_chat
node_chat -->|"posts messages"| node_query
node_query -->|"returns answer"| node_chat
node_shell -->|"renders page"| node_chat
node_query -->|"routes message"| node_router
node_router -->|"classifies request"| node_gemini
node_query -->|"invokes tool call"| node_fit_tool
node_fit_tool -->|"evaluates description"| node_fit
node_fit -->|"reads profile"| node_profile
node_fit -->|"requests structured assessment"| node_gemini
node_query -->|"narrates fit result"| node_answer
node_answer -->|"generates narration"| node_gemini
node_query -->|"retrieves on no tool"| node_retrieval
node_retrieval -->|"embeds query"| node_gemini
node_retrieval -->|"searches vectors"| node_pinecone
node_retrieval -->|"supplies context"| node_answer
node_answer -->|"generates response"| node_gemini
node_ingest -->|"reads source text"| node_corpus
node_ingest -->|"splits text"| node_splitter
node_ingest -->|"embeds and upserts"| node_embed_store
node_embed_store -->|"creates embeddings"| node_gemini
node_embed_store -->|"stores vectors"| node_pinecone

click node_chat "https://github.com/weayabo/chat-with-remus/blob/main/app/page.tsx"
click node_shell "https://github.com/weayabo/chat-with-remus/blob/main/app/layout.tsx"
click node_query "https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts"
click node_router "https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts"
click node_retrieval "https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts"
click node_answer "https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts"
click node_fit_tool "https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts"
click node_fit "https://github.com/weayabo/chat-with-remus/blob/main/lib/check-fit.ts"
click node_profile "https://github.com/weayabo/chat-with-remus/blob/main/data/remus-profile.json"
click node_corpus "https://github.com/weayabo/chat-with-remus/blob/main/data/sample.txt"
click node_ingest "https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.ts"
click node_splitter "https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.ts"
click node_embed_store "https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.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_chat,node_shell toneBlue
class node_query,node_router,node_retrieval,node_answer,node_fit_tool toneAmber
class node_fit,node_profile,node_corpus,node_pinecone toneMint
class node_ingest,node_splitter,node_embed_store toneRose
class node_visitor,node_gemini toneIndigo
```

## Components

### Chat experience

- [Chat interface](https://github.com/weayabo/chat-with-remus/blob/main/app/page.tsx): `app/page.tsx`
- [Page shell](https://github.com/weayabo/chat-with-remus/blob/main/app/layout.tsx): `app/layout.tsx`

### Query orchestration

- [Query endpoint](https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts): `app/api/query/route.ts`
- [Intent router](https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts): `app/api/query/route.ts`
- [Context retrieval](https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts): `app/api/query/route.ts`
- [Answer generation](https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts): `app/api/query/route.ts`
- [Fit tool](https://github.com/weayabo/chat-with-remus/blob/main/app/api/query/route.ts): `app/api/query/route.ts`

### Knowledge and matching

- [Fit analysis](https://github.com/weayabo/chat-with-remus/blob/main/lib/check-fit.ts): `lib/check-fit.ts`
- [Candidate profile](https://github.com/weayabo/chat-with-remus/blob/main/data/remus-profile.json): `data/remus-profile.json`
- [Source text](https://github.com/weayabo/chat-with-remus/blob/main/data/sample.txt): `data/sample.txt`
- **Pinecone index**

### Corpus ingestion

- [Corpus ingestion](https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.ts): `scripts/ingest.ts`
- [Text chunking](https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.ts): `scripts/ingest.ts`
- [Embedding and upsert](https://github.com/weayabo/chat-with-remus/blob/main/scripts/ingest.ts): `scripts/ingest.ts`

### Other components

- **Visitor**
- **Google Gemini**

## Connections

- Visitor → Chat interface: sends question (evidence: `app/page.tsx`)
- Chat interface → Query endpoint: posts messages (evidence: `app/page.tsx`)
- Query endpoint → Chat interface: returns answer (evidence: `app/page.tsx`)
- Page shell → Chat interface: renders page (evidence: `app/layout.tsx`)
- Query endpoint → Intent router: routes message (evidence: `app/api/query/route.ts`)
- Intent router → Google Gemini: classifies request (evidence: `app/api/query/route.ts`)
- Query endpoint → Fit tool: invokes tool call (evidence: `app/api/query/route.ts`)
- Fit tool → Fit analysis: evaluates description (evidence: `app/api/query/route.ts`)
- Fit analysis → Candidate profile: reads profile (evidence: `lib/check-fit.ts`)
- Fit analysis → Google Gemini: requests structured assessment (evidence: `lib/check-fit.ts`)
- Query endpoint → Answer generation: narrates fit result (evidence: `app/api/query/route.ts`)
- Answer generation → Google Gemini: generates narration (evidence: `app/api/query/route.ts`)
- Query endpoint → Context retrieval: retrieves on no tool (evidence: `app/api/query/route.ts`)
- Context retrieval → Google Gemini: embeds query (evidence: `app/api/query/route.ts`)
- Context retrieval → Pinecone index: searches vectors (evidence: `app/api/query/route.ts`)
- Context retrieval → Answer generation: supplies context (evidence: `app/api/query/route.ts`)
- Answer generation → Google Gemini: generates response (evidence: `app/api/query/route.ts`)
- Corpus ingestion → Source text: reads source text (evidence: `scripts/ingest.ts`)
- Corpus ingestion → Text chunking: splits text (evidence: `scripts/ingest.ts`)
- Corpus ingestion → Embedding and upsert: embeds and upserts (evidence: `scripts/ingest.ts`)
- Embedding and upsert → Google Gemini: creates embeddings (evidence: `scripts/ingest.ts`)
- Embedding and upsert → Pinecone index: stores vectors (evidence: `scripts/ingest.ts`)
