# joncarre/network-analyzer architecture

> Architecture diagram of the GitHub repository joncarre/network-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joncarre/network-analyzer
- Repository: https://github.com/joncarre/network-analyzer

## Overview

##### Project type and purpose
- Network Analyzer is a full-stack, microservice-style application for capturing, processing, storing and AI-enhanced analysis of network packet data.
- The backend (Python/FastAPI) orchestrates four core services (capture, processing, database, AI) and exposes REST endpoints. The frontend (React + TailwindCSS) provides an interactive web UI including tables, charts and a chat interface.

##### File structure
- Top level:
- backend/ – FastAPI app
- frontend/ – React app
- backend/ subfolders:
- api/ – route handlers (ai_api.py, capture_api.py, database_api.py, processing_api.py)
- / – TShark integration
- processing/ – PCAP → data structures
- database/ – ORM models, SQLite schemas
- ai/ – Claude AI prompts & metrics
- tests/, benchmarks/
- run.py, main.py, config (env, .env.example)
- frontend/ structure:
- src/components, src/pages – React components for CapturePage, AnalysisPage, ChatInterface, PacketTable, AnomalyTable, SessionAnalytics
- src/services/api.js – HTTP client
- Tailwind + Vite config

##### Key README insights
- Microservices-style architecture: Capture, Processing, Database, REST API, IA Integration
- Tech stack: FastAPI, SQLite, TShark, Pandas, React, TailwindCSS, WebSocket/REST, Anthropic Claude
- User flow:
1) Via TShark → PCAP
2) Auto-processing → validate + parse → SQLite DB
3) UI visualizes stats + tables
4) Chat interface to AI for natural-language analysis

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client and Frontend
    Client["Client (Browser)"]:::frontend
    subgraph "Frontend"
        direction TB
        ReactUI["React UI"]:::frontend
        CapturePage["CapturePage"]:::frontend
        AnalysisPage["AnalysisPage"]:::frontend
        HomePage["HomePage"]:::frontend
        PacketTable["PacketTable"]:::frontend
        AnomalyTable["AnomalyTable"]:::frontend
        SessionAnalytics["SessionAnalytics"]:::frontend
        ChatInterface["ChatInterface"]:::frontend
        Navbar["Navbar"]:::frontend
        APIClient["API Client (api.js)"]:::frontend
    end

    Client -->|"interacts with"| ReactUI
    ReactUI -->|renders pages/components| CapturePage
    ReactUI -->|renders pages/components| AnalysisPage
    ReactUI -->|renders pages/components| HomePage
    CapturePage -->|uses| PacketTable
    AnalysisPage -->|uses| AnomalyTable
    AnalysisPage -->|uses| SessionAnalytics
    ReactUI -->|uses| ChatInterface
    ReactUI -->|navigation| Navbar
    ReactUI -->|calls REST/WebSocket| APIClient

    %% Backend and services
    subgraph "Backend (FastAPI)" 
        direction TB
        APIGateway["API Gateway\n(FastAPI)"]:::backend
        subgraph "Services"
            direction TB
            CaptureService["Capture Service\n(TShark)"]:::backend
            ProcessingService["Processing Service\n(PCAP Processor)"]:::backend
            DatabaseService["Database Service\n(ORM Models)"]:::backend
            AIService["AI Service\n(Claude Integration)"]:::backend
        end
        DB["SQLite Database"]:::database
    end

    APIClient -->|"HTTP/WS requests"| APIGateway
    APIGateway -->|"capture API calls"| CaptureService
    CaptureService -->|"spawns"| TSharkCLI
    CaptureService -->|"writes PCAP files"| PCAPStorage["PCAP Directory"]:::external
    APIGateway -->|"processing API calls"| ProcessingService
    ProcessingService -->|"reads PCAP files"| PCAPStorage
    ProcessingService -->|"parses & writes records"| DB
    APIGateway -->|"database API calls"| DatabaseService
    DatabaseService -->|"CRUD operations"| DB
    APIGateway -->|"AI API calls"| AIService
    AIService -->|"calls Claude API"| ClaudeAPI
    ClaudeAPI -->|"response"| AIService
    AIService -->|"returns analysis"| APIGateway
    APIGateway -->|"responses"| APIClient

    %% External services
    TSharkCLI["TShark CLI"]:::external
    ClaudeAPI["Claude API"]:::external

    %% Click events for mapped components
    click Client "https://github.com/joncarre/network-analyzer/tree/main/frontend/src/"
    click CapturePage "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/pages/CapturePage.jsx"
    click AnalysisPage "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/pages/AnalysisPage.jsx"
    click HomePage "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/pages/HomePage.jsx"
    click PacketTable "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/components/PacketTable.jsx"
    click AnomalyTable "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/components/AnomalyTable.jsx"
    click SessionAnalytics "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/components/SessionAnalytics.jsx"
    click ChatInterface "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/components/ChatInterface.jsx"
    click Navbar "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/components/Navbar.jsx"
    click APIClient "https://github.com/joncarre/network-analyzer/blob/main/frontend/src/services/api.js"
    click APIGateway "https://github.com/joncarre/network-analyzer/blob/main/backend/main.py"
    click APIGateway "https://github.com/joncarre/network-analyzer/blob/main/backend/run.py"
    click CaptureService "https://github.com/joncarre/network-analyzer/blob/main/backend/capture/network_interfaces.py"
    click ProcessingService "https://github.com/joncarre/network-analyzer/blob/main/backend/processing/pcap_processor.py"
    click DatabaseService "https://github.com/joncarre/network-analyzer/blob/main/backend/database/models.py"
    click DatabaseService "https://github.com/joncarre/network-analyzer/blob/main/backend/db_structure.py"
    click DatabaseService "https://github.com/joncarre/network-analyzer/blob/main/backend/db_query.py"
    click AIService "https://github.com/joncarre/network-analyzer/blob/main/backend/ai/claude_integration.py"
    click AIService "https://github.com/joncarre/network-analyzer/blob/main/backend/ai/analyze_metrics.py"
    click AIService "https://github.com/joncarre/network-analyzer/blob/main/backend/ai/claude_metrics.py"
    click TSharkCLI "https://github.com/joncarre/network-analyzer/blob/main/backend/requirements.txt"
    click ClaudeAPI "https://github.com/joncarre/network-analyzer/blob/main/backend/.env.example"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#DFFFE0,stroke:#22863A,color:#22863A
    classDef database fill:#FFE8A1,stroke:#A96D00,color:#A96D00
    classDef external fill:#F0F0F0,stroke:#6A737D,color:#6A737D
```
