# thestartupdeveloper10/theboardfc architecture

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

- Interactive diagram: https://gitdiagram.com/thestartupdeveloper10/theboardfc
- Repository: https://github.com/thestartupdeveloper10/theboardfc

## Overview

##### Project type and purpose
- This is a full-stack web application whose public UI is built with React (TypeScript/TSX), Vite, Tailwind CSS, PostCSS and which uses Supabase as its backend (Auth, Database, Storage, Edge Functions).
- It provides a public facing “fan” site (pages like Home, Fixtures, News, FanZone, PlayerStats, Contact) and an authenticated admin console (Dashboard, content and player/match/notification management).
- It also integrates with an external email service via EmailJS for contact forms and notification delivery.

##### File structure
Top-level directories
- src/ – React entry point (main.tsx), components, pages, hooks, context, config, lib, services (API queries and mutations), assets, styles, types
- public/ + index.html – static entry, images & favicon
- supabase/ – database config (config.toml), edge functions (send-team-notification)
- docs/ – operational docs (email setup, etc.)
- config files – vite.config.ts, tailwind.config.js, tsconfig.json, postcss.config.js
- package.json + lock – project dependencies & scripts

Key patterns
- Component-based UI with a shared ui/ library (buttons, dialogs, cards) and layout & ProtectedRoute wrapper
- Client-side routing with page components under src/pages (public vs admin sub-folder)
- API layer in src/services interacting with Supabase client in src/lib/supabase.ts
- AuthContext providing user session state & ProtectedRoute enforcing admin access
- Supabase Edge Function for sending notifications to subscribed users

##### Architecture notes (from README or docs)
- development-plan.md may hint at deployment or staging environments

a. Main components
– Web Client (React SPA)
– Static hosting/CDN (e.g., Netlify, Vercel, S3+CloudFront)
– Supabase Backend
- Auth service (signup, sign-in, session management)
- Database (tables for users, players, matches, news, contacts, stats)
- Storage (images, assets)
- Edge Functions (send-team-notification)
– External Email Service (EmailJS)

b. Relationships and data flow
1. Browser → Static Hosting → serves React bundle and assets
2. React SPA → Supabase Auth for login/sign-up
3. React SPA → Supabase Database via client-side API (queries & mutations)
4. React SPA → Supabase Storage for image uploads (e.g., merch, fan photos)
5. React SPA → EmailJS (contact form posting)
6. Database triggers or admin actions → Supabase Edge Function → sends notifications via EmailJS or other provider

c. Architectural patterns and principles
- Single Page Application (SPA) with clear public vs protected (admin) routes
- Separation of concerns: UI components, layout, data services, context for cross-cutting concerns (auth, theme, toast)
- Client-side state minimal; rely on Supabase for real-time updates or fetch-on-render
- Serverless backend using managed services (Supabase + Edge Functions)

