# jason5ng32/myip architecture

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

- Interactive diagram: https://gitdiagram.com/jason5ng32/myip
- Repository: https://github.com/jason5ng32/myip

## Overview

##### Project Type and Purpose
- The project is a full-stack web application.
- Its purpose is to offer a rich "IP toolbox" that not only displays user IPs but also allows querying of IP information, tests (e.g., DNS leak, WebRTC), whois lookups, speed tests, and other network diagnostics.
- The README emphasizes multiple features (e.g., IP detection, censorship check, latency tests) which means that both frontend (using Vue.js) and backend (Node.js) parts play important roles.

##### Analyzing the File Structure
- There are two main server entry points at the root: "frontend-server.js" and "backend-server.js". This indicates that the architecture is split into two server processes:
- The Frontend server (serving the Vue single-page app).
- The Backend server (serving API endpoints and processing logic).
- The "frontend" directory contains the Vue application’s source code – components, router, store, styles, and utilities. This is the presentation layer.
- The "api" directory contains a collection of JavaScript files. Each of these files (e.g., "get-whois.js", "dns-resolver.js", "ipinfo-io.js") likely represents various API endpoints focused on IP intelligence and diagnostics.
- The "common" directory includes shared libraries and a local copy of the MaxMind database files, which are used for IP geolocation and related computations.
- Docker configuration files (Dockerfile, docker-compose.yml) and GitHub workflows indicate the availability of containerized deployment and continuous integration setups.

##### Key Components
a. Frontend Component:
- Technologies: Vue.js (with supporting files like App.vue, router, store) and static assets (in “public”).
- Responsibilities: Render UI, handle user interactions, and make AJAX/Fetch calls to the backend.
b. Backend Component:
- Responsibilities: Handle API requests, perform IP data lookups, and integrate with multiple APIs (as seen in the “api” directory).
c. API Endpoints:
- Contains endpoints like “get-user-info”, “get-whois”, “dns-resolver”, “google-map”, “invisibility-test”, etc.
- These endpoints serve as the intermediary between the frontend and the external IP/geolocation and network diagnostic services.
d. Common Utilities and Databases:
- These are used by backend processes to enrich or verify IP data.
e. External/Third-Party Services:
- These external services are referenced in both the API endpoints (to fetch detailed IP info) and via environment variable configurations.
f. Docker/Deployment Layer:
- Docker containers (using Dockerfile and docker-compose) that encapsulate the runtime environments.

##### Relationships and Data Flow
- Within the backend, indicate different API endpoints that, when triggered, fetch information:
– Some endpoints talk directly to local utilities (such as the MaxMind DB in the “common” folder).
- You may optionally note that Docker coordinates the building and running of these containers.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clear delineation between presentation (frontend Vue) and service logic (backend Node).
- Modular API Endpoints: Each file in the “api” folder likely represents discrete functionalities (e.g., DNS resolution, whois lookup), which can be illustrated as submodules within the backend.
- Configurable Environment: Use of environment variables to adjust ports and integrate third-party APIs for extensibility and adaptability.
- Containerized Deployment: Emphasize Docker-based deployment as a means for reproducible environments and CI/CD integration.

## Diagram (Mermaid)

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

    %% Application/API Layer
    subgraph "Application/API Layer"
        BE["NodeJS Backend"]:::backend
        API["API Endpoints"]:::api
    end

    %% Utilities & External Services
    subgraph "Utilities & External Services"
        COMMON["Common Utilities"]:::common
        EXT["External Services"]:::external
    end

    %% Infrastructure / Deployment Layer
    subgraph "Infrastructure (Docker/CI)"
        DF["Dockerfile"]:::infra
        DC["docker-compose.yml"]:::infra
        GH["GitHub Workflows"]:::infra
    end

    %% Connections between layers
    FE -->|"HTTP/HTTPS"| BE
    BE -->|"Handles"| API
    API -->|"Uses"| COMMON
    API -->|"Calls"| EXT

    %% Deployment arrows from Infrastructure to Application Layers
    DF -.->|"Builds Frontend"| FE
    DC -.->|"Orchestrates Backend"| BE
    GH -.->|"CI/CD Pipelines"| BE

    %% Click Events
    click FE "https://github.com/jason5ng32/myip/tree/main/frontend/"
    click BE "https://github.com/jason5ng32/myip/blob/main/backend-server.js"
    click API "https://github.com/jason5ng32/myip/tree/main/api/"
    click COMMON "https://github.com/jason5ng32/myip/tree/main/common/"
    click DF "https://github.com/jason5ng32/myip/tree/main/Dockerfile"
    click DC "https://github.com/jason5ng32/myip/blob/main/docker-compose.yml"
    click GH "https://github.com/jason5ng32/myip/tree/main/.github/workflows/"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef api fill:#98fb98,stroke:#000,stroke-width:2px;
    classDef common fill:#ffa500,stroke:#000,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef infra fill:#da70d6,stroke:#000,stroke-width:2px;
```
