# renatofilipi/nebulaform architecture

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

- Interactive diagram: https://gitdiagram.com/renatofilipi/nebulaform
- Repository: https://github.com/renatofilipi/nebulaform

## Overview

##### Project Type & Purpose
- Nebulaform is a web application designed to create, customize, and analyze online forms.
- The app supports authentication, a public landing site, and a private dashboard with different functionalities such as form editing, analytics, and checkout/payment flows.
- The README indicates the technologies in use (TypeScript, Next.js, TailwindCSS, PostgreSQL/Supabase, etc.) while the file structure confirms a modern full-stack architecture.

##### Analysis of the File Structure
- The top-level “app” directory contains many pages organized into subdirectories for authentication (login, password reset, signup), dashboard functionality (editor, analytics, forms, settings, help, checkout), and public pages.
- The “components” directory is organized into various modules. There are public components (auth, landing), private components (dashboard, editor, form management, settings, etc.), and shared UI components (buttons, cards, tables, etc.).
- API endpoints and callbacks (e.g., app/api/checkout/route.ts, app/auth/callback/route.ts) reflect backend routes provided by Next.js.
- Utility libraries (under “lib”, “utils” and “stores”) manage client state, external interactions (with Supabase and Stripe), and shared functions.
- There are configuration files for ESLint, TypeScript, Tailwind, and deployment (Vercel), which indicate a structured and integrated development environment.

##### Main Components to Highlight
a. Client Interface:
- Public Landing Pages (from app/page.tsx and components/public)
- Authentication Pages (login, signup, password management in app/(auth-pages) and components/public/auth)
- Dashboard and Form Editor (from app/dashboard and components/private/editor/form management)
b. Backend/API Layer:
- Next.js API routes (e.g., app/api/checkout for handling checkout processes, app/auth/callback for authentication callbacks)
- Middleware (middleware.ts and utils/supabase/middleware.ts) which manage security and possibly request modifications.
c. Data and External Services:
- Database integration through Supabase (in utils/supabase/) with PostgreSQL as the underlying database.
- Payment integration with Stripe (lib/stripe.ts).
d. State Management and Shared Logic:
- Client-side stores (located in the “stores” folder) to manage state for analytics, editor, form inputs, submission statuses, and user data.
- Utility functions (in utils) to support constants, entity definitions, and type interfaces used across the project.

##### Relationships and Interactions
- End users access the application through a web browser, which interacts with Next.js-rendered pages (public or authenticated).
- The authentication flow leads users to the secure dashboard where they can design forms, view analytics, and manage subscriptions.
- The client components call specific API routes for operations such as checkout, form data submission, and user management.
- Middleware and utility libraries handle routing and communication with external services (Supabase for data/stores and Stripe for payments).

