How vardaanaroracodes/newsubackend works
Project type and purpose
• This is a full-stack conversational AI news aggregation service.
• Purpose: Allow users to query recent news via a Next.js frontend, authenticate via Clerk, then hit a Flask backend that uses LangChain agents to fetch, summarize, and return news from external APIs while persisting conversation sessions in MongoDB.
File structure
• Top-level files:
• config.py – environment & Flask configuration
• extensions.py – initializes shared extensions (e.g., Mongo client, LangChain tooling)
• models.py – defines MongoDB document schemas for sessions & messages
• requirements.txt, API_DOCUMENTATION.md, README.md
• Directories:
• api/ (index.py) – entry point where the Flask app and Blueprints are registered
• api_routes/ – Blueprint modules for auth, news, search routes
• services/ – “service layer” classes encapsulating business logic:
– newsagentservice.py (orchestrates LangChain, Serper, Gemini)
– session_service.py (create/read/delete sessions in Mongo)
– session_title_service.py (derive or fetch session titles)
README for additional insights
• Key components: Frontend (Next.js + Clerk), Backend (Flask Blueprints), LangChain agents, Google Gemini LLM, Serper news API, MongoDB for memory.
• Workflow steps and API endpoints are clearly detailed.