How narenderrai/cyberthreatanalyzer works
Project Type and Purpose
• This is a full‐stack, single‐service Streamlit application for cybersecurity threat research, analysis, and visualization.
• It integrates with the OpenAI GPT API and persists threat data in a local SQLite database.
File Structure
• Top‐level entrypoint: main.py (Streamlit UI)
• UI/Presentation components: components/ui.py and components/visualization.py
• Business logic modules:
• utils/gpt_helper.py (GPTHandler)
• utils/threat_analyzer.py (ThreatAnalyzer)
• utils/database.py (DB connector/ORM)
• Templates/prompts: templates/prompts.py
• Sample data for offline/testing: data/sample_threats.py
• Database file: threat_database.db
• Deployment/config: .streamlit/config.toml, rep.nix, Docker/ECS instructions in README
Extract Architecture Insights from the README
• Clearly defined layers: UI → GPTHandler → ThreatAnalyzer → Database
• Optional NewsScraper (not in file tree but mentioned) can be slotted beside GPTHandler
• Supports Docker, AWS ECS/Fargate, Replit deployments
Main Components
a. Presentation Layer
• User’s Web Browser (HTTP)
• Streamlit UI (main.py + components/)
b. Application/Service Layer
• GPTHandler (utils/gpt_helper.py) → calls OpenAI API
• ThreatAnalyzer (utils/threat_analyzer.py) → orchestrates analysis, tagging, formatting
• Templates/Prompt Engine (templates/prompts.py)
• (Optional) NewsScraper module
c. Data Layer
• SQLite database (threat_database.db) via utils/database.py
• Sample Data source (data/sample_threats.py) for testing
d. External Services
• OpenAI GPT API
• (Optional) News feed endpoints
Relationships and Data Flows
• User submits query → Streamlit UI
• UI invokes ThreatAnalyzer
• ThreatAnalyzer builds prompt (templates/prompts.py)
• Calls GPTHandler → external GPT API
• Receives analysis + tags
• Persists results via Database module
• UI fetches history/search results from DB
• UI renders both raw and formatted data (components/visualization.py)
Architectural Patterns
• Layered Architecture: clear separation of Presentation, Application, Data layers
• Modular Design: distinct modules for GPT integration, analysis logic, UI components
• Single‐Service Container: runs as one Streamlit process, deployable via Docker/ECS