How akshitjain16/repobot-ai works
Project Type and Purpose
• RepoBot AI is a full-stack web application built with Next.js that uses tRPC for type-safe, end-to-end APIs. Its purpose is to assist developers by interacting with and analyzing GitHub repositories, with features including natural language interactions for code explanation, project navigation, and quick answers about code structure.
• Key technologies include Next.js (for both frontend and backend rendering), tRPC (for API layer), Prisma (as the ORM layer for database interactions), and several utility libraries (e.g., usehooks-ts, zod).
Analyzing the File Structure
• Notice the separation within the src folder:
• The "src/app" directory holds the Next.js application pages. It includes public pages (e.g., sign-in, sign-up, landing) and a protected section (e.g., dashboard, billing, meetings, Q&A) indicating role-based access.
• The "src/api" subdirectory and “src/server/api” indicate there is a clear API structure, likely using tRPC endpoints for data operations.
• The "prisma" directory holds the schema (prisma/schema.prisma) which implies the use of a relational database.
• The "src/components/ui" directory contains a complete UI component library, which forms the building blocks for the presentation layer.
• Other directories such as "src/hooks", "src/lib", "src/styles" and "src/trpc" show the system has a well-organized and modular codebase.
• Configuration and setup files like next.config.js, tailwind.config.ts, tsconfig.json, and environment examples indicate standard practices for a modern web application.
Components of the System
• Frontend (Client-side)
• Built using Next.js. It handles user interface, routing, and rendering of both public and protected pages.
• UI components are encapsulated in "src/components/ui" and other custom components in "src/app" and "src/components".
• Integration of authentication flow (reflected in pages like sign-in and sign-up) and state management using hooks (e.g., use-project, use-refetch, use-toast).
• Backend (Server-side API and Business Logic)
• tRPC is used for creating a type-safe API layer. The endpoints are defined in directories like "src/app/api/trpc" and "src/server/api/routers".
• The server processes requests coming from the frontend and interacts with the database.
• Database
• Managed via Prisma (see the "prisma/schema.prisma"). This is likely a relational database (e.g., Postgres) handling persistent data – such as user profiles, token storage, GitHub repository information and more.
• External Integrations
• GitHub OAuth: Users connect their GitHub accounts using OAuth (environment variables for GITHUB_CLIENT_ID/SECRET and instructions in the README).
• GitHub API: The application uses modules like "src/lib/github-loader.ts" and "src/lib/github.ts" which are likely responsible for fetching repository data, commits, and logs.
• Middleware and Utility Layers
• Middleware in "src/middleware.ts" processes requests for authentication/authorization.
• Utility libraries ("src/lib/utils.ts", custom hooks, etc.) encapsulate recurring logic.
Architectural Patterns and Relationships
• The application uses a “unified” architecture with Next.js handling both frontend rendering and backend API routes.
• There is a clear separation between public and protected routes, suggesting a role-based or session-based access control.
• The tRPC API acts as the middleware connecting frontend operations and database interactions.
• External services (GitHub OAuth and API) are integrated as separate connectors/modules.
• The UI uses a component-driven design, and the codebase appears to follow best practices like modularity and separation of concerns.