# carlosfigueroapicado/stain-the-canvas architecture

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

- Interactive diagram: https://gitdiagram.com/carlosfigueroapicado/stain-the-canvas
- Repository: https://github.com/carlosfigueroapicado/stain-the-canvas

## Overview

1. **Overall shape**
This is a static, multi-page frontend application. The browser loads HTML/CSS/JavaScript directly, and all dynamic data comes from Supabase rather than a custom backend.

2. **Public site surface**
The public-facing entry points are `index.html` and `catalogo.html`. These pages present the artisanal product catalog, product details, and WhatsApp contact actions for customers.

3. **Admin surface**
`admin.html` and `login.html` form the management area. The login page authenticates an admin user, and the admin dashboard exposes create/read/update/delete flows for products plus image upload handling.

4. **Client-side module split**
The JavaScript is organized by responsibility:
- `js/supabase.js` centralizes the Supabase client/config
- `js/auth.js` handles auth state and access control
- `js/login.js` drives the login form
- `js/admin.js` orchestrates admin UI actions
- `js/productos.js` encapsulates product data operations
- `js/catalogo.js` renders the public catalog
- `js/index.js` likely powers the landing page
- `js/dashboard.js` and `js/analytics.js` support admin metrics/summary views

5. **Primary data store**
The main domain table is `productos` in Supabase. The documented fields are `id`, `nombre`, `descripcion`, `precio`, `imagen_url`, and `categoria`, with `created_at` and `updated_at` used as supporting metadata.

6. **Data flow for the catalog**
Public pages read from Supabase, transform product records into UI cards and detail views, and display the stored `imagen_url`. The catalog is therefore a read-only consumer of the product table and public image URLs.

7. **Customer contact flow**
The public product experience includes a WhatsApp button with a prefilled message. That means the browser assembles a contact intent from product context and hands the user off to an external messaging channel, rather than submitting a form to the app itself.

8. **Authentication and access boundary**
Admin access is protected with Supabase Auth. The login flow authenticates the user in the browser, and the protected admin pages rely on client-side auth state plus backend policies to determine whether writes are allowed.

9. **Media storage**
Product images are stored in Supabase Storage in a public bucket named `productos`. The admin flow uploads the file, retrieves a public URL, and saves that URL in `productos.imagen_url` so the same asset can be rendered in the catalog and detail views.

10. **Security and database rules**
`supabase/setup.sql` is the architectural control point for database permissions and row-level security. The README explicitly expects authenticated-only write access, which means the real security boundary lives in Supabase policies rather than in the frontend code.

11. **Presentation layer**
`css/styles.css` defines the shared visual system across pages. The repo is entirely frontend-rendered, so layout, typography, and responsive behavior are part of the same client bundle rather than a separate UI service.

12. **Infrastructure dependency**
The only external platform dependency is Supabase, which provides three roles in the architecture: authentication, database persistence, and object storage. Everything else is served as static files from the repository.

