How adgpt/codecritic-ai works
Project Type & Purpose
• CodeCritic-AI is a modern, frontend-heavy, AI-powered code review assistant. It gives feedback on code quality in “real time.”
• The README highlights features such as a code editor with syntax highlighting, AI-powered code analysis (leveraging an external Gemini API), secure authentication via Supabase (with Google and GitHub OAuth), and a modern UI built with shadcn-ui and Tailwind CSS.
File Structure
• There’s no explicit separate backend folder—instead, the architecture is built around a frontend application (using Vite, React, and TypeScript) with integration to external services.
• Look at the “src” directory:
• “components” contain UI parts such as CodeEditor, CodeReviewer, Navbar, ReviewSummary, and others.
• “contexts” holds AuthContext.tsx, indicating that user authentication and state management are handled in a React context.
• “hooks” and “lib” directories suggest custom utilities for toast notifications (and probably other shared logic) as well as integrations such as Supabase.
• “pages” show route components including Home, Login, NotFound, Profile, etc.
• “services” (with codeAnalysisService.ts) likely encapsulate API calls to AI-code analysis endpoints.
• There is also a “supabase” directory with migration SQL scripts, which means that Supabase is used not only for authentication but also for managing the underlying user profile and possibly other database-backed logic.
• Various configuration and environment files such as .env, Vite config, Tailwind, and tsconfig indicate a tightly integrated deployment and development setup.
Key Components
a. Frontend Application (SPA)
• Developed with React, TypeScript, and Vite.
• Components are split into UI elements (in “components/ui”) and functional sections (CodeEditor, CodeReviewer, Navbar, etc.).
• Pages (Home, Login, Profile, etc.) and routing logic.
• Context providers (such as AuthContext) responsible for managing state and user sessions.
b. External Services & APIs
• Supabase: Used for secure authentication, OAuth integrations (Google, GitHub), and database management.
• Gemini API: Integrated via environment variables for AI-powered code analysis (as mentioned in the README).
c. Code Analysis Service
• Represented by src/services/codeAnalysisService.ts, which likely communicates with the Gemini API or other AI endpoints.
d. Database & Migrations
• A Supabase database with user profiles and associated RLS (Row Level Security) policies managed under the “supabase/migrations” directory.
e. Build & Configuration Utilities
• Vite for frontend tooling.
• Tailwind CSS and shadcn-ui for the user interface.
• ESLint configurations, environment settings, and other build tools acting as supporting infrastructure.
Relationships and Interactions
• The Frontend (SPA) interacts directly with:
• Supabase for authentication and to fetch/store user profile information.
• The Code Analysis Service for sending code to be reviewed and receiving AI feedback.
• The AuthContext in React manages session state and permissions that are used across the application.
• UI Components (like the CodeEditor, CodeReviewer, and Navbar) communicate with each other (or via context) and with Services to reflect real-time results.
• External APIs (Gemini API) are called indirectly from the services layer, ensuring separation of concerns.
Architectural Patterns & Design Principles
• Component-Based Architecture: The project uses a very modular approach, with clearly separated UI components and custom hooks.
• Separation of Concerns: The use of contexts (AuthContext) and services (codeAnalysisService) decouples business logic from the UI.
Customizing for CodeCritic-AI
• Because CodeCritic-AI is a full-stack-like application with a strong emphasis on frontend functionality and external API integrations:
• Separation between the presentation layer (React components/pages, UI components library) and the service layer (code analysis service).
• Authentication process that relies on Supabase and the integrations with Google/GitHub.
• Incorporate specific modules like the “CodeEditor” and “CodeReviewer” to show where the AI feedback loop is initiated in the user experience.
• Do not overcomplicate by splitting every minor file; focus on logical groupings (e.g., UI components, service integration, authentication/context, and database management).
• Main UI and routing structure (SPA with React and TypeScript)
• Communication paths for user authentication (Supabase OAuth), fetching/updating user profile data, and handling secure sessions through AuthContext.
• Services used to power the AI feedback loop, including the Gemini API integration for code analysis.
• The supporting infrastructure that uses migrations and configurations (environment variables, build configurations) to glue these elements together.