How rezabrizi/litcoach works
Project Type & Purpose
• LitCoach is a Chrome extension that interacts with both a frontend (extension UI) and a backend API.
• Its purpose is to offer coding assistance and premium features using third-party integrations (GitHub, Stripe, OpenAI) and a MongoDB store.
Analyzing the File Structure
• The project has two primary parts:
• The backend: Located in the ‘api’ directory, it includes:
• app.py (entry point), config.py, and separate folders for db (database connections), models (data structures and business logic for AI help, GitHub, Leetcode, Stripe, user management), routes (API endpoints), and services (external integrations with AI, GitHub, Stripe).
• The frontend/extension: Found under ‘src’ with subdirectories like:
• background (background scripts crucial for Chrome extension event handling)
• options and sidepanel (the UI aspects of the extension presented to the user)
• components (reusable UI components in React/JSX), hooks, lib, and styles
• Other supporting files hint at build tools and configurations (Vite, ESLint, Tailwind, etc.), which means a modern JavaScript framework (likely React) is being used.
Insights from the README
• Provides clear instructions for setting up a Python environment for the backend and an npm environment for the frontend.
• Lists necessary external dependencies such as GitHub OAuth, Stripe, MongoDB, and the OpenAI API for AI functionalities.
• Mentions specific activities like Stripe webhook setup and loading the Chrome extension, emphasizing the integration between extension frontends and backend services.
a. Main Components:
• Chrome Extension Frontend:
• Options Page (user settings/configuration)
• Sidepanel (primary interactive display within the browser)
• Background Script (for event handling and communication)
• API Backend:
• API Application (built with Uvicorn/ASGI serving routes defined in ‘api/routes’)
• Controllers/Routes (each file corresponds to different endpoints like ai_assistance, GitHub auth, subscription management, etc.)
• Data Models (in ‘api/models’ outlining the domains such as ai_help, create_repo, user, etc.)
• Services (wrappers around third-party APIs: GitHub, Stripe, and OpenAI)
• Database Module (MongoDB access as per the ‘api/db’ directory)
• External Services:
• GitHub (OAuth authentication and code integration)
• Stripe (subscription management and webhook integration)
• OpenAI (AI assistance services)
• MongoDB (database cluster for persistent storage)
b. Relationships & Interactions:
• The Chrome extension UI sends requests to the backend API endpoints.
• API endpoints interact with the database for CRUD operations.
• The backend calls external APIs:
• GitHub for authentication and operations.
• Stripe for payment processing and subscription renewals.
• OpenAI for generating AI-based responses.
• Stripe also sends webhook events directly to a designated API endpoint (as set up with the CLI forwarding).
• The communication flows from the extension (client) → API server → external services / database.
c. Highlighting Architectural Patterns and Design Principles:
• Separation of Concerns: The frontend (UI/extension code) and the backend (API with business logic) are cleanly separated.
• Modularization: The backend is split into models, routes, and services, each responsible for a specific domain.
• API-Driven Architecture: The Chrome extension interacts with a structured API layer.
• Use of Config Files & Environment Variables: Sensitive external keys and configurations are abstracted in the .env file.
d. Relevant Technologies and Frameworks:
• Frontend: JavaScript/React (JSX files, Vite, Tailwind CSS, ESLint configuration)
• Backend: Python, FastAPI or similar ASGI framework running via Uvicorn (as per “uvicorn api.app:app --reload”)
• External Integrations:
• Stripe (payments and subscriptions)
• GitHub OAuth
• OpenAI API
• MongoDB for database operations
Elements
• One for frontend components (perhaps in blue)
• One for backend components (in green)
• One for external services (in orange or red)