How yug-sinha/url-copilot works
Main Components
• Frontend Component:
• Built with Next.js and styled with Tailwind CSS.
• Contains the React-based chat interface.
• Interacts with backend API endpoints (/extract and /chat).
• Static assets and dynamic pages (files in the “app” directory, public assets, and configuration files like next.config.mjs).
• Backend Component:
• Built with FastAPI and integrates Playwright to scrape and extract text (from both parent pages and child links).
• Exposes API endpoints (/extract and /chat).
• Integrates with an external LLM service (Google Gemini or similar) for generating query responses.
• Contains utility functions (as in utils.py) and the main FastAPI app (in main.py).
• Docker Container:
• Single Dockerfile builds both frontend and backend using a multi‑stage build.
• Represents the unified deployment artifact where both services are served from one container.
• External Dependencies:
• Google Gemini or other LLM API.
• Web resources (target websites for scraping).
Relationships and Data Flow
• Users access the frontend over HTTP (for example, via port 80 when deployed in Docker).
• The frontend makes API calls (POST /extract and POST /chat) to the backend within the same container.
• The backend (FastAPI) processes the requests by invoking Playwright to fetch and scrape the website content, then passes the data to the LLM API (Google Gemini) to obtain responses.
• The responses are then funneled back to the frontend which displays them in the chat UI.
Highlighted Architectural Patterns and Design Principles
• Separation of Concerns:
• Frontend and backend functionalities are clearly separated into distinct directories and responsibilities.
• API-Driven Communication:
• Clearly defined REST endpoints (POST /extract, POST /chat) for interactions.
• Single Container Deployment:
• Emphasizes ease of deployment and unified process by multi‑stage Docker builds.
• Extensible Scraping and LLM Integration:
• The backend is modular with clear responsibilities (e.g., extracting text, querying LLM, handling utility functions).