# isaias-alt/creacionix-ai architecture

> Architecture diagram of the GitHub repository isaias-alt/creacionix-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/isaias-alt/creacionix-ai
- Repository: https://github.com/isaias-alt/creacionix-ai

## Overview

##### Project & Purpose Classification
- Creacionix AI is a full-stack web application built with Next.js, TypeScript, and Tailwind CSS.
- Its purpose is to let users generate content using generative AI (integrated via Google’s Generative AI API) while providing a smooth user experience that includes authentication (via Clerk) and a rich dashboard interface.
- The project also integrates with a database using Drizzle ORM for data persistence.

##### Main Components to Highlight
a. User Interface (UI) Components:
- Next.js Pages: The “app” directory houses logical route groupings. For example:
- The (auth) folder contains the authentication flows (sign-in and sign-up pages).
- The dashboard folder organizes user-specific pages including dashboard home, history, settings, and dynamic content pages.
- Shared UI elements: Located in components/ui (e.g., buttons, cards, inputs, alert dialogs) and specific components in app/dashboard/__components.
b. Authentication Module:
- Managed under app/(auth) with separate routes for sign-in and sign-up.
- Integrated with Clerk (as indicated by the README) for user session management.
c. Content Generation & Business Logic:
- The generative AI integration: The application interacts with Google’s Generative AI API for content creation.
- Template and constants management under app/(data) help in structuring the generation process.
d. Database & ORM Integration:
- Drizzle ORM is configured via drizzle.config.ts, and supporting database utilities are in utils/db.ts.
- These modules coordinate database operations and schema management.
e. Configuration & Utilities:
- Global styles (app/globals.css), custom hooks (hooks/use-toast.ts), middleware (middleware.ts), and build/deployment configs.
- Next.js configuration (next.config.ts) and Tailwind config (tailwind.config.ts) set up the styling and server behavior.

##### Relationships & Data Flow
- Client Browser/User Interaction:
- Users access the frontend rendered by Next.js, interact with UI components organized per page (authentication, dashboard, etc.).
- Authentication Flow:
- From sign-in/sign-up pages, authentication requests are processed by Clerk.
- Once authenticated, users are directed to dashboard areas.
- Content Generation:
- Users submit input via forms.
- The application sends requests from the UI layer to the backend logic that in turn interacts with the external Google Generative AI API.
- The generated content is then stored or processed via the database layer (using Drizzle ORM).
- Dashboard & Management:
- The dashboard pages fetch and display content stored in the database, utilizing React components from the dashboard directory and reusable UI components.

##### Architectural Patterns & Design Principles
- Next.js File-based Routing: Emphasize how the “app” directory reflects organized routing (auth, dashboard, etc.), streamlining page navigation.
- Separation of Concerns: Components are modular (UI components, hooks, utilities) ensuring that presentation, business logic, and data access are clearly separated.
- Integration with External Services: Clearly mark the integration with Google’s AI API and authentication via Clerk.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (UI Layer)
    subgraph "Frontend (UI Layer)"
        user["User Browser"]
        nextPages["Next.js Pages"]:::ui
        auth["Authentication Module"]:::auth
        signIn["Sign-In Page"]:::auth
        signUp["Sign-Up Page"]:::auth
        dashboardUI["Dashboard UI Components"]:::ui
        contentPage["Content Page"]:::ui
        sharedUI["Shared UI Elements"]:::ui
    end

    %% Backend (Business Logic & Data Layer)
    subgraph "Backend (Business Logic & Data Layer)"
        %% Content Generation & Business Logic Subgroup
        subgraph "Content Generation & Business Logic"
            templates["Templates"]:::backend
            constants["Constants"]:::backend
            contentReq["Content Generation Request"]:::backend
        end
        googleAI["Google Generative AI API"]:::external
        %% Database Integration Subgroup
        drizzleConfig["Drizzle Config"]:::db
        dbUtils["DB Utilities"]:::db
        database["Database Layer (Drizzle ORM)"]:::db
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        globals["Globals CSS"]:::config
        nextConfig["Next.js Config"]:::config
        tailwind["Tailwind Config"]:::config
        hook["use-toast Hook"]:::config
        utils["Utility Functions"]:::config
        middleware["Middleware"]:::config
    end

    %% Connections - Frontend Flow
    user --> nextPages
    nextPages --> signIn
    nextPages --> signUp
    nextPages --> dashboardUI
    dashboardUI --> contentPage
    dashboardUI --> sharedUI
    dashboardUI --> contentReq

    %% Connections - Business Logic Flow
    templates --> contentReq
    constants --> contentReq
    contentReq --> googleAI
    contentReq --> database
    drizzleConfig --> database
    dbUtils --> database
    database --> dashboardUI

    %% Configuration & Utilities dependencies (dotted lines)
    globals -.-> nextPages
    nextConfig -.-> nextPages
    tailwind -.-> nextPages
    hook -.-> dashboardUI
    utils -.-> dashboardUI
    middleware -.-> nextPages

    %% Click Events for UI Components
    click nextPages "https://github.com/isaias-alt/creacionix-ai/tree/main/app/"
    click signIn "https://github.com/isaias-alt/creacionix-ai/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.tsx"
    click signUp "https://github.com/isaias-alt/creacionix-ai/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.tsx"
    click dashboardUI "https://github.com/isaias-alt/creacionix-ai/tree/main/app/dashboard/__components/"
    click contentPage "https://github.com/isaias-alt/creacionix-ai/blob/main/app/dashboard/content/[slug]/page.tsx"
    click sharedUI "https://github.com/isaias-alt/creacionix-ai/tree/main/components/ui/"

    %% Click Events for Business Logic Components
    click templates "https://github.com/isaias-alt/creacionix-ai/blob/main/app/(data)/templates.ts"
    click constants "https://github.com/isaias-alt/creacionix-ai/blob/main/app/(data)/constants.tsx"

    %% Click Events for Database & ORM Integration
    click drizzleConfig "https://github.com/isaias-alt/creacionix-ai/blob/main/drizzle.config.ts"
    click dbUtils "https://github.com/isaias-alt/creacionix-ai/blob/main/utils/db.ts"

    %% Click Events for Configuration & Utilities
    click globals "https://github.com/isaias-alt/creacionix-ai/blob/main/app/globals.css"
    click nextConfig "https://github.com/isaias-alt/creacionix-ai/blob/main/next.config.ts"
    click tailwind "https://github.com/isaias-alt/creacionix-ai/blob/main/tailwind.config.ts"
    click hook "https://github.com/isaias-alt/creacionix-ai/blob/main/hooks/use-toast.ts"
    click utils "https://github.com/isaias-alt/creacionix-ai/blob/main/lib/utils.ts"
    click middleware "https://github.com/isaias-alt/creacionix-ai/blob/main/middleware.ts"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef auth fill:#87CEFA,stroke:#000,stroke-width:1px;
    classDef backend fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef db fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:1px;
```
