# tifiloutube/l-agencev2 architecture

> Architecture diagram of the GitHub repository tifiloutube/l-agencev2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tifiloutube/l-agencev2
- Repository: https://github.com/tifiloutube/l-agencev2

## Overview

##### Project type and purpose
- This is a full-stack web application (“L-agencev2”) built with Next.js 13 (App Router), React and TypeScript on the frontend, and Next.js API Routes (Node.js) on the backend.
- Purpose: an online real-estate matching platform (“mise en relation immobilière”) that supports property listing, user account management, messaging between users, property simulations, and subscription billing via Stripe.

##### File structure
- Top-level “client” folder hosts both frontend (app/, components/, public/, styles/) and backend (app/api/) code.
- app/ contains React server/client components and page routes.
- app/api/ contains Next.js API Route endpoints mapped one-to-one to business features: account, auth, properties, messages, favorites, simulation, stripe, upload-temp.
- lib/ holds shared utilities: prisma client, authentication helpers, business services, Stripe plan definitions, React context.
- prisma/ holds the schema and migration history for the PostgreSQL database.
- components/ contains reusable React UI components grouped by domain (account, property, message, layout).

##### README for additional insights
- Confirms the real-estate marketplace nature.

##### Elements
- Clear labels: e.g., “Next.js API Routes”, “Prisma ORM”, “PostgreSQL DB”, “Stripe Service”.
- UI → API (property listing, messages, simulation)
- API → DB (CRUD operations)
- API ↔ Stripe (checkout, webhook events)
- External services in a third (e.g., gray clouds)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        Browser["Client Browser"]:::frontend
        NextServer["Next.js App Router & Pages"]:::frontend
        Components["Reusable React UI Components"]:::frontend
        Browser --> NextServer
        NextServer --> Components
        NextServer --> API
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        subgraph "API Layer"
            direction TB
            AuthAPI["Auth"]:::api
            AccountAPI["Account"]:::api
            PropertiesAPI["Properties"]:::api
            MessagesAPI["Messages"]:::api
            FavoritesAPI["Favorites"]:::api
            SimulationAPI["Simulation"]:::api
            StripeAPI["Stripe"]:::api
            UploadAPI["Upload"]:::api
        end
        API(("API Layer")):::backend
        API --> AuthAPI
        API --> AccountAPI
        API --> PropertiesAPI
        API --> MessagesAPI
        API --> FavoritesAPI
        API --> SimulationAPI
        API --> StripeAPI
        API --> UploadAPI

        subgraph "Shared Utilities"
            direction TB
            AuthLib["Auth Helpers"]:::util
            ServicesLib["Business Services"]:::util
            StripePlan["Stripe Plan Definitions"]:::util
            ToastContext["React Context"]:::util
        end

        API --> AuthLib
        API --> ServicesLib
        API --> StripePlan
        API --> ToastContext

        LibPrisma["Prisma ORM"]:::db
        AuthLib --> LibPrisma
        ServicesLib --> LibPrisma
        StripePlan --> LibPrisma
        UploadAPI --> LibPrisma
        SimulationAPI --> LibPrisma
        PropertiesAPI --> LibPrisma
        MessagesAPI --> LibPrisma
        FavoritesAPI --> LibPrisma
        AccountAPI --> LibPrisma
        AuthAPI --> LibPrisma

        LibPrisma --> PostgresDB["PostgreSQL DB"]:::db
    end

    %% External Services
    StripeService["Stripe Service"]:::external
    Storage["Upload Storage"]:::external

    StripeAPI -->|Checkout, Webhooks| StripeService
    StripeService -->|Webhook Events| StripeAPI
    UploadAPI -->|File Upload| Storage

    %% UI to API call
    NextServer -->|REST API calls| API

    %% Click Events
    click NextServer "https://github.com/tifiloutube/l-agencev2/tree/main/client/app"
    click Components "https://github.com/tifiloutube/l-agencev2/tree/main/client/components"
    click AuthAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/auth/[...nextauth]/route.ts"
    click AccountAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/account/update/route.ts"
    click PropertiesAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/properties/route.ts"
    click MessagesAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/messages/start/route.ts"
    click FavoritesAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/favorites/route.ts"
    click SimulationAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/simulation/save/route.ts"
    click StripeAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/stripe/plans/route.ts"
    click UploadAPI "https://github.com/tifiloutube/l-agencev2/blob/main/client/app/api/upload-temp/route.ts"
    click AuthLib "https://github.com/tifiloutube/l-agencev2/blob/main/client/lib/auth.ts"
    click ServicesLib "https://github.com/tifiloutube/l-agencev2/tree/main/client/lib/services"
    click StripePlan "https://github.com/tifiloutube/l-agencev2/blob/main/client/lib/stripe/plan.ts"
    click ToastContext "https://github.com/tifiloutube/l-agencev2/blob/main/client/lib/context/ToastContext.tsx"
    click LibPrisma "https://github.com/tifiloutube/l-agencev2/blob/main/client/lib/prisma.ts"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef api fill:#C8E6C9,stroke:#2E7D32,color:#1B5E20
    classDef util fill:#FFECB3,stroke:#F57F17,color:#E65100
    classDef db fill:#FFE0B2,stroke:#E65100,color:#BF360C
    classDef external fill:#CFD8DC,stroke:#455A64,color:#263238
```
