# markogalarza/dsm-clase-hexagonal--2026 architecture

> Architecture diagram of the GitHub repository markogalarza/dsm-clase-hexagonal--2026, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/markogalarza/dsm-clase-hexagonal--2026
- Repository: https://github.com/markogalarza/dsm-clase-hexagonal--2026

## Overview

##### Project type & purpose (from tree + README)
This is a **client-side React + TypeScript application built with Vite**. There’s no explicit backend service in the repo; instead, persistence is abstracted behind a **Repository pattern** with at least two concrete implementations:
- **FirebaseRepository** (external cloud backend)
- **LocalStorageRepository** (in-browser persistence)

The domain appears centered on a “Product” feature with a clean separation into:
- `domain/` (entities + repository interface)
- `service/` (use-cases / application services)
- `infrastructure/` (data access implementations)
- `view/` (React UI screens)

That suggests a lightweight “clean architecture-ish” / layered feature module inside a SPA.

##### Browser Runtime
- React app (bundled by Vite)
- React rendering + events
##### External Services
- Firebase (DB/Auth/etc. — label only what you actually use)
##### Client-side Storage
- LocalStorage (key/value)

Key technologies to label:
- React, TypeScript
- Vite (build + dev server; clarify it’s build-time, not runtime in prod)

- UI events → React components
- Components → services (function calls)
- Services → repository interface (dependency)
- Repository implementation → Firebase SDK / LocalStorage API

- Vite dev server / bundler
- ESLint config
- tsconfig(s)

This helps distinguish *execution architecture* vs *engineering toolchain*.

**Goal:** This is where you “separate into as many components as possible” based on folders/files.

`src/Product/` as a bounded context/module with 4 internal layers:

##### View layer (`src/Product/view/`)
- `ProductsView.tsx`
- `NewProductView.tsx`
- `EditProductView.tsx`

- UI composition
- User input handling
- Calls application services

- Views → Services (calls)

##### Service layer (`src/Product/service/`)
- `productsService.tsx` (list/fetch use-case)
- `newProductService.tsx` (create use-case)
- `editProductService.tsx` (update use-case)

Responsibilities:
- Orchestrate use-cases
- Validation / mapping (if any)
- Choose repository methods

- Services → Domain repository interface

##### Domain layer (`src/Product/domain/`)
- `Product.tsx` (domain model/entity)
- `ProductRepository.tsx` (interface/port)

Responsibilities:
- Domain types + invariants (if present)
- Contract for persistence

- Domain types used by Services and Repositories
- Repository interface implemented by Infrastructure

##### Infrastructure layer (`src/Product/infrastructure/`)
- `FirebaseRepository.tsx` (adapter)
- `LocalStorageRepository.tsx` (adapter)

Responsibilities:
- Implement `ProductRepository`
- Translate domain objects ↔ storage formats
- Call Firebase SDK or LocalStorage APIs

- `FirebaseRepository` → Firebase service
- `LocalStorageRepository` → Browser LocalStorage
- “Repository wiring” → selects which implementation is used by services (either via import, config, or factory)

##### App composition (`src/main.tsx`, `src/App.tsx`)
Outside the Product module, show:
- `main.tsx` (React bootstrap/root render)
- `App.tsx` (top-level routing/composition)
- `main.tsx` → `App.tsx`
- `App.tsx` → Product Views

##### Relationships & interactions to highlight (data flow)
At least one explicit “happy path” flow annotation, e.g. “Create product”:

##### Concrete repo
- LocalStorageRepository writes to LocalStorage, or
- FirebaseRepository writes to Firebase

##### Architectural patterns/design principles present (and worth diagramming)
- **Layered architecture within a feature module** (`view → service → domain → infrastructure`)
- **Ports & adapters / repository pattern**
- Domain defines `ProductRepository` (port)
- Infrastructure implements it (adapters)
- **Replaceable persistence**

##### System Context: User ↔ SPA ↔ (Firebase, LocalStorage)
3. **Component (Product module):** View/Service/Domain/Infrastructure split with concrete file names as nodes

