# rsp-byte/frutos-paraiso architecture

> Architecture diagram of the GitHub repository rsp-byte/frutos-paraiso, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rsp-byte/frutos-paraiso
- Repository: https://github.com/rsp-byte/frutos-paraiso

## Overview

1. This is a React 18 single-page frontend built with Create React App. The repo contains no backend code; all server interaction is via API/repository layers in `src/*/infrastructure` and `src/home/services`.

2. The app is organized by feature area rather than by technical layer alone. The main top-level domains are `home` (storefront), `users` (auth and account actions), `invoices` (billing/history), `admin` (backoffice pages), and a small `products` dashboard area. `shared/ui` holds reusable visual primitives.

3. There are two home-related entry paths: `src/pages/Home.jsx` appears to be a simpler/older home screen, while `src/home/presentation/pages/HomePage.jsx` is the more feature-scoped storefront composition. The README describes the `home` feature as the primary customer-facing experience, assembled from reusable sections.

4. The storefront is component-driven and mostly presentation-heavy. `Navbar`, `Hero`, `ProductsSection`, `ProductGrid`, `Facturacion`, `ChatBot`, and `Footer` make up the page. Product browsing and the purchase modal are split into separate components, so the diagram should show a composed page shell feeding user actions into cart/order state.

5. Application state for shopping flows is centralized through `src/context/StoreContext.jsx` and the `useCart` hook in `src/home/hooks/useCart.js`. This is the main shared state boundary for cart/product selection across home components and billing/order UI.

6. The auth/account subsystem follows a cleaner layered structure. `users/domain/entities/User.js` defines the domain model, `users/application/use-cases/*` contains login/register/change-password use cases, and `users/infrastructure/repositories/ApiUserRepository.js` plus `AuthTokenManager.js` handle API calls and token persistence. `loginRoleUtils.js` suggests role-based branching after login.

7. The invoices subsystem is also layered: `GetInvoicesUseCase.js` calls into `ApiInvoiceRepository.js`, and `InvoicesPage.jsx` renders the result. This indicates a data flow from UI to use case to repository to backend API, then back to a presentation page.

8. The admin area is a set of standalone presentation pages under `src/admin/presentation/pages`, including dashboard, products, reports, accounting, login/register user, password change, and verse management. This implies a backoffice surface with multiple navigable screens rather than one composite page.

9. `src/shared/ui` provides reusable building blocks such as `Button`, `AuthInput`, and `ProductCard`. These are the design-system boundary for both customer and admin flows, keeping form and card styling consistent across features.

10. Styling is mostly per-component CSS, with global defaults in `src/index.css` and page-level styles in files like `home.css` and `admin.css`. This means the UI architecture is tightly coupled to CSS modules/files rather than a CSS-in-JS or utility framework.

11. Static hosting assets live in `public/` and `src/assets/images/`. The README explicitly treats product imagery as imported frontend assets, so product presentation depends on local image bundling rather than a separate media service.

12. The runtime/build boundary is standard CRA: `src/index.js` bootstraps the app, `public/index.html` is the shell, `npm start` runs development, and `npm run build` produces the deployable bundle. Tests are minimal but present via `App.test.js` and CRA’s test harness.

13. For an architecture diagram, the most important arrows are: page/component UI → hooks/context/use-cases → repositories/services → backend API, with shared UI and context/state cutting across `home`, `users`, and `invoices`. The admin pages sit beside, not under, the customer storefront, and the auth/token layer is the cross-cutting boundary that likely controls access to protected screens.

