How leeseungmin1013/repowiseai works
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: RepositoryWorkbench.tsx Repository Workbench · models.py Snapshot and learning store · router.py Feature routes · github.py GitHub archive ingestion
Components 21
Next.js client
- Workbench entry
apps/web/src/app/page.tsx - Repository Workbench · Combines repository context, learning, and assistant views.
apps/web/src/components/RepositoryWorkbench.tsx - Code context panels
apps/web/src/components/CodePanel.tsx - Learning Journey
apps/web/src/components/LearningJourneyPanel.tsx - Assistant and voice
apps/web/src/components/AssistantPanel.tsx - API and deep-task client
apps/web/src/lib/api.ts
FastAPI application
- FastAPI API
apps/api/app/main.py - Feature routes · Repository, chat, and learning endpoints.
apps/api/app/api/router.py - GitHub archive ingestion · Acquires public archives and filters unsafe files.
apps/api/app/services/github.py - RQ analysis jobs
apps/api/app/queue.py - Grounded chat · Retrieves snapshot evidence before structured answer generation.
apps/api/app/services/grounded_chat.py - Evidence retrieval · Uses exact, lexical, vector, selection, and RRF retrieval with citation validation.
apps/api/app/retrieval/hybrid.py
Analysis pipeline
- Analysis worker · Runs durable repository-analysis jobs outside requests.
apps/api/app/workers/repository_analysis.py - Code intelligence · Parses TypeScript/JavaScript into structure, symbols, relations, and chunks.
apps/api/app/analysis/typescript.py
Learning domain
- Adaptive learning · Builds lessons and replans from evidence, prerequisites, and mastery.
apps/api/app/learning/curriculum.py - Assessment scoring
apps/api/app/assessment/scoring.py
Runtime services
- Snapshot and learning store · Persists snapshot-scoped code artifacts and learner state.
apps/api/app/models.py - PostgreSQL + pgvector
docker-compose.yml - Redis
docker-compose.yml
Other components
- Public GitHub archives
- OpenAI · Optional embeddings and structured-output generation.
Connections 23
- 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