How dhairyaaa15/webpage-bot-extension works
Backend’s purpose and main components
• Purpose: Expose two HTTP endpoints (/analyze, /ask) that crawl webpages, summarize content, and answer user questions via an AI model.
• Components:
• Flask app (app.py)
• Analyzer module (analyzer.py)
• Chatbot module (chatbot.py)
• External services: Playwright browser, Gemini LLM API
• Session store (in-memory or simple dict in app.py)
A. Client → POST /analyze
1. Flask route handler in app.py receives { "url": "..." }.
2. Calls analyzer.py:
• Launches Playwright, navigates to the URL
• Extracts page content, generates a summary/chunked context
• Returns { message, prompt_preview, session_id }
3. app.py stores the summary & session context keyed by session_id.
4. Response sent back to client with JSON payload.
B. Client → POST /ask
1. Flask route handler in app.py receives { "question", "session_id" }.
2. Looks up context using session_id.
3. Calls chatbot.py:
• Sends the stored context + user question to Gemini LLM API
• Receives AI’s answer
4. Returns { "answer": "<AI's answer>" } to client.