# sms03/sharksenz architecture

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

- Interactive diagram: https://gitdiagram.com/sms03/sharksenz
- Repository: https://github.com/sms03/sharksenz

## Overview

##### Project Overview
- SharkSenz is a full-stack SaaS platform for startup founders, built as a single-page application (SPA) with React/Vite on the frontend and Supabase (PostgreSQL + Auth + Edge Functions) as the backend, hosted on Vercel. It integrates with the Cashfree payment gateway for subscriptions and multi-currency billing.

##### Main Components
a. Frontend (src/)
- UI Layer: React 18 + TypeScript, Vite build.
- Components:
– src/components/ui (shadcn/ui primitives)
– src/components/analytics (calculators)
– src/components (ContentCard, PitchSimulator, AuthButton, etc.)
– src/layouts (MainLayout)
- Pages & Routing: src/pages (Index, AnalyticsDashboard, Pricing, Auth, ProfilePage, etc.)
- State & Data Fetching: React Contexts (src/contexts/AuthContext), TanStack Query, custom hooks (src/hooks).
- Static Assets: public/assets served by Vercel.

b. Backend Services
- Supabase Auth & Database: PostgreSQL tables for users, content library, subscription plans, analytics data.
- Supabase Edge Functions (supabase/functions):
– create-cashfree-order (generates payment order)
– verify-cashfree-payment (webhook to confirm payment)
- Supabase Client Integration: src/integrations/supabase/client.ts connects frontend to Supabase APIs.

c. External Services
- Cashfree Payment Gateway: payment routing, multi-currency, GST compliance.
- (Possible AI Service) for Pitch Simulator feedback (implied by “AI-powered analysis”).

d. Deployment & Hosting
- Vercel: hosts static frontend, runs Supabase Edge Functions (via Supabase).

##### Interactions & Data Flows
- User -> React SPA (served from Vercel CDN)
- SPA <-> Supabase Auth (login, tokens)
- SPA <-> Supabase Database (content library, analytics data) via Supabase JS client + TanStack Query
- SPA -> Edge Function "create-cashfree-order" -> Cashfree API
- Cashfree -> Edge Function "verify-cashfree-payment" (webhook) -> update subscription status in DB -> SPA notified (via real-time or refetch)
- SPA -> (optional) AI API for pitch analysis

##### Architectural Patterns & Design Principles
- SPA + REST/Realtime backend
- Serverless Functions for payment orchestration
- Role-based access: ProtectedRoute components gate premium content
- Modular UI with atomic design (shadcn/ui primitives + custom components)
- Separation of concerns: components, hooks, contexts, integrations directories
- Infrastructure as code: supabase/config.toml for migrations

- Clear, descriptive labels on all nodes

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        SPA["React SPA<br/>(React/Vite, TS, Tailwind)"]:::frontend
        UI["UI Layer<br/>shadcn/ui primitives"]:::frontend
        Pages["Pages & Routing<br/>src/pages"]:::frontend
        Layouts["Layouts<br/>MainLayout"]:::frontend
        SharedComponents["Shared Components<br/>src/components"]:::frontend
        Analytics["Analytics Calculators<br/>src/components/analytics"]:::frontend
        Contexts["Auth Context<br/>src/contexts/AuthContext.tsx"]:::frontend
        Hooks["Custom Hooks<br/>src/hooks"]:::frontend
        Integrations["Supabase Client Integration<br/>src/integrations/supabase/client.ts"]:::frontend
        PublicAssets["Static Assets<br/>public/assets"]:::frontend

        SPA --> UI
        SPA --> Pages
        SPA --> Layouts
        SPA --> SharedComponents
        SPA --> Analytics
        SPA --> Contexts
        SPA --> Hooks
        SPA --> Integrations
        SPA --> PublicAssets
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        EdgeFunctions["Supabase Edge Functions"]:::backend
        CreateOrder["create-cashfree-order"]:::backend
        VerifyPayment["verify-cashfree-payment"]:::backend
        EdgeFunctions --> CreateOrder
        EdgeFunctions --> VerifyPayment
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        SupabaseAuth["Supabase Auth"]:::backend
        Postgres["PostgreSQL Database"]:::database
        Config["Config & Migrations<br/>supabase/config.toml"]:::backend
        SupabaseAuth --> Postgres
        Config --> Postgres
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Cashfree["Cashfree Payment Gateway"]:::external
        AIService["AI Service (Optional)"]:::external
    end

    %% Vercel Hosting
    Vercel["Vercel CDN & Hosting"]:::frontend

    %% Connections
    Vercel --> SPA
    SPA -->|Auth/Login| SupabaseAuth
    SPA -->|DB Read/Write| Postgres
    SPA -->|POST /edge-function/create-order| CreateOrder
    CreateOrder -->|API Request| Cashfree
    Cashfree -->|Webhook| VerifyPayment
    VerifyPayment -->|Update Subscription| Postgres
    Postgres -->|Real-time/Refetch| SPA
    SPA -->|POST Pitch Data| AIService

    %% Click Events
    click UI "https://github.com/sms03/sharksenz/tree/main/src/components/ui"
    click SPA "https://github.com/sms03/sharksenz/blob/main/src/main.tsx"
    click Pages "https://github.com/sms03/sharksenz/tree/main/src/pages"
    click Layouts "https://github.com/sms03/sharksenz/blob/main/src/layouts/MainLayout.tsx"
    click SharedComponents "https://github.com/sms03/sharksenz/tree/main/src/components"
    click Analytics "https://github.com/sms03/sharksenz/tree/main/src/components/analytics"
    click Contexts "https://github.com/sms03/sharksenz/blob/main/src/contexts/AuthContext.tsx"
    click Hooks "https://github.com/sms03/sharksenz/tree/main/src/hooks"
    click Integrations "https://github.com/sms03/sharksenz/blob/main/src/integrations/supabase/client.ts"
    click PublicAssets "https://github.com/sms03/sharksenz/tree/main/public/assets"
    click CreateOrder "https://github.com/sms03/sharksenz/blob/main/supabase/functions/create-cashfree-order/index.ts"
    click VerifyPayment "https://github.com/sms03/sharksenz/blob/main/supabase/functions/verify-cashfree-payment/index.ts"
    click Config "https://github.com/sms03/sharksenz/blob/main/supabase/config.toml"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:1px
    classDef backend fill:#E8F5E9,stroke:#2E7D32,stroke-width:1px
    classDef external fill:#FFF3E0,stroke:#EF6C00,stroke-width:1px
    classDef database fill:#C8E6C9,stroke:#1B5E20,stroke-width:1px
```
