# leeseungmin1013/repowiseai architecture

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

- Interactive diagram: https://gitdiagram.com/leeseungmin1013/repowiseai
- Repository: https://github.com/leeseungmin1013/repowiseai

## Overview

#### Purpose and Entry Points
RepoWise AI is an interactive code-learning system that ingests a public GitHub repository, fixes analysis to a branch/commit snapshot, and teaches its code through grounded chat, guided lessons, assessment, and mastery tracking. The backend starts at `apps/api/app/main.py`; its HTTP surface is assembled in `apps/api/app/api/router.py`. The Next.js workspace begins at `apps/web/src/app/page.tsx`, centered on `apps/web/src/components/RepositoryWorkbench.tsx`.

#### Repository Ingestion and Durable Analysis
Repository registration triggers GitHub archive acquisition and safety filtering, then schedules durable background analysis. GitHub and archive concerns are isolated in `apps/api/app/services/github.py` and `apps/api/app/services/file_filter.py`; RQ job orchestration and execution live in `apps/api/app/queue.py`, `apps/api/app/workers/runner.py`, and `apps/api/app/workers/repository_analysis.py`. This boundary prevents request handlers from performing large repository analysis synchronously.

#### Code Intelligence and Persisted Snapshot
Analysis parses TypeScript/JavaScript using Tree-sitter, producing file structure, symbols, import/call candidates, and hierarchical chunks. Core stages are `apps/api/app/analysis/typescript.py`, `apps/api/app/analysis/tree.py`, and `apps/api/app/analysis/chunking.py`. SQLAlchemy domain models in `apps/api/app/models.py` persist snapshot-scoped files, symbols, relations, chunks, and learning state; Alembic migrations in `apps/api/migrations/versions/` define the evolving PostgreSQL schema.

#### Retrieval, Evidence, and Grounded AI
Question handling retrieves snapshot-local code evidence through exact, lexical, vector, selection, and hybrid/RRF paths in `apps/api/app/retrieval/query.py`, `apps/api/app/retrieval/hybrid.py`, and `apps/api/app/retrieval/evidence.py`. Evidence allowlisting, source hashes, line validation, and server-side citations form the grounding boundary before generation. `apps/api/app/services/grounded_chat.py` combines retrieval with structured answers from `apps/api/app/ai/answers.py`; `apps/api/app/ai/embeddings.py` supports OpenAI embeddings or a deterministic local fallback.

#### Adaptive Learning Domain
The learning subsystem converts code evidence and learner signals into curriculum modules, lessons, explanations, activities, and replanned paths. Its primary components are `apps/api/app/learning/curriculum.py`, `apps/api/app/learning/activities.py`, and `apps/api/app/learning/replan.py`. A fixed concept/prerequisite graph and mastery state in `apps/api/app/learning/concepts.py` and `apps/api/app/learning/mastery.py` resolve minimal prerequisite gaps while preserving completed lessons. Assessment scoring is separated in `apps/api/app/assessment/question_bank.py` and `apps/api/app/assessment/scoring.py`.

#### API and Client Interaction
Feature-specific FastAPI routes expose repository lifecycle, chat, guidance, learning, assessment, deep tasks, and voice: `apps/api/app/api/repositories.py`, `apps/api/app/api/chat.py`, and `apps/api/app/api/learning.py`. The web client presents code/tree/graph context alongside learning panels through `apps/web/src/components/CodePanel.tsx`, `apps/web/src/components/LearningJourneyPanel.tsx`, and `apps/web/src/components/AssistantPanel.tsx`. Shared API calls and client-side deep-task routing reside in `apps/web/src/lib/api.ts` and `apps/web/src/lib/deep-tasks.ts`.

#### Runtime and External Dependencies
The system runs a Python 3.12 FastAPI API plus separate RQ worker, and a Next.js/React frontend. Docker Compose provides PostgreSQL with pgvector and Redis via `docker-compose.yml`; database configuration is centralized in `apps/api/app/core/db.py`. External boundaries are public GitHub archives, OpenAI (`text-embedding-3-small` and structured-output generation when configured), and official research materials managed by `apps/api/app/services/research_materials.py`. Real-time voice sessions are handled separately in `apps/api/app/voice/realtime.py` and surfaced by `apps/web/src/components/voice/VoiceSessionDock.tsx`.

