# rafaelhgreco/rafael-app architecture

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

- Interactive diagram: https://gitdiagram.com/rafaelhgreco/rafael-app
- Repository: https://github.com/rafaelhgreco/rafael-app

## Overview

##### Project type and purpose
- This is a front-end single-page application (SPA) built with React, TypeScript, and Vite.
- It follows a layered (“Clean Architecture” / hexagonal) style: a UI/Presentation layer, an Application layer, a Domain layer, and an Infrastructure layer.
- Its goal is to fetch and display users via an HTTP API (mocked in development by Mock Service Worker).

##### File structure
- src/pages, src/components, src/hooks: Presentation/UI layer
- src/application/controller, src/application/services: Application layer
- src/domain: Domain layer (core business models/entities)
- src/infrastructure/api_client.ts, src/infrastructure/repositories, src/infrastructure/stores: Infrastructure layer (API adapter, data persistence, state management)
- src/mocks: mock API endpoint configuration for local development
- Root files (vite.config.ts, tsconfig*, eslint.config.js, Storybook) support build, linting, and component development/testing.

##### README
- Confirms minimal React+TS+Vite template with HMR, ESLint, optional SWC plugin.

## Diagram (Mermaid)

```mermaid
graph TB
  %% Presentation Layer
  subgraph "Presentation Layer"
    direction TB
    AboutPage["About Page"]:::ui
    UserList["User List Component"]:::ui
    UserCard["User Card Component"]:::ui
    Button["Button Atom"]:::ui
    Card["Card Atom"]:::ui
    Header["Header Molecule"]:::ui
    UseUsers["useUsers Hook"]:::ui
  end

  %% Application Layer
  subgraph "Application Layer"
    direction TB
    UserController["User Controller"]:::app
    UserService["User Service"]:::app
  end

  %% Domain Layer
  subgraph "Domain Layer"
    direction TB
    UserEntity["User Entity"]:::domain
  end

  %% Infrastructure Layer
  subgraph "Infrastructure Layer"
    direction TB
    UserRepository["User Repository"]:::infra
    APIClient["API Client"]:::infra
    StoreHook["Store Hook"]:::infra
  end

  %% External Systems
  subgraph "External / Mock"
    direction TB
    MockServiceWorker["Mock Service Worker"]:::external
    BrowserSetup["MSW Browser Setup"]:::external
    MSWHandlers["MSW Request Handlers"]:::external
    ExternalAPI["External HTTP API"]:::external
  end

  %% Tooling & Config
  subgraph "Tooling & Config"
    direction TB
    Vite["Vite Dev/Build"]:::tool
    ESLint["ESLint Config"]:::tool
    Storybook["Storybook"]:::tool
    Vitest["Vitest Setup"]:::tool
    TSConfig["TypeScript Configs"]:::tool
  end

  %% Data Flow
  AboutPage -->|uses| UseUsers
  UserList -->|uses| UseUsers
  UserCard -->|uses| UseUsers
  Button -->|renders| UserCard
  Card -->|contains| UserCard
  Header -->|displays| UserList

  UseUsers -->|calls| UserController
  UserController -->|invokes| UserService
  UserService -->|fetches| UserRepository
  UserService -->|updates| StoreHook
  UserRepository -->|requests| APIClient
  APIClient -->|HTTP| MockServiceWorker
  APIClient -->|HTTP| ExternalAPI

  BrowserSetup -->|registers| MockServiceWorker
  MSWHandlers -->|handles| MockServiceWorker

  %% Click Events
  click AboutPage "https://github.com/rafaelhgreco/rafael-app/blob/main/src/pages/about.tsx"
  click UserList "https://github.com/rafaelhgreco/rafael-app/blob/main/src/components/user_list.tsx"
  click UserCard "https://github.com/rafaelhgreco/rafael-app/blob/main/src/components/user_card.tsx"
  click Button "https://github.com/rafaelhgreco/rafael-app/blob/main/src/components/atoms/button/button.tsx"
  click Card "https://github.com/rafaelhgreco/rafael-app/blob/main/src/components/atoms/card.tsx"
  click Header "https://github.com/rafaelhgreco/rafael-app/blob/main/src/components/molecules/header.tsx"
  click UseUsers "https://github.com/rafaelhgreco/rafael-app/blob/main/src/hooks/use_users.ts"
  click UserController "https://github.com/rafaelhgreco/rafael-app/blob/main/src/application/controller/user_controller.ts"
  click UserService "https://github.com/rafaelhgreco/rafael-app/blob/main/src/application/services/user_service.ts"
  click UserEntity "https://github.com/rafaelhgreco/rafael-app/blob/main/src/domain/user.ts"
  click APIClient "https://github.com/rafaelhgreco/rafael-app/blob/main/src/infrastructure/api_client.ts"
  click UserRepository "https://github.com/rafaelhgreco/rafael-app/blob/main/src/infrastructure/repositories/user_repository.ts"
  click StoreHook "https://github.com/rafaelhgreco/rafael-app/blob/main/src/infrastructure/stores/use_store.ts"
  click MockServiceWorker "https://github.com/rafaelhgreco/rafael-app/blob/main/public/mockServiceWorker.js"
  click BrowserSetup "https://github.com/rafaelhgreco/rafael-app/blob/main/src/mocks/browser.ts"
  click MSWHandlers "https://github.com/rafaelhgreco/rafael-app/blob/main/src/mocks/handlers.ts"
  click Vite "https://github.com/rafaelhgreco/rafael-app/blob/main/vite.config.ts"
  click ESLint "https://github.com/rafaelhgreco/rafael-app/blob/main/eslint.config.js"
  click Storybook "https://github.com/rafaelhgreco/rafael-app/blob/main/.storybook/main.ts"
  click Vitest "https://github.com/rafaelhgreco/rafael-app/blob/main/vitest.workspace.ts"
  click TSConfig "https://github.com/rafaelhgreco/rafael-app/blob/main/tsconfig.json"

  %% Styles
  classDef ui fill:#D0E8FF,stroke:#0366D6,stroke-width:1px
  classDef app fill:#DFFFD6,stroke:#28A745,stroke-width:1px
  classDef domain fill:#FFF5B1,stroke:#D29922,stroke-width:1px
  classDef infra fill:#FFE4C4,stroke:#D2691E,stroke-width:1px
  classDef external fill:#F0F0F0,stroke:#6A737D,stroke-width:1px,stroke-dasharray: 5 5
  classDef tool fill:#EDEDED,stroke:#888888,stroke-width:1px,stroke-dasharray: 2 2
```