##### Architectural Patterns or Design Principles
- Use of file-based routing (Next.js app directory) to structure frontend and API endpoints.
- Modular component design with a clear separation of concerns (public vs. private components, UI vs. logic).
- State management via centralized stores to support dynamic forms and analytics.
- Use of modern React patterns (hooks, context providers) via components in “components/core” and “components/magicui”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User"] 

    %% Frontend: User Interface – Frontend
    subgraph "User Interface – Frontend"
        PLPage["Public Landing Pages"]
        PLComp["Public Landing Pages"]
        AuthPage["Authentication Pages"]
        AuthComp["Authentication Pages"]
        DashPages["Dashboard & Form Editor"]
        EditorPage["Dashboard Editor"]
        DashComp["Dashboard & Form Editor"]
        EditorComp["Dashboard & Form Editor"]
        StateMan["State Management"]
        UtilsFunc["Utility Functions"]
    end

    %% Backend & External Services
    subgraph "Backend & External Services"
        APICheckout["API Endpoint"]
        APICallback["API Endpoint"]
        MiddlewareMain["Middleware"]
        MiddlewareSup["Middleware"]
        DB["Database (Supabase/PostgreSQL)"]
        StripePay["Payment (Stripe)"]
    end

    %% Relationships
    User --> PLPage
    User --> AuthPage
    User --> DashPages

    PLPage -->|"renders"| PLComp
    AuthPage -->|"renders"| AuthComp

    DashPages -->|"contains"| EditorPage
    DashPages -->|"contains"| DashComp
    DashPages -->|"contains"| EditorComp

    AuthPage -->|"calls"| APICallback
    DashPages -->|"calls"| APICheckout

    APICheckout -->|"via"| MiddlewareMain
    APICallback -->|"via"| MiddlewareMain

    MiddlewareMain -->|"chains"| MiddlewareSup
    MiddlewareSup -->|"accesses"| DB

    APICheckout -->|"processes"| StripePay

    StateMan -->|"provides"| DashPages
    UtilsFunc -->|"provides"| DashPages

    %% Click Events for Frontend components
    click PLPage "https://github.com/renatofilipi/nebulaform/blob/main/app/page.tsx"
    click PLComp "https://github.com/renatofilipi/nebulaform/tree/main/components/public/landing"
    click AuthPage "https://github.com/renatofilipi/nebulaform/blob/main/app/(auth-pages)/login/page.tsx"
    click AuthComp "https://github.com/renatofilipi/nebulaform/tree/main/components/public/auth"
    click DashPages "https://github.com/renatofilipi/nebulaform/tree/main/app/dashboard"
    click EditorPage "https://github.com/renatofilipi/nebulaform/blob/main/app/dashboard/editor/[slug]/page.tsx"
    click DashComp "https://github.com/renatofilipi/nebulaform/tree/main/components/private/dashboard"
    click EditorComp "https://github.com/renatofilipi/nebulaform/tree/main/components/private/editor"
    click StateMan "https://github.com/renatofilipi/nebulaform/tree/main/stores"
    click UtilsFunc "https://github.com/renatofilipi/nebulaform/tree/main/utils"

    %% Click Events for Backend/API components
    click APICheckout "https://github.com/renatofilipi/nebulaform/blob/main/app/api/checkout/route.ts"
    click APICallback "https://github.com/renatofilipi/nebulaform/blob/main/app/auth/callback/route.ts"
    click MiddlewareMain "https://github.com/renatofilipi/nebulaform/blob/main/middleware.ts"
    click MiddlewareSup "https://github.com/renatofilipi/nebulaform/blob/main/utils/supabase/middleware.ts"
    click DB "https://github.com/renatofilipi/nebulaform/tree/main/utils/supabase"
    click StripePay "https://github.com/renatofilipi/nebulaform/blob/main/lib/stripe.ts"

    %% Styling Classes
    classDef ui fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px,color:#0D47A1;
    classDef api fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px,color:#2E7D32;
    classDef middleware fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px,color:#F57F17;
    classDef database fill:#F8BBD0,stroke:#C2185B,stroke-width:2px,color:#C2185B;
    classDef payment fill:#FFCDD2,stroke:#C62828,stroke-width:2px,color:#C62828;
    classDef state fill:#D1C4E9,stroke:#5E35B1,stroke-width:2px,color:#5E35B1;
    classDef util fill:#B2DFDB,stroke:#00695C,stroke-width:2px,color:#00695C;

    %% Assign classes
    class PLPage,PLComp,AuthPage,AuthComp,DashPages,EditorPage,DashComp,EditorComp UserInterface;
    class PLPage,PLComp,AuthPage,AuthComp,DashPages,EditorPage,DashComp,EditorComp state;
    class PLPage,PLComp,AuthPage,AuthComp,DashPages,EditorPage,DashComp,EditorComp ui;
    class APICheckout,APICallback api;
    class MiddlewareMain,MiddlewareSup middleware;
    class DB database;
    class StripePay payment;
    class StateMan state;
    class UtilsFunc util;
```