Main entry points: [`src/App.js`](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/App.js) (App), [`src/home/presentation/pages/HomePage.jsx`](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/pages/HomePage.jsx) (Home page), [`src/users/infrastructure/repositories/ApiUserRepository.js`](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/repositories/ApiUserRepository.js) (User repo), [`src/shared/ui`](https://github.com/rsp-byte/frutos-paraiso/tree/master/src/shared/ui) (shared/ui)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_public_index_html["index.html<br/>html shell<br/>[index.html]"]
  node_src_index_js["index.js<br/>bootstrap<br/>[index.js]"]
  node_app_js["App<br/>router shell<br/>[App.js]"]
end

subgraph group_storefront["Storefront"]
  node_home_page["Home page<br/>feature page<br/>[HomePage.jsx]"]
  node_old_home_page["Legacy home<br/>page<br/>[Home.jsx]"]
  node_navbar["Navbar<br/>ui component<br/>[Navbar.jsx]"]
  node_hero["Hero<br/>ui component<br/>[Hero.jsx]"]
  node_products_section["Products<br/>ui component"]
  node_product_grid["Grid<br/>ui component<br/>[ProductGrid.jsx]"]
  node_cart_facturacion["Cart + billing<br/>shopping flow"]
  node_use_cart["useCart<br/>state hook<br/>[useCart.js]"]
  node_store_context["StoreContext<br/>[StoreContext.jsx]"]
  node_home_api["Home API<br/>[api.js]"]
end

subgraph group_auth["Users"]
  node_login_page["Login<br/>auth page<br/>[LoginPage.jsx]"]
  node_signup_page["Sign up<br/>auth page<br/>[SignUpPage.jsx]"]
  node_change_password_page["Change password<br/>auth page"]
  node_login_uc["Login use case<br/>[LoginUseCase.js]"]
  node_register_uc["Register use case<br/>[RegisterUseCase.js]"]
  node_change_password_uc["Password use case"]
  node_user_entity{{"User<br/>domain entity<br/>[User.js]"}}
  node_user_repo["User repo"]
  node_token_manager["Token manager<br/>auth storage"]
  node_login_role_utils["Role utils<br/>auth logic<br/>[loginRoleUtils.js]"]
end

subgraph group_billing["Invoices"]
  node_invoices_page["Invoices<br/>billing page<br/>[InvoicesPage.jsx]"]
  node_get_invoices_uc["Get invoices<br/>use case"]
  node_invoice_repo["Invoice repo"]
end

subgraph group_admin["Admin"]
  node_admin_dashboard["Dashboard<br/>admin page"]
  node_admin_products["Products<br/>admin page"]
  node_admin_ops["Admin ops<br/>admin screens"]
  node_admin_login["Admin login<br/>admin auth<br/>[AdminLoginPage.jsx]"]
end

subgraph group_shared["Shared UI"]
  node_shared_ui["shared/ui<br/>design system"]
end

subgraph group_external["External"]
  node_backend_api[("Backend API<br/>external service")]
end

node_public_index_html -->|"hosts"| node_src_index_js
node_src_index_js -->|"boots"| node_app_js
node_app_js -->|"routes"| node_home_page
node_app_js -->|"routes"| node_login_page
node_app_js -->|"routes"| node_signup_page
node_app_js -->|"routes"| node_change_password_page
node_app_js -->|"routes"| node_invoices_page
node_app_js -->|"routes"| node_admin_dashboard
node_home_page -->|"composes"| node_navbar
node_home_page -->|"composes"| node_hero
node_home_page -->|"composes"| node_products_section
node_products_section -->|"renders"| node_product_grid
node_product_grid -->|"uses"| node_shared_ui
node_home_page -->|"drives"| node_cart_facturacion
node_cart_facturacion -->|"reads"| node_use_cart
node_use_cart -->|"syncs"| node_store_context
node_use_cart -->|"calls"| node_home_api
node_home_api -->|"requests"| node_backend_api
node_login_page -->|"invokes"| node_login_uc
node_signup_page -->|"invokes"| node_register_uc
node_change_password_page -->|"invokes"| node_change_password_uc
node_login_uc -->|"uses"| node_user_repo
node_register_uc -->|"uses"| node_user_repo
node_change_password_uc -->|"uses"| node_user_repo
node_login_uc -->|"validates"| node_user_entity
node_user_repo -->|"persists"| node_token_manager
node_user_repo -->|"requests"| node_backend_api
node_login_uc -->|"branches"| node_login_role_utils
node_login_role_utils -->|"reads"| node_token_manager
node_invoices_page -->|"requests"| node_get_invoices_uc
node_get_invoices_uc -->|"uses"| node_invoice_repo
node_invoice_repo -->|"requests"| node_backend_api
node_admin_dashboard -->|"uses"| node_shared_ui
node_admin_products -->|"uses"| node_shared_ui
node_admin_ops -->|"uses"| node_shared_ui
node_admin_login -->|"authenticates"| node_token_manager
node_shared_ui -.->|"none"| node_backend_api

click node_public_index_html "https://github.com/rsp-byte/frutos-paraiso/blob/master/public/index.html"
click node_src_index_js "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/index.js"
click node_app_js "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/App.js"
click node_home_page "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/pages/HomePage.jsx"
click node_old_home_page "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/pages/Home.jsx"
click node_navbar "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/Navbar.jsx"
click node_hero "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/Hero.jsx"
click node_products_section "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/ProductsSection.jsx"
click node_product_grid "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/ProductGrid.jsx"
click node_use_cart "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/hooks/useCart.js"
click node_store_context "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/context/StoreContext.jsx"
click node_home_api "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/services/api.js"
click node_shared_ui "https://github.com/rsp-byte/frutos-paraiso/tree/master/src/shared/ui"
click node_login_page "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/presentation/pages/LoginPage.jsx"
click node_signup_page "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/presentation/pages/SignUpPage.jsx"
click node_change_password_page "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/presentation/pages/ChangePasswordPage.jsx"
click node_login_uc "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/application/use-cases/LoginUseCase.js"
click node_register_uc "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/application/use-cases/RegisterUseCase.js"
click node_change_password_uc "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/application/use-cases/ChangePasswordUseCase.js"
click node_user_entity "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/domain/entities/User.js"
click node_user_repo "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/repositories/ApiUserRepository.js"
click node_token_manager "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/repositories/AuthTokenManager.js"
click node_login_role_utils "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/loginRoleUtils.js"
click node_invoices_page "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/invoices/presentation/pages/InvoicesPage.jsx"
click node_get_invoices_uc "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/invoices/application/use-cases/GetInvoicesUseCase.js"
click node_invoice_repo "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/invoices/infrastructure/repositories/ApiInvoiceRepository.js"
click node_admin_dashboard "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/admin/presentation/pages/AdminDashboardPage.jsx"
click node_admin_products "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/admin/presentation/pages/AdminProductsPage.jsx"
click node_admin_login "https://github.com/rsp-byte/frutos-paraiso/blob/master/src/admin/presentation/pages/AdminLoginPage.jsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_index_html,node_src_index_js,node_app_js,node_backend_api toneBlue
class node_home_page,node_old_home_page,node_navbar,node_hero,node_products_section,node_product_grid,node_cart_facturacion,node_use_cart,node_store_context,node_home_api toneAmber
class node_login_page,node_signup_page,node_change_password_page,node_login_uc,node_register_uc,node_change_password_uc,node_user_entity,node_user_repo,node_token_manager,node_login_role_utils toneMint
class node_invoices_page,node_get_invoices_uc,node_invoice_repo toneRose
class node_admin_dashboard,node_admin_products,node_admin_ops,node_admin_login toneIndigo
class node_shared_ui toneTeal
```

## Components

### Runtime

CRA bootstrap and application shell

- [index.html](https://github.com/rsp-byte/frutos-paraiso/blob/master/public/index.html): html shell · CRA document shell · `public/index.html`
- [index.js](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/index.js): bootstrap · Bootstraps the React app · `src/index.js`
- [App](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/App.js): router shell · Top-level app composition and navigation · `src/App.js`

### Storefront

Customer-facing home experience and shopping flow

- [Home page](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/pages/HomePage.jsx): feature page · Primary customer storefront composition · `src/home/presentation/pages/HomePage.jsx`
- [Legacy home](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/pages/Home.jsx): page · Simpler older home screen · `src/pages/Home.jsx`
- [Navbar](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/Navbar.jsx): ui component · Top navigation for the storefront · `src/home/presentation/components/Navbar.jsx`
- [Hero](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/Hero.jsx): ui component · Landing banner and entry callouts · `src/home/presentation/components/Hero.jsx`
- [Products](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/ProductsSection.jsx): ui component · Product browsing section · `src/home/presentation/components/ProductsSection.jsx`
- [Grid](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/presentation/components/ProductGrid.jsx): ui component · Renders browsable product cards · `src/home/presentation/components/ProductGrid.jsx`
- **Cart + billing**: shopping flow · Cart state and purchase/order interaction
- [useCart](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/hooks/useCart.js): state hook · Shared cart and product selection logic · `src/home/hooks/useCart.js`
- [StoreContext](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/context/StoreContext.jsx): context · Shared shopping state boundary · `src/context/StoreContext.jsx`
- [Home API](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/home/services/api.js): service · Frontend API access for home features · `src/home/services/api.js`

### Users

Authentication and account management

- [Login](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/presentation/pages/LoginPage.jsx): auth page · User sign-in screen · `src/users/presentation/pages/LoginPage.jsx`
- [Sign up](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/presentation/pages/SignUpPage.jsx): auth page · User registration screen · `src/users/presentation/pages/SignUpPage.jsx`
- [Change password](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/presentation/pages/ChangePasswordPage.jsx): auth page · Password update screen · `src/users/presentation/pages/ChangePasswordPage.jsx`
- [Login use case](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/application/use-cases/LoginUseCase.js): use case · Authentication workflow · `src/users/application/use-cases/LoginUseCase.js`
- [Register use case](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/application/use-cases/RegisterUseCase.js): use case · Account creation workflow · `src/users/application/use-cases/RegisterUseCase.js`
- [Password use case](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/application/use-cases/ChangePasswordUseCase.js): use case · Password change workflow · `src/users/application/use-cases/ChangePasswordUseCase.js`
- [User](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/domain/entities/User.js): domain entity · Core user model · `src/users/domain/entities/User.js`
- [User repo](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/repositories/ApiUserRepository.js): repository · API-backed user repository · `src/users/infrastructure/repositories/ApiUserRepository.js`
- [Token manager](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/repositories/AuthTokenManager.js): auth storage · Persists and reads auth tokens · `src/users/infrastructure/repositories/AuthTokenManager.js`
- [Role utils](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/users/infrastructure/loginRoleUtils.js): auth logic · Role-based branching after login · `src/users/infrastructure/loginRoleUtils.js`

### Invoices

Invoice history and retrieval

- [Invoices](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/invoices/presentation/pages/InvoicesPage.jsx): billing page · Invoice history screen · `src/invoices/presentation/pages/InvoicesPage.jsx`
- [Get invoices](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/invoices/application/use-cases/GetInvoicesUseCase.js): use case · Fetches invoice history · `src/invoices/application/use-cases/GetInvoicesUseCase.js`
- [Invoice repo](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/invoices/infrastructure/repositories/ApiInvoiceRepository.js): repository · API-backed invoice repository · `src/invoices/infrastructure/repositories/ApiInvoiceRepository.js`

### Admin

Backoffice presentation screens

- [Dashboard](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/admin/presentation/pages/AdminDashboardPage.jsx): admin page · Backoffice overview screen · `src/admin/presentation/pages/AdminDashboardPage.jsx`
- [Products](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/admin/presentation/pages/AdminProductsPage.jsx): admin page · Backoffice product management · `src/admin/presentation/pages/AdminProductsPage.jsx`
- **Admin ops**: admin screens · Accounting, reports, user access, and verse management
- [Admin login](https://github.com/rsp-byte/frutos-paraiso/blob/master/src/admin/presentation/pages/AdminLoginPage.jsx): admin auth · Backoffice sign-in screen · `src/admin/presentation/pages/AdminLoginPage.jsx`

### Shared UI

Reusable visual components

- [shared/ui](https://github.com/rsp-byte/frutos-paraiso/tree/master/src/shared/ui): design system · Reusable buttons, inputs, and cards · `src/shared/ui`

### External

Backend API boundary

- **Backend API**: external service · Remote server endpoints consumed by repositories and services

## Connections

- index.html → index.js: hosts · HTML shell loads the React bundle
- index.js → App: boots · Application entry initializes the app shell
- App → Home page: routes · Top-level routing reaches the storefront
- App → Login: routes · Top-level routing reaches auth screens
- App → Sign up: routes · Top-level routing reaches registration
- App → Change password: routes · Top-level routing reaches password change
- App → Invoices: routes · Top-level routing reaches billing history
- App → Dashboard: routes · Top-level routing reaches backoffice area
- Home page → Navbar: composes · Storefront page assembles navigation
- Home page → Hero: composes · Storefront page assembles hero section
- Home page → Products: composes · Storefront page assembles product browsing
- Products → Grid: renders · Section delegates product listing to the grid
- Grid → shared/ui: uses · Product cards and controls use shared primitives
- Home page → Cart + billing: drives · Page feeds selection into cart and billing actions
- Cart + billing → useCart: reads · Cart flow uses shared cart hook
- useCart → StoreContext: syncs · Cart hook centralizes state through context
- useCart → Home API: calls · Cart and browsing logic can reach frontend API services
- Home API → Backend API: requests · Frontend service sends API traffic outward
- Login → Login use case: invokes · Login form triggers authentication workflow
- Sign up → Register use case: invokes · Registration form triggers account creation
- Change password → Password use case: invokes · Password screen triggers password update workflow
- Login use case → User repo: uses · Use case delegates to repository
- Register use case → User repo: uses · Use case delegates to repository
- Password use case → User repo: uses · Use case delegates to repository
- Login use case → User: validates · Authentication workflow centers on the user model
- User repo → Token manager: persists · Repository coordinates token storage
- User repo → Backend API: requests · User repository calls the backend API
- Login use case → Role utils: branches · Login flow applies role-based routing
- Role utils → Token manager: reads · Role logic depends on persisted auth state
- Invoices → Get invoices: requests · Invoices UI asks the use case for data
- Get invoices → Invoice repo: uses · Use case delegates to invoice repository
- Invoice repo → Backend API: requests · Invoice repository calls the backend API
- Dashboard → shared/ui: uses · Backoffice pages reuse shared visual primitives
- Products → shared/ui: uses · Backoffice pages reuse shared visual primitives
- Admin ops → shared/ui: uses · Backoffice pages reuse shared visual primitives
- Admin login → Token manager: authenticates · Admin sign-in relies on shared token persistence
- shared/ui → Backend API: none · No direct data flow; shared UI remains presentation-only
