# tryabby/abby architecture

> Architecture diagram of the GitHub repository tryabby/abby, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tryabby/abby
- Repository: https://github.com/tryabby/abby

## Overview

##### Main System Components

a) Frontend Layer:
- Web Application (Next.js based dashboard)
- Documentation Site
- CDN Service

b) Backend Services:
- API Layer (Next.js API routes)
- Authentication Service
- Feature Flag Management
- A/B Testing Engine
- Remote Configuration Service

c) Data Layer:
- Primary Database (PostgreSQL, indicated by Prisma usage)
- Redis Cache (for request caching)
- CDN Cache

d) SDK Integration Layer:
- Core SDK
- Framework-specific SDKs (React, Next.js, Angular, Svelte, Remix)

##### Component Relationships

Key interactions:

a) Client Flow:
**Client Applications → SDKs → CDN/API → Feature Flags/Tests**

b) Management Flow:
**Dashboard → API Layer → Database → Cache Layer**

##### Architectural Patterns to Highlight

- Monorepo Structure (using Turborepo)
- Microservices Architecture (separate apps for web, docs, and CDN)
- API Gateway Pattern (centralized API routing)
- Caching Strategy (multi-level caching with Redis and CDN)

**┌─ Frontend Layer ─┐    ┌─ Service Layer ─┐    ┌─ Data Layer ─┐**
- Dashboard     │ → │ - API Gateway   │ → │ - PostgreSQL │
- Docs Site    │    │ - Auth Service  │    │ - Redis     │
- CDN          │    │ - Flag Service  │    └─────────────┘
- ┘    └────────────────┘

**┌─ Client Apps ─┐    ┌─ SDK Layer ─┐    ┌─ Abby Services ─┐**
- React Apps   │ → │ React SDK   │ → │ Feature Flags  │
- Next.js Apps │ → │ Next SDK    │ → │ A/B Tests      │
- Angular Apps │ → │ Angular SDK │ → │ Remote Config  │
- ┘    └────────────┘    └───────────────┘

##### Implementation Details

- API versioning (v1 endpoints)
- Authentication flows
- Feature flag evaluation paths
- A/B test distribution logic
- Caching mechanisms
- Database schema relationships (based on Prisma schema)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WA["Web Application"]:::frontend
        DS["Documentation Site"]:::frontend
        CDN["CDN Service"]:::frontend
    end

    subgraph Backend
        API["API Layer"]:::backend
        Auth["Authentication Service"]:::backend
        FFM["Feature Flag Management"]:::backend
        ABT["A/B Testing Engine"]:::backend
        RCS["Remote Config Service"]:::backend
    end

    subgraph Data
        DB[(PostgreSQL)]:::database
        RC[(Redis Cache)]:::cache
        CDNC[(CDN Cache)]:::cache
    end

    subgraph "SDK Layer"
        CoreSDK["Core SDK"]:::sdk
        subgraph "Framework SDKs"
            ReactSDK["React SDK"]:::sdk
            NextSDK["Next.js SDK"]:::sdk
            AngularSDK["Angular SDK"]:::sdk
            SvelteSDK["Svelte SDK"]:::sdk
            RemixSDK["Remix SDK"]:::sdk
        end
    end

    subgraph "Client Applications"
        CA["Client Apps"]:::client
    end

    %% Relationships
    CA --> CoreSDK
    CA --> ReactSDK & NextSDK & AngularSDK & SvelteSDK & RemixSDK
    CoreSDK --> CDN
    ReactSDK & NextSDK & AngularSDK & SvelteSDK & RemixSDK --> CDN
    CDN --> API
    WA & DS --> API
    API --> Auth
    API --> FFM & ABT & RCS
    FFM & ABT & RCS --> DB
    FFM & ABT & RCS --> RC
    CDN --> CDNC

    %% Click Events
    click WA "https://github.com/tryabby/abby/tree/main/apps/web/"
    click DS "https://github.com/tryabby/abby/tree/main/apps/docs/"
    click CDN "https://github.com/tryabby/abby/tree/main/apps/cdn/"
    click API "https://github.com/tryabby/abby/tree/main/apps/web/src/api/"
    click Auth "https://github.com/tryabby/abby/blob/main/apps/web/src/server/common/auth.ts"
    click FFM "https://github.com/tryabby/abby/blob/main/apps/web/src/server/services/FlagService.ts"
    click ABT "https://github.com/tryabby/abby/blob/main/apps/web/src/server/services/TestService.ts"
    click RCS "https://github.com/tryabby/abby/blob/main/apps/web/src/server/services/ConfigService.ts"
    click DB "https://github.com/tryabby/abby/tree/main/apps/web/prisma/"
    click RC "https://github.com/tryabby/abby/blob/main/apps/web/src/server/db/redis.ts"
    click CoreSDK "https://github.com/tryabby/abby/tree/main/packages/core/"
    click ReactSDK "https://github.com/tryabby/abby/tree/main/packages/react/"
    click NextSDK "https://github.com/tryabby/abby/tree/main/packages/next/"
    click AngularSDK "https://github.com/tryabby/abby/tree/main/packages/angular/"
    click SvelteSDK "https://github.com/tryabby/abby/tree/main/packages/svelte/"
    click RemixSDK "https://github.com/tryabby/abby/tree/main/packages/remix/"

    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef database fill:#FFC107,stroke:#FFA000,color:black
    classDef cache fill:#FF9800,stroke:#F57C00,color:white
    classDef sdk fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef client fill:#607D8B,stroke:#455A64,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        D[(Database)]:::database
        C[(Cache)]:::cache
        S[SDK]:::sdk
        CL[Client]:::client
    end
```
