# ssaavedraa/pg-henry architecture

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

- Interactive diagram: https://gitdiagram.com/ssaavedraa/pg-henry
- Repository: https://github.com/ssaavedraa/pg-henry

## Overview

##### Project type and purpose
- This is a full-stack art E-Commerce platform (“SantArt”) composed of:
- A web client built in React (Frontend/art-gallery)
- A mobile client built with Expo/React Native (Api/SantiArtApp)
- A Node.js/Express RESTful API server (Backend)
- A PostgreSQL database accessed via Sequelize ORM
- Integrations with external services (MercadoPago, Google OAuth2, SMTP via NodeMailer)

##### File structure
- Top‐level directories:
- Frontend/art-gallery → React SPA with Redux, React Router, custom hooks, components, auth context
- Api/SantiArtApp → Expo mobile app, React Native components, selectors, views
- Backend → Express server in src, organized by controllers/routes/models/middlewares, plus mockData for seeding
- Architectural patterns:
- MVC‐style backend (routes → controllers → models)
- Layered frontend: components → containers → redux store/actions/reducers
- Mobile app mirrors web features via selectors and views
- Config & deploy:
- .env.sample in Api/SantiArtApp & Backend for secrets
- package.json scripts for starting server, bundling mobile app, building web app
- nodemailer templates & transporter for email workflows
- checkout controllers for MercadoPago webhooks & payment status

##### README for additional insights
- Tech stack: React, Redux, Node.js, PostgreSQL, Sequelize, Passport.js, NodeMailer
- Key features: search autocomplete, JWT & Google OAuth login, checkout with MercadoPago, admin panel

##### Detail
- Backend modules (auth, checkout, cart, nodemailer templates)
- State management in clients (Redux store/actions)
- Secure flows: OAuth login, JWT authentication
- Checkout flow: client → API → MercadoPago → webhook → order status update → notification email

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients"
        Web["React SPA"]:::client
        Mobile["Expo Mobile App"]:::client
    end

    %% Server
    subgraph "Server"
        subgraph "Entry & Config"
            AppEntry["Entry Point (index.js)"]:::server
            AppConfig["App Config (app.js)"]:::server
        end
        subgraph "Layers"
            Routes["API Routes"]:::routes
            Controllers["Controllers"]:::controllers
            Models["Models"]:::models
            Middlewares["Middlewares"]:::middleware
        end
    end

    %% Database
    DB["PostgreSQL\n(Sequelize)"]:::database

    %% External Services
    subgraph "External Services"
        Google["Google OAuth2"]:::external
        MP["MercadoPago"]:::external
        SMTP["SMTP Mail Server"]:::external
    end

    %% Connections
    Web -->|"HTTP/HTTPS"| AppEntry
    Mobile -->|"HTTP/HTTPS"| AppEntry
    AppEntry --> AppConfig
    AppConfig --> Routes
    Routes --> Controllers
    Controllers --> Models
    Models --> DB
    Controllers --> Google
    Controllers --> MP
    Controllers --> SMTP

    %% Click Events
    click Web "https://github.com/ssaavedraa/pg-henry/tree/main/Frontend/art-gallery"
    click Mobile "https://github.com/ssaavedraa/pg-henry/tree/main/Api/SantiArtApp"
    click AppEntry "https://github.com/ssaavedraa/pg-henry/blob/main/Backend/index.js"
    click AppConfig "https://github.com/ssaavedraa/pg-henry/blob/main/Backend/src/app.js"
    click DB "https://github.com/ssaavedraa/pg-henry/blob/main/Backend/src/db.js"
    click Routes "https://github.com/ssaavedraa/pg-henry/tree/main/Backend/src/routes"
    click Controllers "https://github.com/ssaavedraa/pg-henry/tree/main/Backend/src/controllers"
    click Models "https://github.com/ssaavedraa/pg-henry/tree/main/Backend/src/models"
    click Middlewares "https://github.com/ssaavedraa/pg-henry/tree/main/Backend/src/middlewares"
    click Google "https://github.com/ssaavedraa/pg-henry/blob/main/Backend/src/controllers/auth/googleAuth.js"
    click MP "https://github.com/ssaavedraa/pg-henry/blob/main/Backend/src/controllers/checkout/createPreference.js"
    click SMTP "https://github.com/ssaavedraa/pg-henry/tree/main/Backend/src/nodemailer"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef routes fill:#98FB98,stroke:#000,stroke-width:1px;
    classDef controllers fill:#8FBC8F,stroke:#000,stroke-width:1px;
    classDef models fill:#66CDAA,stroke:#000,stroke-width:1px;
    classDef middleware fill:#3CB371,stroke:#000,stroke-width:1px;
    classDef database fill:#2E8B57,stroke:#000,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
