# pinfada/invitation-anniversaire architecture

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

- Interactive diagram: https://gitdiagram.com/pinfada/invitation-anniversaire
- Repository: https://github.com/pinfada/invitation-anniversaire

## Overview

##### Project type and purpose
- From the file tree, we have two top-level folders: `client` (a React/Tailwind front-end) and `server` (a Node/Express back-end).
- The front-end contains components like `BirthdayInvitation`, `PhotoShare`, `QRScanner` and an admin subfolder with `GuestManager` and `QRCodePreview`. The back-end has `guest` models and `guestRoutes`.
- There’s also `test-mongodb.js`, suggesting MongoDB as the database.
- Purpose: a Progressive Web App (PWA) for managing and sharing event invitations (e.g., birthday invites) via QR codes, with photo-share features, plus an admin interface to manage guests and preview/generate QR codes.

##### File structure
- `client/`
- `public/` holds `index.html`, `manifest.json`, `service-worker.js` (PWA support).
- `src/components/` has feature components: user-facing (`BirthdayInvitation`, `PhotoShare`, `QRScanner`) and admin (`GuestManager`, `QRCodePreview`).
- Configs: `.env.development`, `postcss.config.js`, `tailwind.config.js`.
- `server/`
- `models/guest.js` defines the guest schema.
- `routes/guestRoutes.js` maps HTTP endpoints to controller logic.
- `server.js` boots up the Express app and registers middleware/routes.
- Root:
- Monorepo `package.json` (workspace or script orchestration).
- `test-mongodb.js` used to verify connectivity to MongoDB.

##### README
- (Empty in this case, so we infer from structure.)

##### Elements
- Clear labels: “React PWA Client”, “Express API Server”, “MongoDB Database”, “QR Code Library”, “Cloud Storage (optional)”.
- Browser → Service Worker → Static assets
- Browser ↔ Express API
- Express → MongoDB
- Client ↔ Cloud Storage (if applicable)
- UI components (rectangles, light blue)

##### Detailed, essential architectural elements
- Break the client into sub-components:
- “Invitation Viewer” (BirthdayInvitation)
- “Photo Sharing” (PhotoShare)
- “QR Scanner” (QRScanner)
- “Admin Panel” (GuestManager + QRCodePreview)
- Configuration flow: `.env` → client/server endpoint values.
- Build steps or scripts if relevant (e.g., npm run build in root vs. client).

- Top layer: User’s Browser (PWA UI + service worker)
- Middle layer: Express REST API (guestRoutes, photo endpoints, QR generation)
- Bottom layer: MongoDB data store (Guests collection) + optional Cloud Storage for images.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top layer: User Browser & PWA
    subgraph "User Browser (PWA)" 
        direction TB
        Browser["User's Browser"]:::external
        StaticAssets["Static Assets"]:::ui
        ServiceWorker["Service Worker"]:::ui
        Manifest["Web App Manifest"]:::ui
        Browser -->|"loads index.html"| StaticAssets
        Browser -->|"registers"| ServiceWorker
        Browser -->|"reads"| Manifest
        click StaticAssets "https://github.com/pinfada/invitation-anniversaire/blob/main/client/public/index.html"
        click ServiceWorker "https://github.com/pinfada/invitation-anniversaire/blob/main/client/public/service-worker.js"
        click Manifest "https://github.com/pinfada/invitation-anniversaire/blob/main/client/public/manifest.json"
    end

    %% Client Application Components
    subgraph "React PWA Client" 
        direction TB
        InvitationViewer["Invitation Viewer"]:::ui
        PhotoSharing["Photo Sharing"]:::ui
        QRScanning["QR Scanner"]:::ui
        AdminPanel["Admin Panel"]:::ui
        InvitationViewer -->|"/"| Browser
        PhotoSharing -->|"/photos"| Browser
        QRScanning -->|"/scan"| Browser
        AdminPanel -->|"/admin"| Browser
        click InvitationViewer "https://github.com/pinfada/invitation-anniversaire/blob/main/client/src/components/BirthdayInvitation.js"
        click PhotoSharing "https://github.com/pinfada/invitation-anniversaire/blob/main/client/src/components/PhotoShare.js"
        click QRScanning "https://github.com/pinfada/invitation-anniversaire/blob/main/client/src/components/QRScanner.js"
        subgraph "Admin Panel Components"
            direction TB
            GuestManager["Guest Manager"]:::ui
            QRCodePreview["QR Code Preview"]:::ui
        end
        AdminPanel --> GuestManager
        AdminPanel --> QRCodePreview
        click GuestManager "https://github.com/pinfada/invitation-anniversaire/blob/main/client/src/components/admin/GuestManager.js"
        click QRCodePreview "https://github.com/pinfada/invitation-anniversaire/blob/main/client/src/components/admin/QRCodePreview.js"
        ConfigDotEnv["Front-end Environment Config"]:::ui
        TailwindConfig["Tailwind CSS Config"]:::ui
        PostCSSConfig["PostCSS Config"]:::ui
        click ConfigDotEnv "https://github.com/pinfada/invitation-anniversaire/blob/main/client/.env.development"
        click TailwindConfig "https://github.com/pinfada/invitation-anniversaire/blob/main/client/tailwind.config.js"
        click PostCSSConfig "https://github.com/pinfada/invitation-anniversaire/blob/main/client/postcss.config.js"
    end

    %% Communication to API Server
    Browser -->|"HTTPS requests (REST)"| APIServer

    %% Server layer
    subgraph "Express API Server" 
        direction TB
        APIServer["Express API Server"]:::api
        GuestRoutes["Guest Routes (/api/guests)"]:::api
        APIPhotos["Photo Routes (/api/photos)"]:::api
        QRLib["QR Code Generation Library"]:::api
        ConfigServer["Server Package Config"]:::api

        APIServer --> GuestRoutes
        APIServer --> APIPhotos
        APIServer --> QRLib
        click APIServer "https://github.com/pinfada/invitation-anniversaire/blob/main/server/server.js"
        click GuestRoutes "https://github.com/pinfada/invitation-anniversaire/blob/main/server/routes/guestRoutes.js"
        click ConfigServer "https://github.com/pinfada/invitation-anniversaire/blob/main/server/package.json"
    end

    %% Data layer
    subgraph "Data & External Services"
        direction TB
        MongoDB["MongoDB Database"]:::db
        GuestModel["Guest Data Model"]:::db
        CloudStorage["Cloud Storage (for photos)"]:::external
        APIServer --> MongoDB
        APIServer --> CloudStorage
        click GuestModel "https://github.com/pinfada/invitation-anniversaire/blob/main/server/models/guest.js"
        MongoTest["MongoDB Test Script"]:::db
        click MongoTest "https://github.com/pinfada/invitation-anniversaire/blob/main/test-mongodb.js"
    end

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6,stroke-width:1px
    classDef api fill:#DFFFE0,stroke:#268A00,color:#268A00,stroke-width:1px
    classDef db fill:#FFE8D0,stroke:#D97706,color:#D97706,stroke-width:1px
    classDef external stroke-dasharray: 5 5,stroke:#555,color:#555,fill:none
```
