# festa-di-primavera/fdp-app architecture

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

- Interactive diagram: https://gitdiagram.com/festa-di-primavera/fdp-app
- Repository: https://github.com/festa-di-primavera/fdp-app

## Overview

##### Project type and purpose
- This is a full-stack web application built with SvelteKit for managing tickets, orders, check-ins, and earnings for an event (“Festa di Primavera 2024”).
- The project uses SvelteKit’s filesystem-based routing, server endpoints, and components for the UI; Firebase (Firestore) as its primary database; Lucia-Auth layered on Firestore; ReSend for transactional email; and is hosted/deployed via Vercel (with serverless functions and cron jobs).

##### File structure
- src/routes: SvelteKit pages (+page.svelte), server endpoints (+server.ts / +page.server.ts) for both UI and REST API under /api.
- src/components & src/lib: reusable UI components (charts, forms, feedback), helper libraries (authentication, Firebase client, utilities).
- Configuration files: svelte.config.js, vite.config.ts, tailwind.config.cjs, vercel.json (cron job, builds).
- package.json / pnpm-lock.yaml define dependencies (SvelteKit, Flowbite-Svelte, Tailwind, Lucia-Auth, Firebase, ReSend).

##### README for additional insights
- Tech stack calls out SvelteKit UI, Flowbite, Tailwind, Firebase (Firestore), Lucia-Auth, ReSend, Vercel deployment & cron job.
- Environment variables list clarifies the integration points for Firebase, Google OAuth, ReSend, and the Vercel cron secret.

##### Detail without over-splitting
- Essential integration points (DB, email, OAuth, cron) clearly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Browser (SvelteKit UI)"]:::browser
        UI["UI Components"]:::frontend
        AdminPages["Page Routes (admin, kitchen, tickets)"]:::frontend
        LoginPage["Login Page"]:::frontend
        RootPage["+page.svelte"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Serverless Functions (API)"]:::backend

        subgraph "Authentication"
            AuthCore["Core Auth Services"]:::backend
            GoogleFlow["Google OAuth Flow"]:::backend
            EmailTemp["Email Templates"]:::backend
        end

        subgraph "Business APIs"
            TicketsAPI["Ticket Management API"]:::backend
            OrdersAPI["Order Management API"]:::backend
            PermissionsAPI["Permissions API"]:::backend
            MoneyAPI["Earnings & Money API"]:::backend
            CleanAPI["Cleanup Endpoint"]:::backend
        end
    end

    %% External Services
    DB[("Firestore DB")]:::db
    ResendAPI[("ReSend Email API")]:::external
    GoogleOAuth[("Google OAuth Provider")]:::external
    CronJob[("Vercel Cron Job")]:::external

    %% Connections
    Browser --> UI
    Browser --> AdminPages
    Browser --> LoginPage
    Browser --> RootPage

    UI --> BE
    AdminPages --> BE
    LoginPage --> BE
    RootPage --> BE

    BE -->|reads/writes| DB
    AuthCore -->|stores sessions| DB

    BE -->|sends email| ResendAPI
    AuthCore -->|verification & reset| EmailTemp
    AuthCore -->|uses| GoogleOAuth

    BE --> AuthCore
    BE --> GoogleFlow
    BE --> EmailTemp

    BE --> TicketsAPI
    BE --> OrdersAPI
    BE --> PermissionsAPI
    BE --> MoneyAPI
    BE --> CleanAPI

    CronJob -->|triggers| CleanAPI

    %% Click Events
    click UI "https://github.com/festa-di-primavera/fdp-app/tree/main/src/components"
    click AdminPages "https://github.com/festa-di-primavera/fdp-app/tree/main/src/routes/(admin)"
    click LoginPage "https://github.com/festa-di-primavera/fdp-app/tree/main/src/routes/login"
    click RootPage "https://github.com/festa-di-primavera/fdp-app/blob/main/src/routes/+page.svelte"
    click BE "https://github.com/festa-di-primavera/fdp-app/tree/main/src/routes/api"
    click AuthCore "https://github.com/festa-di-primavera/fdp-app/blob/main/src/lib/auth/session.ts"
    click GoogleFlow "https://github.com/festa-di-primavera/fdp-app/blob/main/src/lib/auth/google.ts"
    click EmailTemp "https://github.com/festa-di-primavera/fdp-app/blob/main/src/lib/auth/email-templates/verification_code.ts"
    click EmailTemp "https://github.com/festa-di-primavera/fdp-app/blob/main/src/lib/auth/email-templates/password_reset.ts"
    click ResendAPI "https://github.com/festa-di-primavera/fdp-app/blob/main/src/lib/utils/resend.ts"
    click CronJob "https://github.com/festa-di-primavera/fdp-app/blob/main/vercel.json"
    click CleanAPI "https://github.com/festa-di-primavera/fdp-app/blob/main/src/routes/api/clean-db/+server.ts"
    click TicketsAPI "https://github.com/festa-di-primavera/fdp-app/blob/main/src/routes/api/tickets/+server.ts"
    click OrdersAPI "https://github.com/festa-di-primavera/fdp-app/blob/main/src/routes/api/order/+server.ts"
    click PermissionsAPI "https://github.com/festa-di-primavera/fdp-app/blob/main/src/routes/api/permissions/[id]/[newPermission]/+server.ts"
    click MoneyAPI "https://github.com/festa-di-primavera/fdp-app/blob/main/src/routes/api/money/[id]/+server.ts"

    %% Styles
    classDef browser fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef frontend fill:#e0f7fa,stroke:#006064;
    classDef backend fill:#e8f5e9,stroke:#1b5e20;
    classDef db fill:#ffe0b2,stroke:#e65100,stroke-width:2px;
    classDef external fill:#eceff1,stroke:#455a64,stroke-dasharray:2 2;
```
