# lorena-murciab/dcolors architecture

> Architecture diagram of the GitHub repository lorena-murciab/dcolors, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lorena-murciab/dcolors
- Repository: https://github.com/lorena-murciab/dcolors

## Overview

Para dibujar un diagrama de sistema claro y preciso para este proyecto (“DColors” en React con Firebase), sigue estos pasos:

##### Identificar el tipo y propósito del proyecto
- Es una aplicación web de catálogo (full-stack ligero) desarrollada con Create-React-App.
- El frontend está construido en React (JavaScript, CSS, Bootstrap), y el backend es un BaaS: Firebase (Auth, Firestore y Storage).
- Su propósito es exponer un inventario de cuadros a usuarios/distribuidores y permitir a un administrador autenticado gestionar ese inventario.

##### Componentes principales
a. Cliente web (React SPA)
- index.html + bundle JS/CSS (public/)
- src/index.js → monta `<App/>`
- Componentes UI: Header, ImageGallery, CategoriesPreview, LatestPaintings, PaintingDetail, EditPaintingModal, AdminPanel, LoginAdmin
- Contexto de autenticación: AuthContext
b. Capa de servicios Firebase
- Firebase Authentication
- Firestore (colección “paintings”, categorías, metadatos)
- Cloud Storage (imágenes de las obras)
c. (Opcional) Hosting
- Firebase Hosting u otro CDN de archivos estáticos

##### Relaciones e interacciones
- El usuario anónimo carga la SPA → React solicita datos a Firestore → renderiza galerías y detalle de pintura
- El usuario usa filtros: React filtra localmente o pide consultas a Firestore
- El administrador inicia sesión (AuthContext → Firebase Auth)
- Una vez autenticado, accede a AdminPanel → operaciones CRUD sobre Firestore y Storage para crear/editar/eliminar pinturas
- El sistema de hosting entrega los archivos estáticos del frontend

##### Patrones y principios
- Single-Page Application (SPA) con separación clara de componentes de presentación y lógica de datos (Context + hooks)
- BaaS para evitar servidor propio (Firebase)
- Principio de responsabilidad única: cada componente de UI tiene su ámbito, el Context gestiona el estado de autenticación

##### Tecnologías clave
- React (CRA)
- Firebase SDK (Auth, Firestore, Storage)
- Bootstrap/CSS para layout
- Font Awesome, Google Fonts

##### Diseño del diagrama
a. Divide el diagrama en capas o áreas visuales:
- Cliente (navegador) – React App
- Servicios externos – Firebase Auth, Firestore, Storage
- Hosting/CDN
b. Utiliza cajas o contenedores con colores distintos:
- Azul para frontend (React)
- Naranja para Firebase (cada servicio como sub-caja)
- Verde para Hosting
c. Flechas direccionales:
- Desde el navegador → Hosting (GET archivo estático)
- React → Firebase Auth (login/logout)
- React → Firestore (read/write de documentos)
- React → Storage (upload/download de imágenes)
d. Etiqueta cada flecha con el tipo de operación (e.g., “GET paintings”, “POST painting”, “Auth.signIn()”).

##### Elementos imprescindibles en el diagrama
- Componentes:
- React SPA (App.js + Componentes)
- AuthContext (gestión sesiones)
- Módulos Firebase (Auth, Firestore, Storage)
- Hosting/CDN
- Relaciones: flechas con dirección y descripción de la petición/respuesta
– Azul: front-end
– Naranja: backend as a service
– Gris-verde: hosting

##### Guía de dibujo paso a paso
1. Dibuja un rectángulo grande: “Cliente / Navegador”
- Dentro, coloca un sub-rectángulo “React App”
- Dibuja dentro iconos o cajas para: Header, ImageGallery, PaintingDetail, AdminPanel, LoginAdmin
- Conecta estos componentes al “AuthContext”
2. A la derecha, dibuja tres cajas apiladas:
– Firebase Authentication
– Firestore Database
– Cloud Storage
3. Sobre el React App, dibuja una nube “Firebase Hosting” (o CDN) apuntando al React App con una flecha “GET index.html + bundle.js”
4. Conecta React App → Firebase Auth (flecha bidireccional)
– Etiqueta: “signInWithEmailAndPassword / onAuthStateChanged”
5. Conecta React App → Firestore
– Etiqueta: “GET /paintings, QUERY /categories; POST/PUT/DELETE /paintings”
6. Conecta React App → Storage
– Etiqueta: “uploadImage(), getDownloadURL()”

