# disaa0/eddys-tender-app architecture

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

- Interactive diagram: https://gitdiagram.com/disaa0/eddys-tender-app
- Repository: https://github.com/disaa0/eddys-tender-app

## Overview

##### Project Type and Purpose
- This is a full-stack mobile e-commerce application (“Eddy’s Tender App”) built with a React Native/Expo frontend, an ExpressJS/Prisma backend, and a MySQL database. It processes user actions (browse, cart, checkout), integrates with Stripe for payments, and uses Expo Push Notifications.

##### File Structure
- Top-level:
- frontend/ – React Native app (Expo) with pages under app/(app), app/(auth), app/(appAdmin), API service wrappers, context providers, hooks, components, assets.
- backend/ – Express API server with src/{config,controllers,middlewares,services,routes}, Prisma ORM schema & migrations, Dockerfile, docs for API/Stripe/notifications.
- mysql/ – Initialization SQL scripts & permission setup.
- docker-compose.yml – brings up backend, mysql, stripe-cli, (and possibly frontend if containerized).
- docs/ – high-level project reports.

##### README for Additional Insights
- Stack: ExpressJS + Prisma, MySQL, React Native/Expo
- Containerization: Docker Compose coordinates backend, MySQL, stripe-cli
- External services: Stripe API for payments, Expo push for notifications
- Architecture hints: clearly separated frontend/backend, API endpoints under /api, Prisma service layer.