Main entry points: [`apps/web/src/components/RepositoryWorkbench.tsx`](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/RepositoryWorkbench.tsx) (Repository Workbench), [`apps/api/app/models.py`](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/models.py) (Snapshot and learning store), [`apps/api/app/api/router.py`](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/api/router.py) (Feature routes), [`apps/api/app/services/github.py`](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/services/github.py) (GitHub archive ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js client"]
  node_web_page["Workbench entry<br/>Next.js page<br/>[page.tsx]"]
  node_workbench["Repository Workbench<br/>client composition"]
  node_code_panel["Code context panels<br/>React components<br/>[CodePanel.tsx]"]
  node_learning_panel["Learning Journey<br/>React component"]
  node_assistant_panel["Assistant and voice<br/>React components<br/>[AssistantPanel.tsx]"]
  node_client_api["API and deep-task client<br/>client integration<br/>[api.ts]"]
end

subgraph group_api["FastAPI application"]
  node_api_main{{"FastAPI API<br/>Python service<br/>[main.py]"}}
  node_api_router["Feature routes<br/>FastAPI router<br/>[router.py]"]
  node_github_ingestion["GitHub archive ingestion<br/>repository service<br/>[github.py]"]
  node_job_queue["RQ analysis jobs<br/>job orchestration<br/>[queue.py]"]
  node_grounded_chat["Grounded chat<br/>AI service<br/>[grounded_chat.py]"]
  node_retrieval["Evidence retrieval<br/>hybrid retrieval<br/>[hybrid.py]"]
end

subgraph group_analysis["Analysis pipeline"]
  node_worker{{"Analysis worker<br/>RQ worker"}}
  node_code_analysis["Code intelligence<br/>Tree-sitter pipeline<br/>[typescript.py]"]
end

subgraph group_learning["Learning domain"]
  node_learning_engine["Adaptive learning<br/>curriculum engine<br/>[curriculum.py]"]
  node_assessment["Assessment scoring<br/>assessment service<br/>[scoring.py]"]
end

subgraph group_runtime["Runtime services"]
  node_snapshot_store[("Snapshot and learning store<br/>SQLAlchemy models<br/>[models.py]")]
  node_postgres[("PostgreSQL + pgvector<br/>database runtime<br/>[docker-compose.yml]")]
  node_redis["Redis<br/>queue runtime<br/>[docker-compose.yml]"]
end

node_github["Public GitHub archives<br/>external source"]
node_openai(("OpenAI<br/>external AI"))

node_web_page -->|"renders"| node_workbench
node_workbench -->|"shows"| node_code_panel
node_workbench -->|"shows"| node_learning_panel
node_workbench -->|"shows"| node_assistant_panel
node_workbench -->|"uses"| node_client_api
node_client_api -->|"HTTP"| node_api_main
node_api_main -->|"mounts"| node_api_router
node_api_router -->|"repository registration"| node_github_ingestion
node_github_ingestion -->|"downloads archive"| node_github
node_github_ingestion -->|"schedules analysis"| node_job_queue
node_job_queue -->|"enqueues"| node_redis
node_job_queue -->|"dispatches"| node_worker
node_worker -->|"analyzes filtered files"| node_code_analysis
node_code_analysis -->|"persists artifacts"| node_snapshot_store
node_snapshot_store -->|"stores"| node_postgres
node_api_router -->|"chat requests"| node_grounded_chat
node_grounded_chat -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"queries snapshot"| node_snapshot_store
node_grounded_chat -.->|"generates when configured"| node_openai
node_api_router -->|"guidance and learning"| node_learning_engine
node_learning_engine -->|"reads evidence and mastery"| node_snapshot_store
node_learning_engine -->|"assigns activities"| node_assessment
node_assessment -->|"updates mastery"| node_snapshot_store

click node_web_page "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/app/page.tsx"
click node_workbench "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/RepositoryWorkbench.tsx"
click node_code_panel "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/CodePanel.tsx"
click node_learning_panel "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/LearningJourneyPanel.tsx"
click node_assistant_panel "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/AssistantPanel.tsx"
click node_client_api "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/lib/api.ts"
click node_api_main "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/main.py"
click node_api_router "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/api/router.py"
click node_github_ingestion "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/services/github.py"
click node_job_queue "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/queue.py"
click node_worker "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/workers/repository_analysis.py"
click node_code_analysis "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/analysis/typescript.py"
click node_snapshot_store "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/models.py"
click node_grounded_chat "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/services/grounded_chat.py"
click node_retrieval "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/retrieval/hybrid.py"
click node_learning_engine "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/learning/curriculum.py"
click node_assessment "https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/assessment/scoring.py"
click node_postgres "https://github.com/leeseungmin1013/repowiseai/blob/main/docker-compose.yml"
click node_redis "https://github.com/leeseungmin1013/repowiseai/blob/main/docker-compose.yml"

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_web_page,node_workbench,node_code_panel,node_learning_panel,node_assistant_panel,node_client_api toneBlue
class node_api_main,node_api_router,node_github_ingestion,node_job_queue,node_grounded_chat,node_retrieval toneAmber
class node_worker,node_code_analysis toneMint
class node_learning_engine,node_assessment toneRose
class node_snapshot_store,node_postgres,node_redis toneIndigo
class node_github,node_openai toneNeutral
```

## Components

### Next.js client

- [Workbench entry](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/app/page.tsx): Next.js page · `apps/web/src/app/page.tsx`
- [Repository Workbench](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/RepositoryWorkbench.tsx): client composition · Combines repository context, learning, and assistant views. · `apps/web/src/components/RepositoryWorkbench.tsx`
- [Code context panels](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/CodePanel.tsx): React components · `apps/web/src/components/CodePanel.tsx`
- [Learning Journey](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/LearningJourneyPanel.tsx): React component · `apps/web/src/components/LearningJourneyPanel.tsx`
- [Assistant and voice](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/components/AssistantPanel.tsx): React components · `apps/web/src/components/AssistantPanel.tsx`
- [API and deep-task client](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/web/src/lib/api.ts): client integration · `apps/web/src/lib/api.ts`

### FastAPI application

- [FastAPI API](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/main.py): Python service · `apps/api/app/main.py`
- [Feature routes](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/api/router.py): FastAPI router · Repository, chat, and learning endpoints. · `apps/api/app/api/router.py`
- [GitHub archive ingestion](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/services/github.py): repository service · Acquires public archives and filters unsafe files. · `apps/api/app/services/github.py`
- [RQ analysis jobs](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/queue.py): job orchestration · `apps/api/app/queue.py`
- [Grounded chat](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/services/grounded_chat.py): AI service · Retrieves snapshot evidence before structured answer generation. · `apps/api/app/services/grounded_chat.py`
- [Evidence retrieval](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/retrieval/hybrid.py): hybrid retrieval · Uses exact, lexical, vector, selection, and RRF retrieval with citation validation. · `apps/api/app/retrieval/hybrid.py`

### Analysis pipeline

- [Analysis worker](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/workers/repository_analysis.py): RQ worker · Runs durable repository-analysis jobs outside requests. · `apps/api/app/workers/repository_analysis.py`
- [Code intelligence](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/analysis/typescript.py): Tree-sitter pipeline · Parses TypeScript/JavaScript into structure, symbols, relations, and chunks. · `apps/api/app/analysis/typescript.py`

### Learning domain

- [Adaptive learning](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/learning/curriculum.py): curriculum engine · Builds lessons and replans from evidence, prerequisites, and mastery. · `apps/api/app/learning/curriculum.py`
- [Assessment scoring](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/assessment/scoring.py): assessment service · `apps/api/app/assessment/scoring.py`

### Runtime services

- [Snapshot and learning store](https://github.com/leeseungmin1013/repowiseai/blob/main/apps/api/app/models.py): SQLAlchemy models · Persists snapshot-scoped code artifacts and learner state. · `apps/api/app/models.py`
- [PostgreSQL + pgvector](https://github.com/leeseungmin1013/repowiseai/blob/main/docker-compose.yml): database runtime · `docker-compose.yml`
- [Redis](https://github.com/leeseungmin1013/repowiseai/blob/main/docker-compose.yml): queue runtime · `docker-compose.yml`

### Other components

- **Public GitHub archives**: external source
- **OpenAI**: external AI · Optional embeddings and structured-output generation.

## Connections

- Workbench entry → Repository Workbench: renders
- Repository Workbench → Code context panels: shows
- Repository Workbench → Learning Journey: shows
- Repository Workbench → Assistant and voice: shows
- Repository Workbench → API and deep-task client: uses
- API and deep-task client → FastAPI API: HTTP
- FastAPI API → Feature routes: mounts
- Feature routes → GitHub archive ingestion: repository registration
- GitHub archive ingestion → Public GitHub archives: downloads archive
- GitHub archive ingestion → RQ analysis jobs: schedules analysis
- RQ analysis jobs → Redis: enqueues
- RQ analysis jobs → Analysis worker: dispatches
- Analysis worker → Code intelligence: analyzes filtered files
- Code intelligence → Snapshot and learning store: persists artifacts
- Snapshot and learning store → PostgreSQL + pgvector: stores
- Feature routes → Grounded chat: chat requests
- Grounded chat → Evidence retrieval: retrieves evidence
- Evidence retrieval → Snapshot and learning store: queries snapshot
- Grounded chat → OpenAI: generates when configured
- Feature routes → Adaptive learning: guidance and learning
- Adaptive learning → Snapshot and learning store: reads evidence and mastery
- Adaptive learning → Assessment scoring: assigns activities
- Assessment scoring → Snapshot and learning store: updates mastery
