# seba-wetzel/ecomunidad architecture

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

- Interactive diagram: https://gitdiagram.com/seba-wetzel/ecomunidad
- Repository: https://github.com/seba-wetzel/ecomunidad

## Overview

##### Main Components
- Frontend (UI/Pages):
– Represent the Next.js pages found under src/app, including different sections like the “(admin)” and “(principal)” folders.
– Include components folders (e.g., src/components and src/app/(admin)/registrate/components) which handle form elements and other UI parts.
– Note the use of Tailwind CSS, global stylesheets (src/app/globals.css), and custom UI components (under src/components/ui).

- API Layer and Server-Side Logic:
– Map the API routes under src/app/api covering different functionalities (cron jobs, registro, and validation endpoints for direction and email).
– Include the connection between the frontend pages/forms and the API endpoints (showing data flow for registration and validation).

- Domain & Business Logic:
– Emphasize the modular structure seen in src/modules/Cliente. Break this segment into:
a. Application Layer (e.g., createCliente.ts, getClientes.ts): Handles use-case orchestration.
b. Domain Layer (e.g., Cliente.ts, Direccion.ts): Represents the core business entities and interfaces.
c. Infrastructure Layer (e.g., SupabaseClienteRespository.ts): Handles external dependencies and data persistence.
– Also include shared utilities and adapters (under src/modules/shared) which contain the database configurations, migrations, and schemas.

- Database and Persistence:
– Set aside the shared database module (src/modules/shared/database) which includes migrations, schemas, and configurations.
– Highlight the use of Supabase (as seen in the Supabase configuration) and possibly Drizzle ORM integration from the drizzle.config.ts file.

- Third-Party Integrations:
– Identify integrations like the Google address validator (src/lib/google/addressValidator.ts) which implies external service communication.

##### Relationships and Data Flow
- How the API layer interacts with the domain/application layers to handle business logic.
- Connection between the infrastructure layer (e.g., Supabase/DB) and the domain components.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clearly differentiate the presentation layer (React components/Next.js pages), API layer, domain/application logic, and infrastructure/database.
- Modular and Domain-Driven Design: Note the separation into modules (like the "Cliente" module) with clear boundaries between Application, Domain, and Infrastructure.
- Use of API Routes: Emphasize how Next.js API routes are utilized for server-side operations.
- Separation of Concerns: Showcase how configuration, business logic, UI, and data persistence are organized in distinct directories.

##### Relevant Technologies & Frameworks
- Next.js (with the new App Router structure)
- React (components and UI)
- Supabase (for database interaction as evident from SupabaseClienteRespository)
- Tailwind CSS (for styling)
- Possibly Drizzle ORM (as indicated by the drizzle.config.ts, migrations, and database scripts)
- Zod (for schema validation, seen in adapters like ClienteSchema.zod.ts)
- External APIs: Google address validation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Browser["User Browser"]:::browser

    %% Frontend Layer
    subgraph "Frontend Layer"
        A["Next.js Frontend Pages & Layouts"]:::frontend
        B["UI Components"]:::ui
        C["Global Styles"]:::ui
        D["Tailwind Config"]:::ui
    end

    %% API Layer
    subgraph "API Layer"
        E["API Routes & Server-Side Logic"]:::api
    end

    %% Cliente Domain Module
    subgraph "Cliente Domain Module"
        F["Application Layer (Cliente)"]:::domain
        G["Domain Layer (Cliente)"]:::domain
        H["Infrastructure Layer (Cliente)"]:::infrastructure
        I["Shared Adapters"]:::domain
    end

    %% Database & Persistence
    subgraph "Database & Persistence"
        J["Database & Migrations"]:::db
    end

    %% Third-Party Integrations
    subgraph "Third-Party Integration"
        K["Google Address Validator"]:::external
    end

    %% Connections
    Browser -->|"initiates"| A
    A -->|"triggers"| E
    E -->|"calls"| F
    F -->|"orchestrates"| G
    G -->|"delegates to"| H
    H -->|"persists data to"| J
    H -->|"validates address via"| K
    G -->|"utilizes"| I

    %% Click Events
    click A "https://github.com/seba-wetzel/ecomunidad/tree/main/src/app"
    click B "https://github.com/seba-wetzel/ecomunidad/tree/main/src/components"
    click C "https://github.com/seba-wetzel/ecomunidad/blob/main/src/app/globals.css"
    click D "https://github.com/seba-wetzel/ecomunidad/blob/main/tailwind.config.ts"
    click E "https://github.com/seba-wetzel/ecomunidad/tree/main/src/app/api"
    click F "https://github.com/seba-wetzel/ecomunidad/tree/main/src/modules/Cliente/Aplication"
    click G "https://github.com/seba-wetzel/ecomunidad/tree/main/src/modules/Cliente/Domain"
    click H "https://github.com/seba-wetzel/ecomunidad/tree/main/src/modules/Cliente/Infrastructure"
    click I "https://github.com/seba-wetzel/ecomunidad/tree/main/src/modules/shared/adapters"
    click J "https://github.com/seba-wetzel/ecomunidad/tree/main/src/modules/shared/database"
    click K "https://github.com/seba-wetzel/ecomunidad/tree/main/src/lib/google"

    %% Styles
    classDef browser fill:#B0BEC5,stroke:#333,stroke-width:2px;
    classDef frontend fill:#D0E6A5,stroke:#333,stroke-width:2px;
    classDef ui fill:#F9844A,stroke:#333,stroke-width:2px;
    classDef api fill:#F6D186,stroke:#333,stroke-width:2px;
    classDef domain fill:#F9C74F,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#90BE6D,stroke:#333,stroke-width:2px;
    classDef db fill:#577590,stroke:#333,stroke-width:2px;
    classDef external fill:#F94144,stroke:#333,stroke-width:2px;
```