d. Key technologies and frameworks
- React (TSX), Vite (bundler), Tailwind CSS (styling)
- Supabase (PostgreSQL, Auth, Storage, Edge Functions)
- EmailJS (SMTP/email API)
- TypeScript for type safety across client & serverless functions
- PostCSS, Tailwind config for styling pipeline

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Side
    subgraph "Web Client (React SPA)" 
        direction TB
        Browser["Browser"]:::client
        Browser -->|loads| StaticHost
        subgraph "SPA"
            direction TB
            MainTS["Entry Point\nsrc/main.tsx"]:::client
            AppTS["App Component\nsrc/App.tsx"]:::client
            subgraph "Pages"
                direction TB
                PublicPages["Public Pages\nsrc/pages/*.tsx"]:::client
                AdminPages["Admin Pages\nsrc/pages/admin/*.tsx"]:::client
            end
            subgraph "Components"
                direction TB
                UIComp["UI Library\nsrc/components/ui"]:::client
                LayoutComp["Layout\nsrc/components/layout"]:::client
                Protected["ProtectedRoute\nsrc/components/layout/ProtectedRoute.tsx"]:::client
                Scroll["ScrollToTop\nsrc/components/ScrollToTop.tsx"]:::client
            end
            subgraph "Context & Config"
                direction TB
                AuthCtx["AuthContext\nsrc/context/AuthContext.tsx"]:::client
                EmailCfg["EmailJS Config\nsrc/config/emailjs.ts"]:::client
                SupaClient["Supabase Client\nsrc/lib/supabase.ts"]:::client
            end
            subgraph "Services"
                direction TB
                API["API Layer\nsrc/services/api.ts"]:::client
                Queries["Queries\nsrc/services/queries.ts"]:::client
                Mutations["Mutations\nsrc/services/mutations.ts"]:::client
            end
            subgraph "Assets & Styles"
                direction TB
                Assets["Assets\nsrc/assets/images"]:::client
                Styles["Styles\nglobals.css,\ntailwind.config.js,\npostcss.config.js"]:::client
            end
        end
    end

    %% Hosting/CDN
    StaticHost["Static Hosting/CDN\n(e.g., Vercel)"]:::external

    %% Backend Supabase
    subgraph "Supabase" 
        direction TB
        AuthSrv["Auth Service"]:::backend
        DB["Database\n(PostgreSQL)"]:::backend
        Storage["Storage"]:::backend
        subgraph "Edge Functions"
            direction TB
            NotifyFunc["send-team-notification\nsupabase/functions/send-team-notification/index.ts"]:::function
        end
    end

    %% External Email Service
    EmailSvc["EmailJS Service"]:::external

    %% Documentation
    DocsEmail["Email Setup Docs\ndocs/email-setup.md"]:::external
    DevPlan["Dev & Deployment\n development-plan.md"]:::external

    %% Connections
    Browser -->|react router| MainTS
    MainTS --> AppTS
    AppTS --> PublicPages
    AppTS --> AdminPages
    AppTS --> LayoutComp
    LayoutComp --> UIComp
    AppTS --> Protected
    AppTS --> Scroll
    AppTS --> AuthCtx
    AppTS --> SupaClient
    SupaClient --> AuthSrv
    SupaClient --> DB
    SupaClient --> Storage
    AppTS --> API
    API --> Queries
    API --> Mutations
    Queries --> DB
    Mutations --> DB
    Storage -->|uploads/downloads| Assets
    AppTS --> EmailSvc
    EmailSvc -->|via EmailJS Config| EmailCfg
    DB -->|trigger| NotifyFunc
    NotifyFunc --> EmailSvc
    StaticHost -->|serves| Browser

    %% Click events
    click MainTS "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/main.tsx"
    click AppTS "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/App.tsx"
    click PublicPages "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/pages/*.tsx"
    click AdminPages "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/pages/admin/*.tsx"
    click UIComp "https://github.com/thestartupdeveloper10/theboardfc/tree/main/src/components/ui"
    click LayoutComp "https://github.com/thestartupdeveloper10/theboardfc/tree/main/src/components/layout"
    click Protected "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/components/layout/ProtectedRoute.tsx"
    click Scroll "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/components/ScrollToTop.tsx"
    click SupaClient "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/lib/supabase.ts"
    click API "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/services/api.ts"
    click Queries "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/services/queries.ts"
    click Mutations "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/services/mutations.ts"
    click AuthCtx "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/context/AuthContext.tsx"
    click EmailCfg "https://github.com/thestartupdeveloper10/theboardfc/blob/main/src/config/emailjs.ts"
    click Assets "https://github.com/thestartupdeveloper10/theboardfc/tree/main/src/assets/images"
    click Styles "https://github.com/thestartupdeveloper10/theboardfc/blob/main/tailwind.config.js"
    click DocsEmail "https://github.com/thestartupdeveloper10/theboardfc/blob/main/docs/email-setup.md"
    click DevPlan "https://github.com/thestartupdeveloper10/theboardfc/blob/main/development-plan.md"

    %% Styles
    classDef client fill:#cce5ff,stroke:#4a90e2,color:#000
    classDef backend fill:#d4edda,stroke:#28a745,color:#000
    classDef function fill:#fff3cd,stroke:#ffc107,color:#000
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000
```