This approach stays maximally faithful to the repo structure while being detailed enough to capture the essential architectural elements without overthinking it.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Level A — System Context
  %% =========================
  subgraph "Level A — System Context"
    direction TB

    A_User["User (Browser)"]:::external
    A_SPA["Product SPA (React + TypeScript)\nRuns entirely in browser\nPersistence via repository: Firebase or LocalStorage"]:::frontend
    A_Firebase{{"Firebase (External Service)"}}:::external
    A_LocalStorage[("Browser LocalStorage")]:::storage

    A_User -->|"UI_interaction"| A_SPA
    A_SPA <-->|"read/write_products"| A_Firebase
    A_SPA <-->|"read/write_products"| A_LocalStorage
  end

  %% =========================
  %% Level B — Container/Runtime
  %% =========================
  subgraph "Level B — Container / Runtime (what runs where)"
    direction TB

    subgraph "Browser Runtime"
      direction TB
      B_Index["index.html\n(Entry HTML)"]:::frontend
      B_Main["main.tsx\n(React bootstrap)"]:::frontend
      B_App["App.tsx\n(App composition / routing)"]:::frontend
      B_React["React Rendering + Events"]:::frontend
      B_ProductModule["Product Module (Bounded Context)"]:::module
      B_LocalStorage[("LocalStorage API\n(key/value)")]:::storage

      B_Index -->|"loads_bundle"| B_Main
      B_Main -->|"render_root"| B_App
      B_App -->|"compose_views"| B_ProductModule
      B_React -->|"events/update"| B_App
    end

    subgraph "External Services"
      direction TB
      B_Firebase{{"Firebase\n(DB/Auth/etc.)"}}:::external
    end

    subgraph "Build / Dev Tooling (non-runtime)"
      direction TB
      B_Vite["Vite\n(dev server / bundler)"]:::tooling
      B_TS["TypeScript\n(tsconfig*)"]:::tooling
      B_ESLint["ESLint\n(lint rules)"]:::tooling
    end

    B_ProductModule -->|"persistence_via_repo"| B_Firebase
    B_ProductModule -->|"persistence_via_repo"| B_LocalStorage

    B_Vite -.->|"builds"| B_Main
    B_Vite -.->|"builds"| B_App
    B_TS -.->|"typechecks"| B_ProductModule
    B_ESLint -.->|"lints"| B_ProductModule
  end

  %% =========================
  %% Level C — Component/Module (src/Product/*)
  %% =========================
  subgraph "Level C — Component / Module Diagram (src/Product/*)"
    direction TB

    C_Main["main.tsx"]:::frontend
    C_App["App.tsx"]:::frontend

    subgraph "Product Module (src/Product/)"
      direction TB

      subgraph "View Layer (src/Product/view/)"
        direction TB
        C_ProductsView["ProductsView.tsx\n(UI composition + input handling)"]:::view
        C_NewProductView["NewProductView.tsx\n(Form submit + user input)"]:::view
        C_EditProductView["EditProductView.tsx\n(Edit flow + user input)"]:::view
      end

      subgraph "Service Layer (src/Product/service/)"
        direction TB
        C_ProductsService["productsService.tsx\n(list/fetch use-case orchestration)"]:::service
        C_NewProductService["newProductService.tsx\n(create use-case orchestration)"]:::service
        C_EditProductService["editProductService.tsx\n(update use-case orchestration)"]:::service
      end

      subgraph "Domain Layer (src/Product/domain/)"
        direction TB
        C_Product["Product.tsx\n(Domain entity/model)"]:::domain
        C_ProductRepository["ProductRepository.tsx\n(Repository interface / Port)"]:::domain
      end

      subgraph "Infrastructure Layer (src/Product/infrastructure/)"
        direction TB
        C_RepoWiring["Repository.tsx\n(Repository wiring / selection)"]:::infra
        C_FirebaseRepo["FirebaseRepository.tsx\n(Adapter implements ProductRepository)"]:::infra
        C_LocalStorageRepo["LocalStorageRepository.tsx\n(Adapter implements ProductRepository)"]:::infra
      end
    end

    %% Composition
    C_Main -->|"render_root"| C_App
    C_App -->|"renders"| C_ProductsView
    C_App -->|"renders"| C_NewProductView
    C_App -->|"renders"| C_EditProductView

    %% View -> Service calls
    C_ProductsView -->|"listProducts()"| C_ProductsService
    C_NewProductView -->|"createProduct(product)"| C_NewProductService
    C_EditProductView -->|"updateProduct(product)"| C_EditProductService

    %% Service -> Domain port dependency
    C_ProductsService -->|"depends_on"| C_ProductRepository
    C_NewProductService -->|"depends_on"| C_ProductRepository
    C_EditProductService -->|"depends_on"| C_ProductRepository

    %% Domain types used across layers
    C_ProductsService -->|"uses_type"| C_Product
    C_NewProductService -->|"uses_type"| C_Product
    C_EditProductService -->|"uses_type"| C_Product
    C_FirebaseRepo -->|"maps_to/from"| C_Product
    C_LocalStorageRepo -->|"maps_to/from"| C_Product

    %% Wiring/selection + implementations
    C_RepoWiring -->|"selects_impl"| C_FirebaseRepo
    C_RepoWiring -->|"selects_impl"| C_LocalStorageRepo
    C_FirebaseRepo -->|"implements"| C_ProductRepository
    C_LocalStorageRepo -->|"implements"| C_ProductRepository

    %% External dependencies
    C_Firebase[(Firebase)]:::external
    C_LS[("Browser LocalStorage")]:::storage
    C_FirebaseRepo -->|"Firebase_SDK_calls"| C_Firebase
    C_LocalStorageRepo -->|"LocalStorage_API_calls"| C_LS

    %% Happy path annotation: Create product (1..6)
    C_UserAction["Happy Path: Create Product\n(1..6)"]:::note
    C_UserAction -->|"1_submit_form"| C_NewProductView
    C_NewProductView -->|"2_call"| C_NewProductService
    C_NewProductService -->|"3_use_port"| C_ProductRepository
    C_ProductRepository -->|"4_concrete_repo"| C_RepoWiring
    C_RepoWiring -->|"4a_write"| C_LocalStorageRepo
    C_RepoWiring -->|"4b_write"| C_FirebaseRepo
    C_LocalStorageRepo -->|"5_persist"| C_LS
    C_FirebaseRepo -->|"5_persist"| C_Firebase
    C_NewProductService -->|"6_return_updated_state"| C_NewProductView
  end

  %% =========================
  %% Click Events (from component_mapping)
  %% =========================
  click B_Index "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/index.html"
  click B_Main "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/main.tsx"
  click B_App "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/App.tsx"
  click B_ProductModule "https://github.com/markogalarza/dsm-clase-hexagonal--2026/tree/master/src/Product/"

  click C_Main "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/main.tsx"
  click C_App "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/App.tsx"

  click C_ProductsView "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/view/ProductsView.tsx"
  click C_NewProductView "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/view/NewProductView.tsx"
  click C_EditProductView "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/view/EditProductView.tsx"

  click C_ProductsService "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/service/productsService.tsx"
  click C_NewProductService "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/service/newProductService.tsx"
  click C_EditProductService "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/service/editProductService.tsx"

  click C_Product "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/domain/Product.tsx"
  click C_ProductRepository "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/domain/ProductRepository.tsx"

  click C_FirebaseRepo "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/infrastructure/FirebaseRepository.tsx"
  click C_LocalStorageRepo "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/infrastructure/LocalStorageRepository.tsx"
  click C_RepoWiring "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/src/Product/infrastructure/Repository.tsx"

  click B_Vite "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/vite.config.ts"
  click B_TS "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/tsconfig.json"
  click B_ESLint "https://github.com/markogalarza/dsm-clase-hexagonal--2026/blob/master/eslint.config.js"

  %% =========================
  %% Styles (color coding)
  %% =========================
  classDef frontend fill:#D6ECFF,stroke:#1E5AA8,stroke-width:1.5px,color:#0B2545
  classDef module fill:#E7F3FF,stroke:#2B6CB0,stroke-width:1.5px,color:#0B2545
  classDef view fill:#FFE0F0,stroke:#B83280,stroke-width:1.5px,color:#3B0A2A
  classDef service fill:#E6FFFA,stroke:#2C7A7B,stroke-width:1.5px,color:#0B3B3A
  classDef domain fill:#F0FFF4,stroke:#2F855A,stroke-width:1.5px,color:#0F2F1F
  classDef infra fill:#FFF5E6,stroke:#B7791F,stroke-width:1.5px,color:#3A2504
  classDef external fill:#F2F2F2,stroke:#555,stroke-width:1.5px,color:#111
  classDef storage fill:#EFE7FF,stroke:#6B46C1,stroke-width:1.5px,color:#1A103D
  classDef tooling fill:#FFF7D6,stroke:#B7791F,stroke-width:1.5px,color:#3A2504
  classDef note fill:#FFFFFF,stroke:#999,stroke-width:1px,color:#333,stroke-dasharray: 4 3
```