Con este diagrama capturarás de forma detallada y visual la arquitectura real de “DColors” con sus componentes React y Firebase, mostrando claramente capas, flujos de datos y responsabilidades.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Cliente / Navegador layer
    subgraph "Cliente / Navegador"
        style Cliente fill:#eef6fe,stroke:#4a90e2
        Browser["Browser"]:::external
        subgraph ReactApp["React App"]
            style ReactApp fill:#d0e6ff,stroke:#4a90e2
            HTML["index.html"]:::frontend
            JSBundle["bundle.js"]:::frontend
            App["App"]:::frontend
            AuthContext["AuthContext"]:::frontend
            Header["Header"]:::frontend
            ImageGallery["ImageGallery"]:::frontend
            CategoriesPreview["CategoriesPreview"]:::frontend
            LatestPaintings["LatestPaintings"]:::frontend
            PaintingDetail["PaintingDetail"]:::frontend
            EditPaintingModal["EditPaintingModal"]:::frontend
            AdminPanel["AdminPanel"]:::frontend
            LoginAdmin["LoginAdmin"]:::frontend
        end
    end

    %% Firebase Services layer
    subgraph "Firebase Services"
        style Firebase fill:#fff5e6,stroke:#e67e22
        Auth["Authentication"]:::firebase
        Firestore["Firestore Database"]:::firebase
        Storage["Cloud Storage"]:::firebase
    end

    %% Hosting layer
    Hosting["Firebase Hosting/CDN"]:::hosting

    %% Connections
    Browser -->|"GET index.html + bundle.js"| Hosting
    Hosting -->|delivers| HTML
    Hosting -->|delivers| JSBundle
    HTML & JSBundle -->|load| App
    App --> AuthContext
    AuthContext <-->|"signInWithEmailAndPassword / onAuthStateChanged"| Auth
    App -->|"GET /paintings, QUERY /categories"| Firestore
    App -->|"POST/PUT/DELETE /paintings"| Firestore
    App -->|"uploadImage(), getDownloadURL()"| Storage

    App --> Header
    App --> ImageGallery
    App --> CategoriesPreview
    App --> LatestPaintings
    App --> PaintingDetail
    App --> EditPaintingModal
    App --> AdminPanel
    App --> LoginAdmin

    %% Click events for component mapping
    click HTML "https://github.com/lorena-murciab/dcolors/blob/master/public/index.html"
    click JSBundle "https://github.com/lorena-murciab/dcolors/blob/master/public/index.html"
    click App "https://github.com/lorena-murciab/dcolors/blob/master/src/App.js"
    click AuthContext "https://github.com/lorena-murciab/dcolors/blob/master/src/components/AuthContext.js"
    click Header "https://github.com/lorena-murciab/dcolors/blob/master/src/components/Header.js"
    click ImageGallery "https://github.com/lorena-murciab/dcolors/blob/master/src/components/ImageGallery.js"
    click CategoriesPreview "https://github.com/lorena-murciab/dcolors/blob/master/src/components/CategoriesPreview.js"
    click LatestPaintings "https://github.com/lorena-murciab/dcolors/blob/master/src/components/LatestPaintings.js"
    click PaintingDetail "https://github.com/lorena-murciab/dcolors/blob/master/src/components/PaintingDetail.js"
    click EditPaintingModal "https://github.com/lorena-murciab/dcolors/blob/master/src/components/EditPaintingModal.js"
    click AdminPanel "https://github.com/lorena-murciab/dcolors/blob/master/src/components/AdminPanel.js"
    click LoginAdmin "https://github.com/lorena-murciab/dcolors/blob/master/src/components/LoginAdmin.js"
    click Browser "https://github.com/lorena-murciab/dcolors/blob/master/src/index.js"
    click Auth "https://github.com/lorena-murciab/dcolors/blob/master/src/firebaseConfig.js"
    click Firestore "https://github.com/lorena-murciab/dcolors/blob/master/src/firebaseConfig.js"
    click Storage "https://github.com/lorena-murciab/dcolors/blob/master/src/firebaseConfig.js"

    %% Styles
    classDef frontend fill:#d0e6ff,stroke:#4a90e2,color:#000
    classDef firebase fill:#fff5e6,stroke:#e67e22,color:#000
    classDef hosting fill:#e8f5e9,stroke:#388e3c,color:#000
    classDef external fill:#f0f0f0,stroke:#999,color:#333,stroke-dasharray: 3 3
```
