# riccardoperra/codeimage architecture

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

- Interactive diagram: https://gitdiagram.com/riccardoperra/codeimage
- Repository: https://github.com/riccardoperra/codeimage

## Overview

##### Main Components Identification

The system consists of two main applications and several supporting packages:

a. Frontend Application (@codeimage/app):
- Built with SolidJS
- Uses CodeMirror6 for code editing
- Implements vanilla-extract for styling
- Includes state management via StateBuilder

b. Backend Application (@codeimage/api):
- Built with Fastify
- Uses Prisma ORM for database operations
- Implements Auth0 for authentication

##### Key Architectural Elements

a. Client Layer:
- UI Components (Terminal, Editor, PropertyEditor)
- State Management
- Theme System
- Export Functionality

b. API Layer:
- REST Endpoints
- Authentication/Authorization
- Database Operations

c. Supporting Services:
- Auth0 Integration
- Image Processing
- Font Management

**[Frontend Layer]**
- ↑↓
**[API Gateway]**
- ↑↓
**[Backend Services]**
- ↑↓
**[External Services]**

##### Component Relationships

Key interactions:
- Frontend to API communication
- Authentication flow with Auth0
- Database operations through Prisma
- Image export pipeline
- State management flow

##### Specific Implementation Details

Technical elements:
- Monorepo structure (@codeimage/*)
- Package dependencies
- API endpoints
- Database schema
- Authentication flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI["UI Components"]
        Terminal["Terminal Component"]
        Editor["Editor Component"]
        PropEditor["Property Editor"]
        StateMan["State Management"]
        ThemeSystem["Theme System"]
        Export["Export Functionality"]
        
        UI --> Terminal
        UI --> Editor
        UI --> PropEditor
        UI --> StateMan
        UI --> ThemeSystem
        UI --> Export
    end

    subgraph Backend
        REST["REST Endpoints"]
        Auth["Auth0 Integration"]
        DB[(Database)]
        Controllers["API Controllers"]
        ErrorHandle["Error Handling"]
        
        REST --> Controllers
        Controllers --> DB
        Auth --> Controllers
        Controllers --> ErrorHandle
    end

    subgraph Supporting
        DOMExport["DOM Export"]
        Syntax["Syntax Highlighting"]
        UILib["UI Component Library"]
        FontMgmt["Font Management"]
        Locale["Locale Support"]
    end

    Frontend <--> REST
    Frontend --> DOMExport
    Frontend --> Syntax
    Frontend --> UILib
    Frontend --> FontMgmt
    Frontend --> Locale

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef support fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white

    class UI,Terminal,Editor,PropEditor,StateMan,ThemeSystem,Export frontend
    class REST,Auth,Controllers,ErrorHandle backend
    class DOMExport,Syntax,UILib,FontMgmt,Locale support
    class DB database

    click UI "https://github.com/riccardoperra/codeimage/tree/main/apps/codeimage/src/components/"
    click Terminal "https://github.com/riccardoperra/codeimage/tree/main/apps/codeimage/src/components/Terminal/"
    click Editor "https://github.com/riccardoperra/codeimage/tree/main/apps/codeimage/src/components/CustomEditor/"
    click PropEditor "https://github.com/riccardoperra/codeimage/tree/main/apps/codeimage/src/components/PropertyEditor/"
    click StateMan "https://github.com/riccardoperra/codeimage/tree/main/apps/codeimage/src/state/"
    click ThemeSystem "https://github.com/riccardoperra/codeimage/tree/main/apps/codeimage/src/theme/"
    click Export "https://github.com/riccardoperra/codeimage/blob/main/apps/codeimage/src/hooks/export-snippet.ts"
    click REST "https://github.com/riccardoperra/codeimage/tree/main/apps/api/src/routes/v1/"
    click Auth "https://github.com/riccardoperra/codeimage/blob/main/apps/api/src/plugins/auth0.ts"
    click DB "https://github.com/riccardoperra/codeimage/blob/main/apps/api/prisma/schema.prisma"
    click Controllers "https://github.com/riccardoperra/codeimage/tree/main/apps/api/src/modules/"
    click ErrorHandle "https://github.com/riccardoperra/codeimage/tree/main/apps/api/src/common/exceptions/"
    click DOMExport "https://github.com/riccardoperra/codeimage/tree/main/packages/dom-export/"
    click Syntax "https://github.com/riccardoperra/codeimage/tree/main/packages/highlight/"
    click UILib "https://github.com/riccardoperra/codeimage/tree/main/packages/ui/"
    click FontMgmt "https://github.com/riccardoperra/codeimage/blob/main/apps/codeimage/src/state/editor/config/localFont.ts"
    click Locale "https://github.com/riccardoperra/codeimage/tree/main/packages/locale/"
```
