# anhtuan9622/flippl architecture

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

- Interactive diagram: https://gitdiagram.com/anhtuan9622/flippl
- Repository: https://github.com/anhtuan9622/flippl

## Overview

Based on your project’s file tree and README, Flippl.app is a full-stack (primarily frontend with backend services provided by Supabase) application designed to track daily trading performance using a visually appealing calendar, charts, and performance metrics.

##### Main Project Components
- Frontend: Your primary UI is built with React (using Vite as the build tool), TypeScript, and Tailwind CSS. The frontend code resides mostly in the src folder, which is organized into pages (e.g., MainDashboard, Auth pages), components (broken into UI components, modals, and layout), hooks, and utility functions.
- Backend/Database: Supabase serves as your backend service (authentication, database, migrations). The supabase folder holds migration scripts that define your data schema.
- Deployment/Configuration: Files like netlify.toml indicate deployment on Netlify, and other config files (.bolt, ESLint, etc.) show integrated tooling for development and deployment.

##### Categories & Groupings from the File Structure
- UI Components and Layout: Emphasize components in src/components, subdivided into:
– Generic UI (Button, Input, TagGroup)
– Layout-specific items (Header, Footer, LoadingOverlay, and Section) under src/components/layout
– Modals (multiple trade-related and general modals) grouped under src/components/modals
- Business Logic & Hooks: Custom hooks (useAuth, useTradeData, useTradeEntries) guide data flow and state management.
- Assets & Constants: Assets like the Logo component and styling – the public folder’s content (e.g., demo.mp4, _redirects) – serve static resources.
- Pages: The src/pages folder forms the main routing views, from user authentication to dashboard and shared summaries.
- Backend Connection: src/lib/supabase.ts encapsulates your Supabase integration logic along with versioning or related functionality.
- Database Schema Management: The supabase/migrations directory contains ordered scripts for managing database evolutions.

a. Frontend Application:
- Pages (Authentication, Dashboard, etc.)
- Components (UI, Layout, Modals)
- Custom Hooks & Utilities (business logic and data processing)
- Assets & Constants (visual assets, constant values)

b. Backend/Database:
- Associate migration scripts (noting they implement schema changes) as part of the backend setup.

c. External Services & Integrations:
- Deployment configurations (Netlify, Vite build) to explain how the app is bundled and hosted.

