# dachugo/polleria-new-project architecture

> Architecture diagram of the GitHub repository dachugo/polleria-new-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dachugo/polleria-new-project
- Repository: https://github.com/dachugo/polleria-new-project

## Overview

##### Project Type & Purpose
- This is a hybrid mobile full-stack application built with Ionic (v8) + Angular (v19) on the frontend, Capacitor for native device access, and Supabase (PostgreSQL + Auth) + Stripe for backend services.
- Purpose: A mobile ordering and management system for a chicken restaurant (“Pollería Arenas”) providing customer-facing UI, secure auth, real-time order tracking, and payment processing.

##### High-Level Architecture Components
a. Mobile App (Ionic/Angular Hybrid)
- UI Layer: Angular “pages” (lazy-loaded modules) and reusable “components”
- Business Logic Layer: Injectable Angular “services” (auth, data, cart, pedidos, stripe, favoritos)
- Native Bridge: Capacitor runtime enabling Android & iOS builds
b. External Backend Services
- Supabase: Authentication (JWT + RLS), PostgreSQL database, storage
- Stripe: Payment gateway API
c. Platform Builds
- Android native project (under /android)
- iOS project (via Capacitor)
- Web/PWA (via Ionic serve / build)

##### Relationships & Data Flows
- User taps UI component → Angular page/component invokes corresponding Service
- Service uses Supabase JS SDK for CRUD on tables (usuarios, productos, carrito, pedidos, favoritos, tarjetas, estados_pedido)
- For payments, StripeService loads Stripe.js, creates payment intents, handles card elements → calls Stripe API
- Responses from Supabase/Stripe propagate back to the Service → UI updates state (via Reactive Forms or Observables)
- Capacitor plugins handle native features (camera for avatars, file system, notifications)