Main entry points: [`js/admin.js`](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/admin.js) (Admin UI), [`js/productos.js`](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/productos.js) (Products), [`js/catalogo.js`](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/catalogo.js) (Catalog UI), [`js/auth.js`](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/auth.js) (Auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public site"]
  node_index_html["Home<br/>page<br/>[index.html]"]
  node_catalogo_html["Catalog<br/>page<br/>[catalogo.html]"]
end

subgraph group_admin["Admin surface"]
  node_login_html["Login<br/>page<br/>[login.html]"]
  node_admin_html["Admin<br/>page<br/>[admin.html]"]
end

subgraph group_client["Client modules"]
  node_styles_css["Styles<br/>css<br/>[styles.css]"]
  node_supabase_js["Supabase<br/>client config<br/>[supabase.js]"]
  node_auth_js["Auth<br/>access control<br/>[auth.js]"]
  node_login_js["Login UI<br/>form logic<br/>[login.js]"]
  node_admin_js["Admin UI<br/>crud orchestration<br/>[admin.js]"]
  node_productos_js["Products<br/>data access<br/>[productos.js]"]
  node_catalogo_js["Catalog UI<br/>rendering<br/>[catalogo.js]"]
  node_index_js["Landing UI<br/>rendering<br/>[index.js]"]
  node_dashboard_js["Dashboard<br/>metrics ui<br/>[dashboard.js]"]
  node_analytics_js["Analytics<br/>metrics logic<br/>[analytics.js]"]
end

subgraph group_platform["Supabase platform"]
  node_supabase_setup["Policy SQL<br/>database setup<br/>[setup.sql]"]
  node_supabase_auth(("Auth<br/>managed service"))
  node_supabase_db[("Database<br/>managed service")]
  node_supabase_storage[("Storage<br/>managed service")]
  node_whatsapp(("WhatsApp<br/>external channel"))
end

node_index_html -->|"loads"| node_index_js
node_catalogo_html -->|"loads"| node_catalogo_js
node_login_html -->|"loads"| node_login_js
node_admin_html -->|"loads"| node_admin_js
node_admin_html -->|"shows"| node_dashboard_js
node_index_html -->|"styles"| node_styles_css
node_catalogo_html -->|"styles"| node_styles_css
node_login_html -->|"styles"| node_styles_css
node_admin_html -->|"styles"| node_styles_css
node_login_js -->|"uses"| node_auth_js
node_admin_js -->|"guards"| node_auth_js
node_admin_js -->|"uses"| node_productos_js
node_catalogo_js -->|"reads"| node_productos_js
node_index_js -->|"reads"| node_productos_js
node_dashboard_js -->|"uses"| node_analytics_js
node_productos_js -->|"calls"| node_supabase_js
node_auth_js -->|"calls"| node_supabase_js
node_login_js -->|"authenticates"| node_supabase_auth
node_auth_js -->|"sessions"| node_supabase_auth
node_productos_js -->|"reads/writes"| node_supabase_db
node_supabase_setup -->|"configures"| node_supabase_db
node_admin_js -->|"uploads"| node_supabase_storage
node_catalogo_js -->|"renders"| node_supabase_storage
node_catalogo_js -->|"handoff"| node_whatsapp
node_admin_js -->|"writes"| node_supabase_db

click node_index_html "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/index.html"
click node_catalogo_html "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/catalogo.html"
click node_login_html "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/login.html"
click node_admin_html "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/admin.html"
click node_styles_css "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/css/styles.css"
click node_supabase_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/supabase.js"
click node_auth_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/auth.js"
click node_login_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/login.js"
click node_admin_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/admin.js"
click node_productos_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/productos.js"
click node_catalogo_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/catalogo.js"
click node_index_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/index.js"
click node_dashboard_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/dashboard.js"
click node_analytics_js "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/analytics.js"
click node_supabase_setup "https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/supabase/setup.sql"

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_index_html,node_catalogo_html toneBlue
class node_login_html,node_admin_html toneAmber
class node_styles_css,node_supabase_js,node_auth_js,node_login_js,node_admin_js,node_productos_js,node_catalogo_js,node_index_js,node_dashboard_js,node_analytics_js toneMint
class node_supabase_setup,node_supabase_auth,node_supabase_db,node_supabase_storage,node_whatsapp toneRose
```

## Components

### Public site

Customer-facing pages and flows

- [Home](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/index.html): page · Landing page for the public site · `index.html`
- [Catalog](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/catalogo.html): page · Public product catalog and detail page · `catalogo.html`

### Admin surface

Authentication and product management

- [Login](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/login.html): page · Admin sign-in page · `login.html`
- [Admin](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/admin.html): page · Protected management dashboard · `admin.html`

### Client modules

Browser-side JavaScript organization

- [Styles](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/css/styles.css): css · Shared visual system across pages · `css/styles.css`
- [Supabase](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/supabase.js): client config · Centralized Supabase client and configuration · `js/supabase.js`
- [Auth](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/auth.js): access control · Session state and admin access checks · `js/auth.js`
- [Login UI](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/login.js): form logic · Login form behavior and authentication flow · `js/login.js`
- [Admin UI](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/admin.js): crud orchestration · Create, update, delete, and upload actions · `js/admin.js`
- [Products](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/productos.js): data access · Product data operations against Supabase · `js/productos.js`
- [Catalog UI](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/catalogo.js): rendering · Public catalog rendering and product cards · `js/catalogo.js`
- [Landing UI](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/index.js): rendering · Landing page behavior and presentation · `js/index.js`
- [Dashboard](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/dashboard.js): metrics ui · Admin summary and metrics view · `js/dashboard.js`
- [Analytics](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/js/analytics.js): metrics logic · Analytics support for admin summaries · `js/analytics.js`

### Supabase platform

Hosted auth, database, and storage

- [Policy SQL](https://github.com/carlosfigueroapicado/stain-the-canvas/blob/main/supabase/setup.sql): database setup · RLS and permission setup for Supabase · `supabase/setup.sql`
- **Auth**: managed service · Supabase authentication provider
- **Database**: managed service · Supabase persistence for productos and metadata
- **Storage**: managed service · Public image bucket for product assets
- **WhatsApp**: external channel · Out-of-app customer contact destination

## Connections

- Home → Landing UI: loads · Landing page behavior is driven by the home script
- Catalog → Catalog UI: loads · Catalog page uses the catalog renderer
- Login → Login UI: loads · Login page binds the sign-in form logic
- Admin → Admin UI: loads · Admin dashboard is orchestrated by admin UI logic
- Admin → Dashboard: shows · Dashboard/summary content supports the admin surface
- Home → Styles: styles · Shared styles apply to the landing page
- Catalog → Styles: styles · Shared styles apply to the public catalog
- Login → Styles: styles · Shared styles apply to the login page
- Admin → Styles: styles · Shared styles apply to the admin dashboard
- Login UI → Auth: uses · Login flow relies on shared auth state handling
- Admin UI → Auth: guards · Admin actions are gated by auth state
- Admin UI → Products: uses · Admin CRUD is built on product data operations
- Catalog UI → Products: reads · Catalog renders product data from the domain module
- Landing UI → Products: reads · Landing page may surface featured products
- Dashboard → Analytics: uses · Dashboard pulls in analytics support
- Products → Supabase: calls · Product operations use the shared Supabase client
- Auth → Supabase: calls · Auth state and session checks use the shared client
- Login UI → Auth: authenticates · Browser login delegates to Supabase Auth
- Auth → Auth: sessions · Access control depends on Supabase Auth sessions
- Products → Database: reads/writes · Product records live in Supabase database tables
- Policy SQL → Database: configures · SQL establishes database rules and policies
- Admin UI → Storage: uploads · Admin image upload flow targets public storage
- Catalog UI → Storage: renders · Public catalog displays stored image URLs
- Catalog UI → WhatsApp: handoff · Product interactions open a prefilled WhatsApp message
- Admin UI → Database: writes · Admin CRUD persists product changes in the database
