# lukevella/rallly architecture

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

- Interactive diagram: https://gitdiagram.com/lukevella/rallly
- Repository: https://github.com/lukevella/rallly

## Overview

##### Main Components Identification

a) Frontend Layer:
- Landing app (/apps/landing)
- Web application (/apps/web)
- Documentation site (/apps/docs)

b) Backend Services:
- Authentication service (NextAuth.js)
- Email service (/packages/emails)
- Billing system (/packages/billing)
- Database layer (/packages/database using Prisma)

c) External Services Integration:
- Stripe for payments
- Sentry for error tracking
- PostHog for analytics
- S3 for storage
- Various OAuth providers

**┌─ Client Layer ─────────────────────┐**
- Next.js Applications               │
- ┌─────────┐ ┌─────────┐ ┌───────┐ │
- Landing │ │   Web   │ │ Docs  │ │
- ┘ └─────────┘ └───────┘ │
- ┬─────────────────┬──┘

**┌───────────────▼─────────────────▼──┐**
- API Layer (tRPC)                   │
- ┌─────────────────────────────────┐│
- REST & RPC Endpoints         ││
- ┘│
- ┬─────────────────────┘

**┌───────────────▼─────────────────────┐**
- Core Services                       │
- ┌──────────┐ ┌────────┐ ┌────────┐ │
- Auth   │ │ Emails │ │Billing │ │
- ┘ └────────┘ └────────┘ │
- ┬─────────────────────┘

**┌───────────────▼─────────────────────┐**
- Data Layer                          │
- ┌─────────────────────────────────┐ │
- Prisma ORM            │ │
- ┬───────────────┘ │
- ┌─────────────────▼───────────────┐ │
- PostgreSQL DB           │ │
- ┘ │
- ┬─┘

**┌───────────────────────────────────▼─┐**
- External Services                   │
- ┌────────┐ ┌───────┐ ┌──────────┐  │
- Stripe │ │Sentry │ │ PostHog  │  │
- ┘ └───────┘ └──────────┘  │
- ┌────────┐ ┌───────────────────┐   │
- S3   │ │  OAuth Providers  │   │
- ┘ └───────────────────┘   │
- ┘

##### Data Flow Indicators

- Client-server communication (REST/tRPC)
- Service interactions
- Database operations
- External service calls

##### Additional Elements

Include:
- Version information
- Infrastructure requirements
- Security boundaries
- Scaling components

##### Key Architectural Patterns to Highlight

- Monorepo structure (apps/ and packages/)
- Microservices architecture
- Internationalization support
- Authentication flow
- Event-driven email notifications

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef core fill:#eab308,color:white
    classDef data fill:#a855f7,color:white
    classDef external fill:#6b7280,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        Landing["Landing App"]:::frontend
        WebApp["Web Application"]:::frontend
        Docs["Documentation"]:::frontend
    end

    %% API Layer
    subgraph APILayer["API Layer"]
        TRPC["tRPC Endpoints"]:::api
    end

    %% Core Services
    subgraph CoreServices["Core Services"]
        Auth["Authentication"]:::core
        Email["Email Service"]:::core
        Billing["Billing System"]:::core
        i18n["Internationalization"]:::core
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        Prisma["Prisma ORM"]:::data
        PostgreSQL["PostgreSQL DB"]:::data
    end

    %% External Services
    subgraph ExternalServices["External Services"]
        Stripe["Stripe"]:::external
        Sentry["Sentry"]:::external
        PostHog["PostHog"]:::external
        S3["S3 Storage"]:::external
        OAuth["OAuth Providers"]:::external
    end

    %% Relationships
    ClientLayer --> APILayer
    APILayer --> CoreServices
    CoreServices --> DataLayer
    Prisma --> PostgreSQL
    CoreServices --> ExternalServices

    %% Click Events
    click Landing "https://github.com/lukevella/Rallly/tree/main/apps/landing"
    click WebApp "https://github.com/lukevella/Rallly/tree/main/apps/web"
    click Docs "https://github.com/lukevella/Rallly/tree/main/apps/docs"
    click Auth "https://github.com/lukevella/Rallly/tree/main/apps/web/src/auth"
    click Email "https://github.com/lukevella/Rallly/tree/main/packages/emails"
    click Billing "https://github.com/lukevella/Rallly/tree/main/packages/billing"
    click Prisma "https://github.com/lukevella/Rallly/tree/main/packages/database"
    click Stripe "https://github.com/lukevella/Rallly/tree/main/apps/web/src/app/api/stripe"
    click Sentry "https://github.com/lukevella/Rallly/blob/main/apps/web/sentry.client.config.ts"
    click PostHog "https://github.com/lukevella/Rallly/tree/main/packages/posthog"
    click S3 "https://github.com/lukevella/Rallly/blob/main/apps/web/src/utils/s3.ts"
    click TRPC "https://github.com/lukevella/Rallly/tree/main/apps/web/src/trpc"
    click i18n "https://github.com/lukevella/Rallly/tree/main/apps/web/public/locales"

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        APIComp["API"]:::api
        CoreComp["Core Services"]:::core
        DataComp["Data Layer"]:::data
        ExternalComp["External Services"]:::external
    end
```
