How sudeepbogati7/threat-news-summarizer works
Project type and purpose
• This is a full-stack AI-powered chatbot application (“DeepCyberQ”) for querying recent cyber threats and news using RAG (Retrieval-Augmented Generation) and LangChain, with a FastAPI backend and a Next.js frontend.
File structure
• Top level:
• main.py – entrypoint for FastAPI
• news.db – SQLite DB for persisting news and user info
• src/api – FastAPI routers and endpoints (auth.py, news.py)
• src/core – configuration (config.py) and security (JWT, password hashing)
• src/database – database connection and session management
• src/middleware – request/response logging
• src/models & src/schemas – ORM models + Pydantic schemas for User and News
• src/services – business logic: news_fetcher (ingest/fetch news), rag (build and query vector store via LangChain)
• src/utils – custom exceptions
Key README insights
• Tech Stack: FastAPI, LangChain, RAG, Next.js
• Features: user registration/authentication, news browsing, chat interface that embeds RAG + LLM
Main components
a. Frontend (Next.js SPA)
b. API Gateway / Web Server (FastAPI)
• Middleware layer (logging)
• Auth module (core/security)
• Routers & endpoints (src/api)
c. Business Logic / Services
• NewsFetcher – retrieves, normalizes, and persists news into SQLite
• RAG service – builds vector store, invokes LLM via LangChain
d. Database (SQLite: news.db)
e. External services
• LLM provider (e.g. OpenAI)
• External News APIs or scrapers
Relationships & Data Flows
• User → (HTTPS) → Next.js UI
• Next.js → (HTTPS/API) → FastAPI
• Auth endpoints issue JWTs via core/security
• Chat endpoints call services/rag → LangChain → external LLM → response
• News endpoints call services/news_fetcher → database
• FastAPI ←→ SQLite (via src/database/db.py + ORM models)
• FastAPI → external News APIs when news_fetcher ingests data
• FastAPI → external LLM API via LangChain wrapper
Architectural patterns & principles
• Layered architecture:
• Presentation (frontend)
• API layer (routers + middleware)
• Service layer (business logic)
• Data access layer (ORM + database)
• Separation of concerns: auth, config, logging abstracted into core & middleware
• RAG pattern: retrieval store + LLM for dynamic answer generation
Final recommendations
• Be detailed: represent each subcomponent (middleware, routers, services).
• Data-flow: authentication handshake, RAG query pipeline, DB reads/writes.
• Don’t overthink: break the system into all logical pieces and show how they connect.
• Use sequence or flow annotations (e.g., 1: login, 2: fetch news, 3: chat query).
• It’s easy to follow for stakeholders and for onboarding new engineers.