# darshan98solanki/priti-s-cake architecture

> Architecture diagram of the GitHub repository darshan98solanki/priti-s-cake, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darshan98solanki/priti-s-cake
- Repository: https://github.com/darshan98solanki/priti-s-cake

## Overview

##### Project type and purpose
- This is a full-stack, monorepo-style web application called “Priti-s-Cake” with two React UIs (a public storefront “frontend” and an admin portal “admin”), a shared “common” library, and an Express/TypeScript “backend” serving a REST API. Its use case is an online cake gallery/store with admin upload/update capabilities.

##### File structure
- Top-level folders:
- admin – React + Vite admin portal (login, upload/update cakes)
- frontend – React + Vite public website (gallery, products, about, services)
- backend – Node/Express API with Prisma ORM, JWT auth, Cloudinary image uploads
- common – shared TypeScript code (types, utilities) consumed by both frontends (and potentially backend)
- Configs: Vite, ESLint, tsconfig for each package; vercel.json in admin/backend; netlify.toml in frontend; prisma/schema.prisma in backend/prisma.

##### README
- Minimal; project name only. All architecture clues come from folder names, package.json dependencies and code.

##### Main components and their interactions
a. Frontend (Customer UI)
- Hosted on Netlify
- React components/pages → calls REST endpoints on backend (/cakes, /gallery, /products)
b. Admin portal
- Hosted on Vercel
- React components/pages → login/auth via JWT → calls protected backend routes (upload/update cake)
c. Backend API
- Express app (index.ts) with middleware (auth, error handlers)
- Prisma ORM → connects to relational database (Postgres/MySQL)
- Multer-Cloudinary storage for image uploads → Cloudinary external service
- Issues/validates JWTs for admin sessions
d. Database
- Prisma schema defines Cake, User, etc.
- Actual database hosted separately (cloud provider)
e. External services
- Cloudinary for image hosting
- JWT identity provider (self-hosted via backend)

##### Architectural patterns and design principles
- Monorepo with clear separation of concerns
- Shared code in “common” package (DRY)
- REST API layer in backend (Controller → Service → ORM)
- JWT-based stateless auth
- Client-side routing and state in React UIs
- Infrastructure as code via Vercel/Netlify configs

##### Detail level
- Every distinct module (common library, middleware layer, Prisma, Multer-Cloudinary)
- Do not over-aggregate: show auth middleware, image upload pipeline, shared types as separate sub-components if space allows
- Be precise about protocols (HTTPS, Webhooks if any) and ports (443)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Public Web App
    subgraph "Public Web App (frontend)"
        FE["Public Web App\nReact + Vite + TS"]:::frontend
        NetlifyFE["Netlify"]:::external
    end

    %% Admin Web App
    subgraph "Admin Web App (admin)"
        AdminUI["Admin Web App\nReact + Vite + TS"]:::frontend
        VercelAdmin["Vercel"]:::external
    end

    %% Shared Common Library
    Common["Common Library\nTS Types & Utilities"]:::frontend

    %% Backend API
    subgraph "Backend API"
        BackendService["Backend API\nExpress + TS"]:::backend
        AuthMid["Auth & Error Middleware"]:::backend
        ORM["Prisma ORM"]:::backend
        JWTTypes["JWT Types Definitions"]:::backend
        MulterStorage["Multer-Cloudinary Storage"]:::backend
        ExpressTypes["Express Request Augmentation"]:::backend
        VercelBackend["Vercel"]:::external
        DB[(Database\nPostgres/MySQL)]:::db
    end

    %% External Services
    Cloudinary["Cloudinary\nImage Hosting"]:::external

    %% Connections
    FE -->|"HTTPS REST API"| BackendService
    AdminUI -->|"HTTPS REST API (JWT auth)"| BackendService
    Common -->|shared code| FE
    Common -->|shared code| AdminUI
    Common -->|shared code| BackendService

    BackendService -->|uses| AuthMid
    BackendService -->|connects to| ORM
    ORM -->|models defined in\nPrisma schema| DB
    BackendService -->|uses| MulterStorage
    MulterStorage -->|uploads images to| Cloudinary
    BackendService -->|uses types| JWTTypes
    BackendService -->|uses types| ExpressTypes

    FE --> NetlifyFE
    AdminUI --> VercelAdmin
    BackendService --> VercelBackend

    %% Click Events
    click FE "https://github.com/darshan98solanki/priti-s-cake/tree/main/frontend/"
    click NetlifyFE "https://github.com/darshan98solanki/priti-s-cake/blob/main/frontend/netlify.toml"
    click AdminUI "https://github.com/darshan98solanki/priti-s-cake/tree/main/admin/"
    click VercelAdmin "https://github.com/darshan98solanki/priti-s-cake/blob/main/admin/vercel.json"
    click Common "https://github.com/darshan98solanki/priti-s-cake/blob/main/common/src/index.ts"
    click BackendService "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/index.ts"
    click AuthMid "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/middlewear.ts"
    click ORM "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/prisma/schema.prisma"
    click JWTTypes "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/src/types/jsonwebtoken.d.ts"
    click MulterStorage "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/src/types/multer-storage-cloudinary.d.ts"
    click ExpressTypes "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/src/types/express.d.ts"
    click VercelBackend "https://github.com/darshan98solanki/priti-s-cake/blob/main/backend/vercel.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef backend fill:#DFF7DF,stroke:#1a7f37,stroke-width:1px;
    classDef db fill:#FFE7C1,stroke:#d9822b,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#888888,stroke-width:1px;
```
