# prisma/prisma-examples architecture

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

- Interactive diagram: https://gitdiagram.com/prisma/prisma-examples
- Repository: https://github.com/prisma/prisma-examples

## Overview

##### Main Categories as Big “System Blocks”
- Since the repository is organized by examples, begin by dividing it into its primary folders:
– accelerate (showing examples using Prisma Accelerate for caching and connection pooling)
– optimize (demonstrating various performance improvement techniques with Prisma Optimize)
– orm (which includes both full-stack examples and backend-only examples using different frameworks, such as Next.js, Nuxt, SvelteKit, Remix, Express, Fastify, NestJS, etc.)
– databases (projects related to specific database setups like CockroachDB, MongoDB, PostgreSQL/Supabase, SQL-Server, Turso)
– deployment-platforms (projects with deployment configurations for AWS Lambda, Azure Functions, Vercel, and so on)
– additional folders like “optimize” examples also include separate projects that highlight specific database query performance issues.

##### For Each Category, Identify Their Internal Components
- Within each project’s folder (for example, in an Accelerate project like “nextjs-starter”), you typically have a separation into layers such as:
– Frontend: UI components, pages, or views (React components in Next.js or Svelte components in SvelteKit, etc.)
– Backend/API layer: API routes and server code (for REST, GraphQL, tRPC, etc.)
– ORM/Database layer: Prisma Client usage, Prisma schema files (schema.prisma), seed scripts, and migration configurations

- How the Prisma Client acts as the bridge between the application server (any framework-specific API) and the database.
- For deployment examples, show additional layers (or “adapter” blocks) such as cloud functions or Docker setups.

##### Architectural Patterns and Technologies
- Clearly label components with their specific technology (e.g., “Next.js,” “SvelteKit,” “NestJS,” “Express,” “Fastify,” “Apollo Server,” “Mercurius,” “gRPC,” etc.)
- Mention the use of Prisma’s unique capabilities: connection pooling, caching (Accelerate), and performance optimizations (Optimize)
- External integrations where applicable (for instance: GraphQL APIs, REST end-points, microservices integration via gRPC)

## Diagram (Mermaid)

```mermaid
graph TD
    repo["Prisma Examples Repository"]:::repository

    %% Connect repository to each category
    repo --> accCat
    repo --> optCat
    repo --> ormCat
    repo --> dbCat
    repo --> dpCat

    %% Accelerate Examples Subgraph
    subgraph "Accelerate Examples"
        accCat["Accelerate Category"]:::category
        nextjsStarter["Next.js Starter Example"]:::example
        a_app["Frontend App"]:::frontend
        a_components["Frontend Components"]:::frontend
        a_backend["Backend/API Layer"]:::backend
        a_prisma["Prisma/Database Layer"]:::prisma

        accCat --> nextjsStarter
        nextjsStarter --> a_app
        a_app --> a_components
        a_components --> a_backend
        a_backend --> a_prisma
    end

    %% Optimize Examples Subgraph
    subgraph "Optimize Examples"
        optCat["Optimize Category"]:::category
        optExample["Optimize Performance Example"]:::example
        optCat --> optExample
    end

    %% ORM Examples Subgraph
    subgraph "ORM Examples"
        ormCat["ORM Category"]:::category
        expressExample["Express API Example"]:::backend
        fastifyExample["Fastify API Example"]:::backend
        expressPrisma["Express Prisma Layer"]:::prisma
        fastifyPrisma["Fastify Prisma Layer"]:::prisma

        ormCat --> expressExample
        ormCat --> fastifyExample
        expressExample --> expressPrisma
        fastifyExample --> fastifyPrisma
    end

    %% Databases Examples Subgraph
    subgraph "Databases Examples"
        dbCat["Databases Category"]:::category
        cockroachExample["CockroachDB Example"]:::database
        d_prisma["Prisma ORM Layer"]:::prisma

        dbCat --> cockroachExample
        cockroachExample --> d_prisma
    end

    %% Deployment Platforms Examples Subgraph
    subgraph "Deployment Platforms Examples"
        dpCat["Deployment Platforms Category"]:::category
        awsLambdaExample["AWS Lambda Example"]:::deployment
        dp_config["Deployment Config"]:::config
        dp_prisma["Prisma/Database Layer"]:::prisma

        dpCat --> awsLambdaExample
        awsLambdaExample --> dp_config
        awsLambdaExample --> dp_prisma
    end

    %% Typical full-stack data flow in Accelerate example
    a_app -.-> a_backend
    a_backend -.-> a_prisma

    %% Click Events for Component Mappings
    click accCat "https://github.com/prisma/prisma-examples/tree/latest/accelerate/"
    click a_app "https://github.com/prisma/prisma-examples/tree/latest/accelerate/nextjs-starter/app/"
    click a_components "https://github.com/prisma/prisma-examples/tree/latest/accelerate/nextjs-starter/components/"
    click a_prisma "https://github.com/prisma/prisma-examples/blob/latest/accelerate/nextjs-starter/prisma/schema.prisma"
    
    click optCat "https://github.com/prisma/prisma-examples/tree/latest/optimize/"

    click ormCat "https://github.com/prisma/prisma-examples/tree/latest/orm/"
    click expressExample "https://github.com/prisma/prisma-examples/tree/latest/orm/express/src/"
    click expressPrisma "https://github.com/prisma/prisma-examples/blob/latest/orm/express/prisma/schema.prisma"
    click fastifyExample "https://github.com/prisma/prisma-examples/tree/latest/orm/fastify/src/"
    click fastifyPrisma "https://github.com/prisma/prisma-examples/blob/latest/orm/fastify/prisma/schema.prisma"

    click dbCat "https://github.com/prisma/prisma-examples/tree/latest/databases/"
    click d_prisma "https://github.com/prisma/prisma-examples/blob/latest/databases/cockroachdb/prisma/schema.prisma"

    click dpCat "https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/"
    click dp_prisma "https://github.com/prisma/prisma-examples/blob/latest/deployment-platforms/aws-lambda/prisma/schema.prisma"
    click dp_config "https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/aws-lambda/"

    %% Styles
    classDef repository fill:#f9f,stroke:#333,stroke-width:2px;
    classDef category fill:#ddd,stroke:#333,stroke-width:2px;
    classDef example fill:#eef,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ff9,stroke:#333,stroke-width:2px;
    classDef backend fill:#fcf,stroke:#333,stroke-width:2px;
    classDef prisma fill:#cff,stroke:#333,stroke-width:2px;
    classDef deployment fill:#99f,stroke:#333,stroke-width:2px;
    classDef config fill:#f99,stroke:#333,stroke-width:2px;
    classDef database fill:#9ff,stroke:#333,stroke-width:2px;
    classDef optimize fill:#cfc,stroke:#333,stroke-width:2px;
    class optExample optimize;
```
