# amine-tayani/onyxapp architecture

> Architecture diagram of the GitHub repository amine-tayani/onyxapp, 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/amine-tayani/onyxapp
- Repository: https://github.com/amine-tayani/onyxapp

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (src/app directory structure)
- Marketing Pages (src/app/(marketing))
- Authentication Pages (src/app/(auth))
- Dashboard Interface (src/app/dashboard)
- UI Components (src/components/ui)

b) API Layer:
- Next.js API Routes (src/app/api)
- Authentication Endpoints
- Webhook Handlers (especially for Stripe)
- File Upload Handlers (UploadThing integration)

c) Database Layer:
- Prisma ORM (prisma/schema.prisma)
- Database Migrations
- Data Models

d) External Services:
- Stripe Payment Processing
- Email Service
- Authentication Providers
- File Storage (UploadThing)

##### Component Relationships

- Client → API: Show RESTful/API route connections
- API → Database: Illustrate Prisma ORM interactions
- API → External Services: Display third-party service integrations
- Authentication Flow: Highlight the auth process flow

##### Specific Implementation Details

Key architectural elements:

**┌─────────────────────────────────────────────────────────┐**
- Client Layer                         │
- ┌─────────────┐ ┌─────────────┐ ┌────────────────────┐ │
- Marketing   │ │ Auth Pages  │ │ Dashboard          │ │
- Components  │ │ (Login/     │ │ (Applications/     │ │
- Signup)    │ │  Settings)         │ │
- ┘ └─────────────┘ └────────────────────┘ │
- ┬─────────────────────────────┘

**┌───────────────────────────┼─────────────────────────────┐**
- API Layer       │                             │
- ┌─────────────┐ ┌────────┴────┐ ┌──────────────────┐   │
- Auth API    │ │ Core API    │ │ Webhook Handlers │   │
- Routes      │ │ Endpoints   │ │ (Stripe)         │   │
- ┘ └─────────────┘ └──────────────────┘   │
- ┬─────────────────────────────┘

**┌───────────────────────────┼─────────────────────────────┐**
- Service Layer      │                             │
- ┌─────────────┐ ┌────────┴────┐ ┌──────────────────┐   │
- Prisma ORM  │ │ Email       │ │ Payment          │   │
- Service     │ │ Processing       │   │
- ┘ └─────────────┘ └──────────────────┘   │
- ┬─────────────────────────────┘

**┌───────────────────────────┼─────────────────────────────┐**
- Database Layer     │                             │
- ┌─────────────────────────┴─────────────────────────┐   │
- PostgreSQL Database                  │   │
- ┘ │
- ┘

##### Notes for Implementation Details

Annotations for:
- Authentication strategies (NextAuth.js implementation)
- Database schema highlights
- API route security measures
- External service integration points

Remember to maintain a balance between detail and clarity, focusing on the core architecture while providing enough detail to understand the system's complete functionality.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Marketing["Marketing Pages"]
        Auth["Authentication Pages"]
        Dashboard["Dashboard Interface"]
        UI["UI Components"]
        AuthComp["Auth Components"]
        EmailTemp["Email Templates"]
        DashComp["Dashboard Components"]
        BillComp["Billing Components"]
        AppManage["Application Management"]
        UserSettings["User Settings"]
    end

    subgraph API
        AuthAPI["Authentication API"]
        StripeWebhook["Stripe Webhook Handler"]
        FileUpload["File Upload Handler"]
    end

    subgraph Services
        AuthService["Authentication Service"]
        EmailService["Email Service"]
        StripeService["Stripe Payment Integration"]
    end

    subgraph Database
        DBSchema["Database Schema"]
        DBMigrations["Database Migrations"]
    end

    %% Connections
    Marketing --> AuthAPI
    Auth --> AuthAPI
    Dashboard --> AuthAPI
    AuthComp --> AuthService
    BillComp --> StripeService
    DashComp --> AppManage
    AppManage --> AuthAPI
    UserSettings --> AuthAPI
    AuthAPI --> AuthService
    AuthAPI --> DBSchema
    StripeWebhook --> StripeService
    FileUpload --> DBSchema
    EmailService --> EmailTemp
    AuthService --> DBSchema
    StripeService --> DBSchema
    DBSchema --> DBMigrations

    %% Click Events
    click Marketing "https://github.com/amine-tayani/onyxapp/tree/main/src/app/(marketing)"
    click Auth "https://github.com/amine-tayani/onyxapp/tree/main/src/app/(auth)"
    click Dashboard "https://github.com/amine-tayani/onyxapp/tree/main/src/app/dashboard"
    click UI "https://github.com/amine-tayani/onyxapp/tree/main/src/components/ui"
    click AuthAPI "https://github.com/amine-tayani/onyxapp/tree/main/src/app/api/auth"
    click StripeWebhook "https://github.com/amine-tayani/onyxapp/tree/main/src/app/api/webhooks/stripe"
    click FileUpload "https://github.com/amine-tayani/onyxapp/tree/main/src/app/api/uploadthing"
    click DBSchema "https://github.com/amine-tayani/onyxapp/blob/main/prisma/schema.prisma"
    click DBMigrations "https://github.com/amine-tayani/onyxapp/tree/main/prisma/migrations"
    click StripeService "https://github.com/amine-tayani/onyxapp/blob/main/src/lib/payments/stripe.ts"
    click EmailService "https://github.com/amine-tayani/onyxapp/tree/main/src/lib/email"
    click AuthService "https://github.com/amine-tayani/onyxapp/tree/main/src/lib/auth"
    click AppManage "https://github.com/amine-tayani/onyxapp/tree/main/src/app/applications"
    click UserSettings "https://github.com/amine-tayani/onyxapp/tree/main/src/app/dashboard/settings"
    click AuthComp "https://github.com/amine-tayani/onyxapp/tree/main/src/components/auth"
    click EmailTemp "https://github.com/amine-tayani/onyxapp/tree/main/src/components/email-templates"
    click DashComp "https://github.com/amine-tayani/onyxapp/tree/main/src/components/dashboard"
    click BillComp "https://github.com/amine-tayani/onyxapp/tree/main/src/components/billing"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef api fill:#4CAF50,stroke:#2E7D32,color:white
    classDef service fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#9C27B0,stroke:#7B1FA2,color:white

    class Marketing,Auth,Dashboard,UI,AuthComp,EmailTemp,DashComp,BillComp,AppManage,UserSettings frontend
    class AuthAPI,StripeWebhook,FileUpload api
    class AuthService,EmailService,StripeService service
    class DBSchema,DBMigrations database
```