##### Detailed Component Breakdown (to include
- Frontend:
- Pages: auth, user app, admin app
- State management: AuthContext, CartRefreshContext
- API clients: BaseApiService, AuthService, AdminApiService, etc.
- Backend:
- Config modules (bcrypt, JWT, crypto)
- Middlewares (auth, admin check, upload, input validation)
- Controllers grouped by domain (auth, cart, order, product, webhook, notification)
- Services mapping to controllers
- Prisma client module
- Database:
- Schema (User, Product, Order, Cart, Notification, ShippingAddress)
- Migration history
- Payments & Notifications:
- Stripe API (payment_intent) integration and webhook flow
- stripe-cli local listener
- Expo Push Notification flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React Native/Expo)" 
        style Frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:2px
        MobileApp["Mobile App UI Layer"]:::frontend
        PagesUser["User Pages (browse, cart, checkout, profile, orders)"]:::frontend
        PagesAuth["Auth Pages (login, register)"]:::frontend
        PagesAdmin["Admin Dashboard Pages"]:::frontend
        ApiClients["API Client Services"]:::frontend
        Contexts["State Management Contexts"]:::frontend
        Hooks["Custom Hooks"]:::frontend
        Components["UI Components"]:::frontend
        NotificationHandler["Notification Handler"]:::frontend
        Assets["Static Assets"]:::frontend
    end

    MobileApp -->|uses| PagesUser
    MobileApp -->|uses| PagesAuth
    MobileApp -->|uses| PagesAdmin
    PagesUser -->|calls| ApiClients
    PagesAuth -->|calls| ApiClients
    PagesAdmin -->|calls| ApiClients
    ApiClients -->|updates| Contexts
    Contexts -->|provides state to| PagesUser
    PagesUser -->|renders| Components
    Hooks -->|fetch data for| PagesUser
    NotificationHandler -->|listens & displays| MobileApp

    %% Backend Layer
    subgraph "Backend (ExpressJS API)" 
        style Backend fill:#c8e6c9,stroke:#388e3c,stroke-width:2px
        APIApp["Express API Entry Point"]:::backend
        Routes["API Route Definitions"]:::backend
        Controllers["Controllers"]:::backend
        Services["Services"]:::backend
        PrismaClient["Prisma Client Module"]:::backend
        Configs["Config Modules"]:::backend
        Middlewares["Middlewares"]:::backend
    end

    MobileApp -->|HTTPS REST| APIApp
    APIApp -->|loads| Routes
    Routes -->|invoke| Controllers
    Controllers -->|call| Services
    Services -->|use| PrismaClient
    Services -->|use| Configs
    Controllers -->|pass through| Middlewares

    %% Data Layer
    subgraph "Database (MySQL)" 
        style Database fill:#e0e0e0,stroke:#757575,stroke-width:2px
        MySQL["MySQL Database"]:::infra
        Schema["DB Schema & Migrations"]:::infra
    end

    PrismaClient -->|queries| MySQL
    Schema -->|defines| MySQL

    %% External Services
    subgraph "External Services"
        style External fill:#ffe082,stroke:#f57f17,stroke-width:2px
        StripeAPI["Stripe API"]:::external
        ExpoPush["Expo Push Notification API"]:::external
    end

    Services -->|create charges| StripeAPI
    StripeAPI -->|webhook events| StripeCLI
    Services -->|send notifications| ExpoPush
    ExpoPush -->|push notifications| MobileApp

    %% Infrastructure
    subgraph "Infrastructure"
        style Infra fill:#e0e0e0,stroke:#424242,stroke-width:2px
        DockerCompose["Docker Compose"]:::infra
        StripeCLI["stripe-cli Webhook Listener"]:::infra
        MySQLInit["MySQL Init Scripts"]:::infra
    end

    DockerCompose -->|orchestrates| APIApp
    DockerCompose -->|orchestrates| MySQL
    DockerCompose -->|orchestrates| StripeCLI
    MySQLInit -->|initializes| MySQL

    StripeCLI -->|forwards to| Routes

    %% Click Events Frontend
    click MobileApp "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/app"
    click PagesUser "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/app/(app)"
    click PagesAuth "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/app/(auth)"
    click PagesAdmin "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/app/(appAdmin)"
    click ApiClients "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/api/BaseApiService.js"
    click ApiClients "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/api/AuthService.js"
    click ApiClients "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/api/AdminApiService.js"
    click ApiClients "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/api/NotificationApiService.js"
    click ApiClients "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/api/UserService.js"
    click Contexts "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/context/AuthContext.js"
    click Contexts "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/app/context/CartRefreshContext.js"
    click Hooks "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/app/hooks"
    click Components "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/app/components"
    click NotificationHandler "https://github.com/disaa0/eddys-tender-app/blob/main/frontend/components/NotificationHandler.js"
    click Assets "https://github.com/disaa0/eddys-tender-app/tree/main/frontend/assets"

    %% Click Events Backend
    click APIApp "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/app.js"
    click Routes "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/routes/auth.routes.js"
    click Routes "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/routes/cart.routes.js"
    click Routes "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/routes/order.routes.js"
    click Routes "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/routes/product.routes.js"
    click Routes "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/routes/webhook.routes.js"
    click Routes "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/routes/notification.routes.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/auth.controller.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/cart.controller.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/order.controller.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/product.controller.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/webhook.controller.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/notification.controller.js"
    click Controllers "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/controllers/admin.controller.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/auth.service.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/cart.service.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/order.service.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/payment.service.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/notification.service.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/product.service.js"
    click Services "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/services/admin.service.js"
    click PrismaClient "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/lib/prisma.js"
    click Schema "https://github.com/disaa0/eddys-tender-app/blob/main/backend/prisma/schema.prisma"
    click Configs "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/config/jwt.config.js"
    click Configs "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/config/bcrypt.config.js"
    click Configs "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/config/crypto.config.js"
    click Middlewares "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/middlewares/auth.middleware.js"
    click Middlewares "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/middlewares/admin.middleware.js"
    click Middlewares "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/middlewares/upload.middleware.js"
    click Middlewares "https://github.com/disaa0/eddys-tender-app/blob/main/backend/src/middlewares/validateInput.js"

    %% Click Events Infra & Docs
    click DockerCompose "https://github.com/disaa0/eddys-tender-app/blob/main/docker-compose.yml"
    click StripeCLI "https://github.com/disaa0/eddys-tender-app/blob/main/backend/docker-entrypoint.sh"
    click MySQLInit "https://github.com/disaa0/eddys-tender-app/blob/main/mysql/init/01-permissions.sql"
    click Schema "https://github.com/disaa0/eddys-tender-app/tree/main/backend/prisma/migrations"
    click Docs1 "https://github.com/disaa0/eddys-tender-app/blob/main/backend/docs/STRIPE.md"
    click Docs2 "https://github.com/disaa0/eddys-tender-app/blob/main/backend/docs/EXPO_NOTIFICATIONS.md"
    click Docs3 "https://github.com/disaa0/eddys-tender-app/blob/main/README.md"
    click Docs4 "https://github.com/disaa0/eddys-tender-app/blob/main/docs/INFO.md"
    click Docs5 "https://github.com/disaa0/eddys-tender-app/blob/main/backend/docs/API.md"
    click Docs6 "https://github.com/disaa0/eddys-tender-app/blob/main/docs/BACKEND_REPORT.md"
    click Docs7 "https://github.com/disaa0/eddys-tender-app/blob/main/docs/FRONTEND_REPORT.md"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5
    classDef backend fill:#c8e6c9,stroke:#388e3c
    classDef external fill:#ffe082,stroke:#f57f17
    classDef infra fill:#e0e0e0,stroke:#424242
```
