# iiian/prisma-generator-entityframework architecture

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

- Interactive diagram: https://gitdiagram.com/iiian/prisma-generator-entityframework
- Repository: https://github.com/iiian/prisma-generator-entityframework

## Overview

##### Main Components

a. Input Layer:
- Prisma Schema Files (.prisma)
- Generator Configuration (provider, output, namespace, clientClassName)

b. Core Generator Components:
- Schema Parser
- Type Mappers (PostgreSQL, MySQL, SQLite, SQL Server)
- Code Generation Engine
- Template Engine (Handlebars)

c. Output Layer:
- Generated C# Models
- Generated DbContext
- Database Provider Configurations

##### Component Relationships

**[Prisma Schema] → [Schema Parser] → [Type Mapper] → [Code Generation Engine] → [Generated C# Code]**
- ↑
- [Handlebars Templates] ─┘

##### Specific Implementation Details

- Blue rectangles: Input/Output files
- Green hexagons: Processing components
- Yellow diamonds: Decision points (type mapping selection)
- Purple rectangles: Templates
- Orange rectangles: Database providers

##### Key Architectural Elements

a. Generator Pipeline:
**[Input] → [Processing] → [Output]**

b. Type Mapping System:
**[AbstractTypeMapper]**
- ↓
**[TypeMapperFactory] → [Specific Type Mappers]**

##### Technical Details

- Supported database types (PostgreSQL, MySQL, SQLite, SQL Server)
- Template processing system (Handlebars)
- File generation paths
- Configuration options

##### Configuration and customization points

Keep the abstraction level focused on the main architectural components while showing enough detail to understand the generation pipeline and type mapping system. This will help developers understand both the high-level flow and the specific implementation details of the generator.

Remember to include notes about:
- .NET Core 5.0+ support
- Database provider compatibility
- Feature support status
- Template customization options

This will create a comprehensive yet clear visualization of the project's architecture that accurately represents its code generation pipeline and component interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        PS[Prisma Schema]
        GC[Generator Config]
    end

    subgraph Generator["Core Generator Components"]
        SP[Schema Parser]
        TM[Type Mapper System]
        CGE[Code Generation Engine]
        TE[Template Engine]
    end

    subgraph TypeMapping["Type Mapping System"]
        ATM[Abstract Type Mapper]
        TMF[Type Mapper Factory]
        subgraph DBMappers["Database-Specific Mappers"]
            PTM[PostgreSQL Mapper]
            MTM[MySQL Mapper]
            STM[SQLite Mapper]
            MSTM[SQL Server Mapper]
        end
    end

    subgraph Templates
        MT[Model Template]
        DT[DbContext Template]
        ET[Enum Template]
    end

    subgraph Output
        GM[Generated Models]
        GD[Generated DbContext]
        DPC[DB Provider Config]
    end

    PS --> SP
    GC --> SP
    SP --> TM
    TM --> CGE
    TE --> CGE
    CGE --> GM
    CGE --> GD
    CGE --> DPC

    ATM --> TMF
    TMF --> PTM & MTM & STM & MSTM
    PTM & MTM & STM & MSTM --> CGE

    MT & DT & ET --> TE

    classDef input fill:#a8e6cf
    classDef generator fill:#dcedc1
    classDef mapper fill:#ffd3b6
    classDef template fill:#ffaaa5
    classDef output fill:#ff8b94

    class PS,GC input
    class SP,CGE,TE generator
    class ATM,TMF,PTM,MTM,STM,MSTM mapper
    class MT,DT,ET template
    class GM,GD,DPC output

    click PS "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/usage/example/schema.prisma"
    click CGE "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/generator.ts"
    click ATM "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/helpers/connnector-specs/AbstractTypeMapper.ts"
    click TMF "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/helpers/connnector-specs/TypeMapperFactory.ts"
    click PTM "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/helpers/connnector-specs/PostgresTypeMapper.ts"
    click MSTM "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/helpers/connnector-specs/SqlServerTypeMapper.ts"
    click STM "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/helpers/connnector-specs/SimpleTypeMapper.ts"
    click MT "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/templates/Model.cs.hbs"
    click DT "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/templates/DbContext.cs.hbs"
    click ET "https://github.com/iiian/prisma-generator-entityframework/blob/master/packages/generator/src/templates/Enum.cs.hbs"
```
