# borisghidaglia/meet-hn architecture

> Architecture diagram of the GitHub repository borisghidaglia/meet-hn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/borisghidaglia/meet-hn
- Repository: https://github.com/borisghidaglia/meet-hn

## Overview

##### Main Components

A. Frontend Layer:
- Next.js App Router Structure (indicated by the app directory)
- Client Components (components directory)
- Server Components (app directory components)
- UI Components (components/ui directory)

B. Backend Layer:
- API Routes (app/_actions directory)
- Database Operations (app/_db directory)
- External Services Integration (app/_lib directory)

C. Database Layer:
- Schema (represented in app/_db/schema.ts)
- Models (City.ts and User.ts)

D. External Services:
- Telegram Integration (indicated by app/_lib/telegram.ts)
- Service Integration (MapComponent.tsx)

**[Client Layer]**
- ↕
**[Next.js Server Layer]**
- ↕
**[Database Layer]**
- ↕
**[External Services]**

##### Component Details

A. Client Layer (Top):
- Client-side hooks (useMediaQuery)
- Client-side routing components

B. Next.js Server Layer:
- App Router structure with routes:
- Root (/)
- City pages (/city/[...id])
- Feedback (/feedback)
- Delete (/delete)
- Server Actions (_actions directory)
- Data fetching and mutation flows

C. Database Layer:
- Main entities: User and City
- Relationships between entities
- Database client connections

D. External Services (Bottom):
- Telegram Integration
- Service
- Any other third-party services

##### Additional Elements

- A testing layer showing Playwright tests
- Build and configuration files
- Utility scripts (scripts directory)
- Authentication flow if present

##### Feedback submission

Remember to indicate the Next.js-specific features like server components, client components, and server actions, as these are crucial to understanding the application's architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[UI Components]
        SignUpForm[SignUpForm]:::client
        CitySelector[CitySelector]:::client
        MapComponent[MapComponent]:::client
        MapContainerClient[MapContainerClient]:::client
        FeedbackForm[FeedbackForm]:::client
        DeleteForm[DeleteForm]:::client
        useMediaQuery[useMediaQuery]:::client
    end

    subgraph "Next.js Server"
        AppRouter[App Router]:::server
        ServerActions[Server Actions]:::server
        RootPage[Root Page]:::server
        CityPage[City Page]:::server
        FeedbackPage[Feedback Page]:::server
        DeletePage[Delete Page]:::server
        ErrorHandling[Error Handling]:::server
        Revalidation[Revalidation]:::server
    end

    subgraph Database
        Schema[Schema]:::db
        CityModel[City Model]:::db
        UserModel[User Model]:::db
        DBClient[Database Client]:::db
        CityClient[City Client]:::db
        UserClient[User Client]:::db
    end

    subgraph "External Services"
        TelegramService[Telegram Service]:::external
        MapService[Map Service]:::external
    end

    subgraph Testing
        PlaywrightTests[Playwright Tests]:::test
        UnitTests[Unit Tests]:::test
    end

    subgraph Scripts
        MigrationScripts[Migration Scripts]:::script
        MaintenanceScripts[Maintenance Scripts]:::script
    end

    %% Relationships
    UI --> SignUpForm & CitySelector & MapComponent & FeedbackForm & DeleteForm
    MapComponent --> MapContainerClient
    SignUpForm --> ServerActions
    CitySelector --> ServerActions
    FeedbackForm --> ServerActions
    DeleteForm --> ServerActions

    AppRouter --> RootPage & CityPage & FeedbackPage & DeletePage & ErrorHandling
    ServerActions --> DBClient
    DBClient --> CityClient & UserClient
    CityClient --> CityModel
    UserClient --> UserModel
    Schema --> CityModel & UserModel

    ServerActions --> TelegramService
    MapComponent --> MapService

    %% Click Events
    click AppRouter "https://github.com/borisghidaglia/meet-hn/tree/main/app/"
    click RootPage "https://github.com/borisghidaglia/meet-hn/blob/main/app/page.tsx"
    click CityPage "https://github.com/borisghidaglia/meet-hn/blob/main/app/(not-root)/city/[...id]/page.tsx"
    click FeedbackPage "https://github.com/borisghidaglia/meet-hn/blob/main/app/(not-root)/feedback/page.tsx"
    click DeletePage "https://github.com/borisghidaglia/meet-hn/blob/main/app/(not-root)/delete/page.tsx"
    click SignUpForm "https://github.com/borisghidaglia/meet-hn/blob/main/components/SignUpForm.tsx"
    click CitySelector "https://github.com/borisghidaglia/meet-hn/blob/main/components/CitySelector.tsx"
    click MapComponent "https://github.com/borisghidaglia/meet-hn/blob/main/components/MapComponent.tsx"
    click MapContainerClient "https://github.com/borisghidaglia/meet-hn/blob/main/components/MapContainerClient.tsx"
    click FeedbackForm "https://github.com/borisghidaglia/meet-hn/blob/main/components/FeedbackForm.tsx"
    click DeleteForm "https://github.com/borisghidaglia/meet-hn/blob/main/components/DeleteForm.tsx"
    click UI "https://github.com/borisghidaglia/meet-hn/tree/main/components/ui/"
    click ServerActions "https://github.com/borisghidaglia/meet-hn/tree/main/app/_actions/"
    click Schema "https://github.com/borisghidaglia/meet-hn/blob/main/app/_db/schema.ts"
    click CityModel "https://github.com/borisghidaglia/meet-hn/blob/main/app/_db/City.ts"
    click UserModel "https://github.com/borisghidaglia/meet-hn/blob/main/app/_db/User.ts"
    click DBClient "https://github.com/borisghidaglia/meet-hn/blob/main/app/_db/Client.ts"
    click CityClient "https://github.com/borisghidaglia/meet-hn/blob/main/app/_db/City.client.ts"
    click UserClient "https://github.com/borisghidaglia/meet-hn/blob/main/app/_db/User.client.ts"
    click TelegramService "https://github.com/borisghidaglia/meet-hn/blob/main/app/_lib/telegram.ts"
    click useMediaQuery "https://github.com/borisghidaglia/meet-hn/blob/main/app/_hooks/useMediaQuery.ts"
    click ErrorHandling "https://github.com/borisghidaglia/meet-hn/blob/main/app/error.tsx"
    click Revalidation "https://github.com/borisghidaglia/meet-hn/blob/main/app/revalidate/route.ts"
    click PlaywrightTests "https://github.com/borisghidaglia/meet-hn/blob/main/app/_tests/playwright/SignUpForm.test.ts"
    click UnitTests "https://github.com/borisghidaglia/meet-hn/blob/main/app/_tests/hnAboutParsing.test.ts"
    click MigrationScripts "https://github.com/borisghidaglia/meet-hn/blob/main/scripts/migrateCitiesAndUsers.ts"
    click MaintenanceScripts "https://github.com/borisghidaglia/meet-hn/blob/main/scripts/updateCommunityLinks.ts"

    %% Styles
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef db fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef test fill:#e74c3c,stroke:#c0392b,color:white
    classDef script fill:#95a5a6,stroke:#7f8c8d,color:white
```
