# narradorww/seo-lp-ia architecture

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

- Interactive diagram: https://gitdiagram.com/narradorww/seo-lp-ia
- Repository: https://github.com/narradorww/seo-lp-ia

## Overview

##### Main Components
- Frontend Application: Represented by the Next.js “app” directory that uses the App Router. This is where the page components (e.g., header, footer, Magic Mirror, portfolio, and visitor stats) are rendered.
- API Endpoints: Within the “src/app/api”, there are endpoints for “/notify” (triggering email notifications) and “/visitor” (collecting visitor statistics).
- External Services:
- Resend email API for sending notifications.
- ipapi.co for geolocation based on IP.
- Supporting and Utility Layers: Include hooks (like useGithubRepos), types, and utility functions which help in processing data but are not direct UI/API elements.

##### Relationships and Data Flow
- The Browser/User interacts with the Next.js frontend.
- Certain user interactions (or visitor events) in the UI cause API requests to the “/api/visitor” endpoint to log and collect visitor stats.
- When required, the “/api/notify” endpoint is invoked to send email notifications, which then interacts with the Resend API.
- The frontend also might interact with external services indirectly through these endpoints (e.g., fetching geolocation data from ipapi.co on the backend).
- The layout and UI components (Layout, MagicMirror, Portfolio, Stats) are reused across pages and are styled with CSS Modules along with a global stylesheet.

##### Architectural Patterns and Design Principles
- Next.js App Router pattern: You see clear separation in the “app” directory with dedicated UI layers and API routes.
- Component-based Architecture: The “src/components” directory indicates a modular design with self-contained UI components.
- API-driven communication: The API endpoints act as intermediaries between the frontend and external services.
- Responsive and SEO-friendly design: As noted in the README, the project emphasizes accessibility, responsiveness, and performance.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User/Browser"]:::user

    subgraph "Next.js Frontend UI"
        UI1["UI Pages & Global Styling"]:::frontend
        UI2["UI Components: Layout, MagicMirror, Portfolio, Stats"]:::frontend
        UI1 --- UI2
    end

    subgraph "Backend API Endpoints"
        API_NOTIFY["/api/notify (Email Notifications)"]:::backend
        API_VISITOR["/api/visitor (Visitor Stats)"]:::backend
    end

    RESEND["Email Notification Service (Resend)"]:::external
    IPAPI["IP Geolocation (ipapi.co)"]:::external

    UTILITY["Utility & Helper Functions"]:::utility
    TEST["Testing Suite (Jest, React Testing Library)"]:::note

    U -->|"interacts"| UI1
    U -->|"interacts"| UI2

    UI1 -->|"triggers"| API_NOTIFY
    UI1 -->|"triggers"| API_VISITOR
    UI2 -->|"triggers"| API_NOTIFY
    UI2 -->|"triggers"| API_VISITOR

    API_NOTIFY -->|"calls"| RESEND
    API_VISITOR -->|"calls"| IPAPI

    UI1 -->|"uses"| UTILITY
    UI2 -->|"uses"| UTILITY
    API_NOTIFY -->|"uses"| UTILITY
    API_VISITOR -->|"uses"| UTILITY

    UI1 --- TEST
    UI2 --- TEST
    API_NOTIFY --- TEST
    API_VISITOR --- TEST

    click UI1 "https://github.com/narradorww/seo-lp-ia/tree/main/src/app"
    click UI2 "https://github.com/narradorww/seo-lp-ia/tree/main/src/components"
    click API_NOTIFY "https://github.com/narradorww/seo-lp-ia/blob/main/src/app/api/notify/route.ts"
    click API_VISITOR "https://github.com/narradorww/seo-lp-ia/blob/main/src/app/api/visitor/route.ts"
    click UTILITY "https://github.com/narradorww/seo-lp-ia/blob/main/src/hooks/useGithubRepos.ts"
    click UTILITY "https://github.com/narradorww/seo-lp-ia/blob/main/src/utils/formatters.ts"
    click UTILITY "https://github.com/narradorww/seo-lp-ia/tree/main/src/types"
    click TEST "https://github.com/narradorww/seo-lp-ia/tree/main/src/__tests__"

    classDef user fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef utility fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef note fill:#F0E68C,stroke:#000,stroke-width:2px;
```
