# bikum2301/nmap_mcp architecture

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

- Interactive diagram: https://gitdiagram.com/bikum2301/nmap_mcp
- Repository: https://github.com/bikum2301/nmap_mcp

## Overview

##### Project type and purpose
- A frontend GUI (`frontend/app_ui.py`)
- A backend service (`backend/main.py`, `backend/crud.py`, `backend/database.py`)
- A core utility library (`core/utils.py`)
- Likely purpose: provide a user interface for network scanning or management (NMAP), CRUD persistence of scan results, and reusable core logic.

##### File structure
- Top-level directories:
- frontend/ → user interface code (probably a desktop GUI or local web UI)
- backend/ → REST-style or RPC service code
- core/ → shared utility functions, business logic
- Key backend files:
- `main.py` → entry point or HTTP server
- `crud.py` → create-read-update-delete operations
- `database.py` → ORM or direct DB connection
- There are no separate deployment or container scripts visible, implying a single-service deployment.

##### README for additional insights
- The README is minimal. No explicit architecture notes, so we infer patterns from the structure:
- Layered architecture (UI → API → core logic → DB)
- Separation of concerns: frontend vs. backend vs. utilities

a. Main components:
- Frontend UI
- Backend API Server
- Core Utilities Library
- Database
- (Optional) External Nmap Engine or OS-level system calls
b. Relationships and interactions:
1. User interacts with Frontend →
2. Frontend makes HTTP (or direct function) calls to Backend API
3. Backend routes requests (main.py) → invokes CRUD (crud.py) and Core Utils (core/utils.py)
4. CRUD layer communicates with Database (backend/database.py)
5. For scanning tasks, Core Utils may call out to an external Nmap binary or OS process
c. Architectural patterns:
- Layered / n-tier architecture
- Clear separation: UI layer, API layer, business-logic layer (core), persistence layer
- Single codebase, no microservices
- Python (3.x)
- Likely Flask/FastAPI in `backend/main.py`
- SQLite or PostgreSQL via SQLAlchemy (in `database.py`)
- GUI toolkit (Tkinter, PyQt, or a web-based UI served by the backend)

##### Diagramming recommendations
- UI → HTTP → API Server
- API Server → function calls → Core Utils
- API Server → CRUD → Database
- Core Utils → external process → Nmap
- Blue for frontend components
- Green for backend/API
- Yellow for core/library
- Orange for database
- Gray for external services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Frontend UI"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        API["API Server"]:::backend
        CRUD["CRUD Layer"]:::backend
    end

    %% Core Layer
    subgraph "Core Layer"
        Core["Core Utils"]:::core
    end

    %% Data Layer
    subgraph "Data Layer"
        DB[(Database)]:::database
    end

    %% External Services
    Ext["External Nmap"]:::external

    %% Connections
    UI -->|"HTTP Request"| API
    API -->|"invoke CRUD operations"| CRUD
    API -->|"use core utilities"| Core
    CRUD -->|"read/write data"| DB
    Core -->|"execute scan"| Ext

    %% Click Events
    click UI "https://github.com/bikum2301/nmap_mcp/blob/main/frontend/app_ui.py"
    click API "https://github.com/bikum2301/nmap_mcp/blob/main/backend/main.py"
    click CRUD "https://github.com/bikum2301/nmap_mcp/blob/main/backend/crud.py"
    click DB "https://github.com/bikum2301/nmap_mcp/blob/main/backend/database.py"
    click Core "https://github.com/bikum2301/nmap_mcp/blob/main/core/utils.py"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085;
    classDef backend fill:#d4edda,stroke:#155724,color:#155724;
    classDef core fill:#fff3cd,stroke:#856404,color:#856404;
    classDef database fill:#ffe5b4,stroke:#cc8400,color:#cc8400;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
