How prathamthatte52701/sage-hackathon works
Purpose and Entry Points
CODE MASTER AI is a code-intelligence workspace for reviewing pasted snippets and imported ZIP/GitHub projects, producing evidence-backed findings, guidance, chat responses, and validated fixes. The root development command starts React and FastAPI. Backend registration begins at server/main.py; browser bootstrapping flows through client/src/main.jsx into client/src/App.jsx.
Frontend Workspace
The Vite/React client is the user-facing orchestration layer for paste review, project analysis, finding exploration, chat, and preview-first fixes. client/src/api/client.js is the API boundary; it should remain the central transport contract. Major stateful views include client/src/components/CodeEditor.jsx, client/src/components/ProjectOverview.jsx, and client/src/components/FixValidationModal.jsx. Authentication state is isolated in client/src/context/AuthContext.jsx.
HTTP/API Domains
FastAPI separates product capabilities by router: authentication in server/routers/auth.py, snippet review and paste fixes in server/routers/review.py, and project import, analysis, fixes, downloads, and chat in server/routers/projects.py. Explanation-oriented interactions are handled by server/routers/explain.py. Request/response contracts are defined in server/models/schemas.py, forming the main frontend/backend compatibility boundary.
Evidence-First Analysis Pipeline
Snippet and project review first derive deterministic evidence, then optionally augment it with LLM quality review. Project structure and metadata extraction begin in server/services/analyzer.py; language-specific detection is in server/services/analyzers/python_analyzer.py and server/services/analyzers/javascript_analyzer.py, with rule definitions in server/services/analyzers/rules.py. Python taint tracking (server/services/analyzers/python_taint.py) and AST structure analysis (server/services/structural/python_ast.py) deepen evidence where applicable. Findings are deduplicated, grounded, and scored through server/services/grounding.py and server/services/scoring.py.
Knowledge and Retrieval Boundaries
Curated engineering guidance is deliberately separate from uploaded project code. Knowledge records, validation, ingestion, and hybrid retrieval reside in server/knowledge/schema.py, server/knowledge/ingest.py, and server/knowledge/retrieval.py. Finding-scoped retrieval uses exact rule/category evidence before semantic matches. Repository chat and project-context retrieval are separate service concerns in server/services/retrieval.py and server/services/context_expansion.py; retrieved guidance informs recommendations but is not proof of a finding.
AI Reasoning and External Services
LLM calls are constrained to explanations, quality review, chat, reasoning, and patch proposals—not authoritative detection. Prompt construction and reasoning orchestration are in server/services/prompt_builder.py and server/services/reasoning_engine.py; Groq integration is isolated behind server/services/groq_client.py. MongoDB Atlas stores application/project data and the curated sage_knowledge vector collection; embeddings are generated via server/services/embeddings.py and knowledge embeddings via server/knowledge/embeddings.py. The default embedding model is local all-MiniLM-L6-v2 (384 dimensions), with vector-search fallback when unavailable.
Safe Fix and Reanalysis Loop
Fix generation is preview-only until explicit application. server/services/patching.py validates exact targets, uniqueness, source freshness, overlap, and patch structure before modifying working source or a target project file. Review/project routers then invoke reanalysis against the changed working artifact, while project download exports a sanitized fixed ZIP. This boundary preserves original source, prevents unsafe broad edits, and keeps LLM output subordinate to deterministic patch validation.
Main entry points: projects.py Product Routers · analyzer.py Project Analyzer · reasoning_engine.py AI Reasoning · App.jsx Workspace App
Components 19
React Client
- Client Bootstrap
client/src/main.jsx - Workspace App · Orchestrates review, projects, chat, and fixes.
client/src/App.jsx - API Client · Central browser transport boundary.
client/src/api/client.js - Review & Fix Views · Code editor, project overview, and fix validation UI.
client/src/components/CodeEditor.jsx - Auth State
client/src/context/AuthContext.jsx
FastAPI API
- Backend Registration
server/main.py - API Schemas · Frontend/backend compatibility boundary.
server/models/schemas.py - Product Routers · Auth, review, projects, and explanation endpoints.
server/routers/projects.py
Evidence Pipeline
- Project Analyzer · Extracts project structure and metadata.
server/services/analyzer.py - Language Evidence · Python and JavaScript detection with rule definitions.
server/services/analyzers/python_analyzer.py - Python Deep Analysis · Adds taint tracking and structural evidence where applicable.
server/services/analyzers/python_taint.py - Grounding & Scoring · Deduplicates, grounds, and scores findings.
server/services/grounding.py - Patch Validation · Validates precise preview patches before application.
server/services/patching.py
Knowledge & AI
- Curated Knowledge Retrieval · Uses rule/category evidence before semantic matches.
server/knowledge/retrieval.py - Project Context Retrieval · Separate project-context and chat retrieval concern.
server/services/retrieval.py - AI Reasoning · Produces explanations, quality review, chat, and patch proposals.
server/services/reasoning_engine.py
Data & External Services
- MongoDB Atlas · Stores project data and sage_knowledge vectors.
- Groq · Isolated LLM integration for non-authoritative reasoning.
server/services/groq_client.py - Embedding Services · Generates 384-dimensional embeddings with fallback behavior.
server/services/embeddings.py
Connections 24
- Client Bootstrap → Workspace App: mounts
- Workspace App → Review & Fix Views: renders
- Workspace App → Auth State: uses
- Review & Fix Views → API Client: calls
- API Client → API Schemas: exchanges
- API Client → Backend Registration: HTTP
- Backend Registration → Product Routers: registers
- Product Routers → API Schemas: validates with
- Product Routers → Project Analyzer: starts analysis
- Project Analyzer → Language Evidence: derives evidence
- Language Evidence → Python Deep Analysis: deepens Python evidence
- Project Analyzer → Grounding & Scoring: submits findings
- Python Deep Analysis → Grounding & Scoring: adds evidence
- Grounding & Scoring → Curated Knowledge Retrieval: retrieves guidance · Guidance informs recommendations, not finding proof.
- Product Routers → Project Context Retrieval: retrieves project context
- Curated Knowledge Retrieval → AI Reasoning: supplies guidance
- Project Context Retrieval → AI Reasoning: supplies context
- AI Reasoning → Groq: LLM calls
- AI Reasoning → Patch Validation: proposes patches
- Product Routers → Patch Validation: requests preview/apply
- Patch Validation → Project Analyzer: reanalysis after apply
- Curated Knowledge Retrieval → Embedding Services: semantic search
- Embedding Services → MongoDB Atlas: vectors
- Product Routers → MongoDB Atlas: projects and application data