##### Architectural Patterns & Important Design Principles
- Component-Based Design: Highlight how the UI is decomposed into reusable components (e.g., modals, layout, individual UI components).
- Separation of Concerns: Clearly differentiate between presentation (React components in src/components), business logic (custom hooks, utilities), and data persistence (Supabase integration and migrations).
- Single Page Application (SPA): Emphasize that routing and state management (via hooks) are client-based, connecting to backend services asynchronously.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Main Node
    FE_APP["Frontend Application (React App)"]:::frontend

    %% Frontend Details Subgraph
    subgraph "Frontend Details"
        FE_PAGES["Pages: Routing Views (Dashboard,Auth,etc)"]:::frontend
        subgraph "UI Components & Layout"
            FE_UI_generic["Generic UI (Button,Input,TagGroup)"]:::frontend
            FE_UI_layout["Layout Components (Header,Footer,etc)"]:::frontend
            FE_UI_modals["Modal Components (TradeForm,etc)"]:::frontend
        end
        FE_HOOKS["Business Logic & Custom Hooks"]:::frontend
        subgraph "Assets & Configurations"
            FE_ASSETS_logo["Assets (Logo component)"]:::frontend
            FE_PUBLIC["Public Static Assets"]:::frontend
            FE_CONSTANTS["Constants"]:::frontend
        end
        FE_SUPA_CLIENT["Supabase Client (API Integration)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend Service: Supabase"
        BE_AUTH["Authentication Service"]:::backend
        BE_DB["Database Service"]:::backend
        BE_MIGRATIONS["Migration Scripts"]:::backend
    end

    %% External & Configuration Subgraph
    subgraph "External & Config"
        subgraph "External Libraries"
            EX_CHART["Chart.js Analytics"]:::external
            EX_RADIX["Radix UI & Lucide Icons"]:::external
        end
        subgraph "Build & Deployment"
            EX_BUILD["Build & Styling Configurations"]:::config
            EX_TAILWIND["Tailwind CSS"]:::config
            EX_VITE["Vite Build"]:::config
            EX_DEPLOY["Deployment: Netlify"]:::config
        end
    end

    %% Connections within Frontend Details to Supabase Client
    FE_PAGES -->|"sendsData"| FE_SUPA_CLIENT
    FE_UI_generic -->|"sendsData"| FE_SUPA_CLIENT
    FE_UI_layout -->|"sendsData"| FE_SUPA_CLIENT
    FE_UI_modals -->|"sendsData"| FE_SUPA_CLIENT
    FE_HOOKS -->|"sendsData"| FE_SUPA_CLIENT
    FE_ASSETS_logo -->|"sendsData"| FE_SUPA_CLIENT
    FE_PUBLIC -->|"sendsData"| FE_SUPA_CLIENT
    FE_CONSTANTS -->|"sendsData"| FE_SUPA_CLIENT

    %% Connections from Frontend to Backend
    FE_SUPA_CLIENT -->|"API/DataFetching"| BE_AUTH
    FE_SUPA_CLIENT -->|"API/DataFetching"| BE_DB
    BE_DB -->|"schema"| BE_MIGRATIONS

    %% External Libraries used by UI Components
    FE_UI_generic -->|"Uses"| EX_CHART
    FE_UI_generic -->|"Uses"| EX_RADIX

    %% Build & Deployment Relationships
    EX_BUILD --> EX_TAILWIND
    EX_BUILD --> EX_VITE
    EX_VITE -->|"Bundles"| FE_APP
    EX_DEPLOY -->|"Deploys"| FE_APP

    %% Click Events
    click FE_APP "https://github.com/anhtuan9622/flippl/tree/main/src/"
    click FE_PAGES "https://github.com/anhtuan9622/flippl/tree/main/src/pages"
    click FE_UI_generic "https://github.com/anhtuan9622/flippl/tree/main/src/components/ui"
    click FE_UI_layout "https://github.com/anhtuan9622/flippl/tree/main/src/components/layout"
    click FE_UI_modals "https://github.com/anhtuan9622/flippl/tree/main/src/components/modals"
    click FE_HOOKS "https://github.com/anhtuan9622/flippl/tree/main/src/hooks"
    click FE_ASSETS_logo "https://github.com/anhtuan9622/flippl/blob/main/src/assets/Logo.tsx"
    click FE_PUBLIC "https://github.com/anhtuan9622/flippl/tree/main/public/"
    click FE_CONSTANTS "https://github.com/anhtuan9622/flippl/tree/main/src/constants"
    click FE_SUPA_CLIENT "https://github.com/anhtuan9622/flippl/blob/main/src/lib/supabase.ts"
    click BE_MIGRATIONS "https://github.com/anhtuan9622/flippl/tree/main/supabase/migrations"
    click EX_TAILWIND "https://github.com/anhtuan9622/flippl/blob/main/tailwind.config.js"
    click EX_VITE "https://github.com/anhtuan9622/flippl/blob/main/vite.config.ts"
    click EX_DEPLOY "https://github.com/anhtuan9622/flippl/blob/main/netlify.toml"

    %% Class Definitions
    classDef frontend fill:#DDECF8,stroke:#1F78B4,stroke-width:2px;
    classDef backend fill:#F9E2E2,stroke:#E31A1C,stroke-width:2px;
    classDef external fill:#E3F9E5,stroke:#33A02C,stroke-width:2px;
    classDef config fill:#FFF2CC,stroke:#FF7F0E,stroke-width:2px;
```
