# refaelbenzvi24/cs-skins architecture

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

- Interactive diagram: https://gitdiagram.com/refaelbenzvi24/cs-skins
- Repository: https://github.com/refaelbenzvi24/cs-skins

## Overview

##### Main Components

a. Applications Layer:
- Next.js Web Application (apps/nextjs)
- Expo Mobile Application (apps/expo)
- Cronjobs Service (apps/cronjobs)
- Scraper Service (apps/scraper)
- Email Templates Preview (apps/email-templates-preview)

b. Shared Packages Layer:
- API Package (@trpc router definitions)
- Authentication Package (next-auth integration)
- Database Package (Prisma/PostgreSQL)
- UI Components Package
- Message Broker Package
- Validation Package
- Logger Package

c. Infrastructure Layer:
- Database (PostgreSQL)
- Message Queue System
- Elastic APM (for monitoring)
- Email Service

##### Relationships and Data Flow

- API calls between applications and the shared API package
- Database interactions through the db package
- Authentication flow through the auth package
- Message flow through the message broker
- UI component usage in applications
- Monitoring and logging paths

##### Specific Implementation Details

a. Next.js Application:
- TRPC router integration
- I18n implementation (locales)
- Authentication flow
- UI components usage

b. Expo Application:
- Mobile-specific features
- Shared API integration
- Native navigation flow

c. Background Services:
- Cronjob scheduling
- Scraper data flow
- Email template processing

##### Additional Elements

Specialized sections for:
- Development Tools (Turborepo, ESLint, Prettier)
- Deployment Paths (Vercel, EAS)
- Testing Infrastructure
- CI/CD Pipeline

##### Notes Section

Annotations for:
- Scale considerations
- Security implementations
- Performance optimizations
- Development workflows

Remember to emphasize the type-safety aspects across the stack and how the various tools (tRPC, Prisma, TypeScript) work together to ensure end-to-end type safety.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Applications
        NextJS["Next.js Web App"]:::app
        Expo["Expo Mobile App"]:::app
        Cronjobs["Cronjobs Service"]:::app
        Scraper["Scraper Service"]:::app
        EmailPreview["Email Templates Preview"]:::app
        UIDocs["UI Documentation"]:::app
    end

    subgraph "Shared Packages"
        API["API (tRPC)"]:::package
        Auth["Authentication"]:::package
        DB["Database (Prisma)"]:::package
        UI["UI Components"]:::package
        MessageBroker["Message Broker"]:::package
        Validation["Validation"]:::package
        Logger["Logger"]:::package
    end

    subgraph Infrastructure
        PostgreSQL[(PostgreSQL)]:::infra
        MessageQueue["Message Queue"]:::infra
        ElasticAPM["Elastic APM"]:::infra
        EmailService["Email Service"]:::infra
    end

    subgraph "Development Tools"
        ESLint["ESLint"]:::tool
        Prettier["Prettier"]:::tool
        TypeScript["TypeScript"]:::tool
        Tailwind["Tailwind"]:::tool
    end

    %% Application Dependencies
    NextJS --> API
    NextJS --> Auth
    NextJS --> UI
    NextJS --> ElasticAPM
    
    Expo --> API
    Expo --> Auth
    Expo --> UI
    
    Cronjobs --> API
    Cronjobs --> MessageBroker
    
    Scraper --> API
    Scraper --> MessageBroker
    
    EmailPreview --> UI
    EmailPreview --> EmailService

    %% Shared Package Dependencies
    API --> DB
    API --> Validation
    API --> Logger
    API --> MessageBroker
    API --> EmailService
    
    Auth --> DB
    Auth --> Logger
    
    DB --> PostgreSQL
    
    MessageBroker --> MessageQueue
    
    %% Infrastructure Monitoring
    Logger --> ElasticAPM

    %% Click Events
    click NextJS "https://github.com/Refaelbenzvi24/cs-skins/tree/development/apps/nextjs"
    click Expo "https://github.com/Refaelbenzvi24/cs-skins/tree/development/apps/expo"
    click Cronjobs "https://github.com/Refaelbenzvi24/cs-skins/tree/development/apps/cronjobs"
    click Scraper "https://github.com/Refaelbenzvi24/cs-skins/tree/development/apps/scraper"
    click EmailPreview "https://github.com/Refaelbenzvi24/cs-skins/tree/development/apps/email-templates-preview"
    click API "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/api"
    click Auth "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/auth"
    click DB "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/db"
    click UI "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/ui"
    click MessageBroker "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/message-broker"
    click Validation "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/modules/validations"
    click Logger "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/modules/logger"
    click ESLint "https://github.com/Refaelbenzvi24/cs-skins/tree/development/tooling/eslint"
    click Prettier "https://github.com/Refaelbenzvi24/cs-skins/tree/development/tooling/prettier"
    click TypeScript "https://github.com/Refaelbenzvi24/cs-skins/tree/development/tooling/typescript"
    click Tailwind "https://github.com/Refaelbenzvi24/cs-skins/tree/development/tooling/tailwind"
    click ElasticAPM "https://github.com/Refaelbenzvi24/cs-skins/tree/development/apps/nextjs/src/utils/monitoring/elastic"
    click EmailService "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/api/src/services/email"
    click MessageBroker "https://github.com/Refaelbenzvi24/cs-skins/blob/development/packages/message-broker/src/MessageBroker.ts"
    click DB "https://github.com/Refaelbenzvi24/cs-skins/tree/development/packages/db/src/schema"

    %% Styling
    classDef app fill:#2563eb,color:white,stroke:none
    classDef package fill:#16a34a,color:white,stroke:none
    classDef infra fill:#ea580c,color:white,stroke:none
    classDef tool fill:#9333ea,color:white,stroke:none
    
    %% Legend
    subgraph Legend
        L1[Application]:::app
        L2[Shared Package]:::package
        L3[Infrastructure]:::infra
        L4[Development Tool]:::tool
    end
```