##### Architectural Patterns & Design Principles
- Modular, feature-based structure: each “page” is a lazy-loaded Angular module
- Reusable UI “components” separated into /src/app/components
- Injectable “services” encapsulate API interactions and business rules
- Route guards (AuthGuard) protect private pages
- Reactive programming (RxJS) for state and form management
- RLS (Row Level Security) enforces data isolation on Supabase
- Environment files manage secrets and endpoints

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Pollería Arenas Mobile App (Ionic/Angular)"
        AppModule["AppModule"]:::service

        subgraph "UI Layer"
            HomePage["HomePage"]:::ui
            LoginPage["LoginPage"]:::ui
            RegisterPage["RegisterPage"]:::ui
            CartPage["CartPage"]:::ui
            CartPayPage["CartPayPage"]:::ui
            PayMethodPage["PayMethodPage"]:::ui
            ProductViewPage["ProductViewPage"]:::ui
            ProfilePage["ProfilePage"]:::ui
            FavoritePage["FavoritePage"]:::ui
            PedidoCargandoPage["PedidoCargandoPage"]:::ui
            PedidoEstadoPage["PedidoEstadoPage"]:::ui
            NavbarComponent["NavbarComponent"]:::ui
            HeaderProfileComponent["HeaderProfileComponent"]:::ui
            ProductCardComponent["ProductCardComponent"]:::ui
            SidebarPedidoComponent["SidebarPedidoComponent"]:::ui
        end

        subgraph "Services Layer"
            AuthService["AuthService"]:::service
            DataService["DataService"]:::service
            PedidoService["PedidoService"]:::service
            FavoritosService["FavoritosService"]:::service
            PedidosEstadosService["PedidosEstadosService"]:::service
            StripeService["StripeService"]:::service
            AuthGuard["AuthGuard"]:::service
        end

        subgraph "Native Bridge (Capacitor)"
            CapacitorConfig["capacitor.config.ts"]:::native
            AndroidProject["Android Project"]:::native
            iOSProject["iOS Project"]:::native
        end
    end

    Supabase["Supabase (Auth + Database)"]:::external
    StripeAPI["Stripe API"]:::external

    %% Lazy Loading from AppModule to Pages
    AppModule -->|lazyLoad| HomePage
    AppModule -->|lazyLoad| LoginPage
    AppModule -->|lazyLoad| RegisterPage
    AppModule -->|lazyLoad| CartPage
    AppModule -->|lazyLoad| CartPayPage
    AppModule -->|lazyLoad| PayMethodPage
    AppModule -->|lazyLoad| ProductViewPage
    AppModule -->|lazyLoad| ProfilePage
    AppModule -->|lazyLoad| FavoritePage
    AppModule -->|lazyLoad| PedidoCargandoPage
    AppModule -->|lazyLoad| PedidoEstadoPage

    %% UI to Services
    LoginPage -->|"signIn() →"| AuthService
    RegisterPage -->|"signUp() →"| AuthService
    HomePage -->|"fetchProducts() →"| DataService
    ProductViewPage -->|"getProduct() →"| DataService
    CartPage -->|"getCart() →"| PedidoService
    CartPayPage -->|"getCart() →"| PedidoService
    PayMethodPage -->|"getPaymentMethods() →"| DataService
    ProfilePage -->|"getUser() →"| DataService
    FavoritePage -->|"getFavorites() →"| FavoritosService
    PedidoCargandoPage -->|"trackOrder() →"| PedidosEstadosService
    PedidoEstadoPage -->|"getOrderStatus() →"| PedidosEstadosService
    NavbarComponent -->|"guardedBy"| AuthGuard

    %% Services to External
    AuthService -->|"signIn()/signUp() →"| Supabase
    DataService -->|"CRUD operations →"| Supabase
    PedidoService -->|"manageOrders() →"| Supabase
    FavoritosService -->|"manageFavorites() →"| Supabase
    PedidosEstadosService -->|"fetchStatus() →"| Supabase
    StripeService -->|"createPaymentIntent() →"| StripeAPI

    %% Capacitor Bridge
    CapacitorConfig -.-> AndroidProject
    CapacitorConfig -.-> iOSProject

    %% Click Events
    click AppModule "https://github.com/dachugo/polleria-new-project/blob/main/src/app/app.module.ts"
    click HomePage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/home/home.module.ts"
    click LoginPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/login/login.module.ts"
    click RegisterPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/register/register.module.ts"
    click CartPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/cart/cart.module.ts"
    click CartPayPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/cart-pay/cart-pay.module.ts"
    click PayMethodPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/pay-method/pay-method.module.ts"
    click ProductViewPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/product-view/product-view.module.ts"
    click ProfilePage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/profile/profile.module.ts"
    click FavoritePage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pages/favorite/favorite.module.ts"
    click PedidoCargandoPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pedido-cargando/pedido-cargando.module.ts"
    click PedidoEstadoPage "https://github.com/dachugo/polleria-new-project/blob/main/src/app/pedido-estado/pedido-estado.module.ts"
    click NavbarComponent "https://github.com/dachugo/polleria-new-project/blob/main/src/app/components/navbar/navbar.component.ts"
    click HeaderProfileComponent "https://github.com/dachugo/polleria-new-project/blob/main/src/app/components/header-profile/header-profile.component.ts"
    click ProductCardComponent "https://github.com/dachugo/polleria-new-project/blob/main/src/app/components/product-card/product-card.component.ts"
    click SidebarPedidoComponent "https://github.com/dachugo/polleria-new-project/blob/main/src/app/components/sidebar-pedido/sidebar-pedido.component.ts"
    click AuthService "https://github.com/dachugo/polleria-new-project/blob/main/src/app/services/auth.service.ts"
    click DataService "https://github.com/dachugo/polleria-new-project/blob/main/src/app/services/data.service.ts"
    click PedidoService "https://github.com/dachugo/polleria-new-project/blob/main/src/app/services/pedido.service.ts"
    click FavoritosService "https://github.com/dachugo/polleria-new-project/blob/main/src/app/services/favoritos.service.ts"
    click PedidosEstadosService "https://github.com/dachugo/polleria-new-project/blob/main/src/app/services/pedidos-estados.service.ts"
    click StripeService "https://github.com/dachugo/polleria-new-project/blob/main/src/app/services/stripe.service.ts"
    click AuthGuard "https://github.com/dachugo/polleria-new-project/blob/main/src/app/guards/auth.guard.ts"
    click CapacitorConfig "https://github.com/dachugo/polleria-new-project/blob/main/capacitor.config.ts"
    click AndroidProject "https://github.com/dachugo/polleria-new-project/tree/main/android/"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef native fill:#F0E68C,stroke:#333,stroke-width:1px
```
