# streamfi-x/streamfi-community architecture

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

- Interactive diagram: https://gitdiagram.com/streamfi-x/streamfi-community
- Repository: https://github.com/streamfi-x/streamfi-community

## Overview

##### Project type and purpose
- This is a decentralized Web3 “community layer” frontend built in Next.js (React), focused on enabling social interactions, DAO governance, user forums, leaderboards, billing/rewards, and profile/settings pages.
- It has no custom backend; instead it leverages client-side calls (via Wagmi/RainbowKit) to smart contracts on Ethereum/Polygon (or other EVM chains).

##### File structure
- Top-level:
- next.config.mjs, tsconfig.json, ESLint/Tailwind configs – Next.js+TypeScript setup
- public/fonts + global CSS → static assets
- src/app/… → Next.js 13 App Router pages (billing, forums, leaderboard, profile, settings, weekly-highlights)
- src/components/ui → ShadCN UI primitives (button, input, dialog, dropdown, etc.)
- src/components/navbar.tsx → main navigation
- src/lib/utils.ts → shared helper functions
- No /api directory or backend code—app is purely frontend + on-chain interactions.

##### Key architectural patterns & technologies (from README)
- Next.js 13 App Router → server components + client components
- Tailwind CSS + ShadCN UI for styling & reusable UI primitives
- Wagmi + Zustand for on-chain state management
- RainbowKit/Web3Modal for wallet connection
- Solidity smart contracts deployed to Ethereum/Polygon (interfaced via RPC providers like Infura/Alchemy)

##### Main components
a. Users & Browsers
b. Next.js Application (hosted on Vercel/Netlify or similar)
- Server-Side Rendering layer (App Router server components)
- Client components (React + Zustand state)
- UI Component Library (ShadCN primitives + Tailwind)
- Page modules: Billing, Forums, Leaderboard, Profile, Settings, Weekly Highlights
c. Wallet Connector (RainbowKit/Web3Modal)
d. On-chain Integration (Wagmi hooks → RPC Provider)
e. Blockchain Networks (Ethereum, Polygon, other EVM)
f. Smart Contracts (DAO voting, rewards, forums storage)
g. External RPC Providers (Infura, Alchemy)

##### Relationships and data flow
- Browsers load pages from Next.js server (SSR or static).
- Client-side React code initializes wallet connection via RainbowKit → user wallet.
- Wagmi/Zustand manage user session and on-chain state.
- When user interacts (vote, post, claim reward), Wagmi sends transactions to RPC provider → blockchain → smart contracts.
- Smart contracts emit events; front-end can listen (via Wagmi/Providers).

##### Architectural patterns & design principles
- Separation of concerns: Server Components vs. Client Components
- UI primitives encapsulated in a design system (ShadCN + Tailwind)
- Unidirectional data flow: React state → Wagmi calls → blockchain → event listeners → update state
- Stateless server hosting; state lives in wallets, contracts, and client stores

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global Entities
    Browser["User Browser"]:::external

    %% Next.js Server Layer
    subgraph "Next.js Server (App Router)" 
        direction TB
        AppRouter["Next.js Application\n(src/app/)"]:::frontend
        Globals["Global Stylesheet\n(src/app/globals.css)"]:::frontend
        Layout["App Layout\n(src/app/layout.tsx)"]:::frontend
        Home["Home Page\n(src/app/page.tsx)"]:::frontend
    end

    %% Page Modules
    subgraph "Page Modules" 
        direction TB
        Billing["Billing Page\n(src/app/pages/billing/page.tsx)"]:::frontend
        Forums["Forums Page\n(src/app/pages/forums/page.tsx)"]:::frontend
        Leaderboard["Leaderboard Page\n(src/app/pages/leaderboard/page.tsx)"]:::frontend
        Profile["Profile Page\n(src/app/pages/profile/page.tsx)"]:::frontend
        Settings["Settings Page\n(src/app/pages/settings/page.tsx)"]:::frontend
        Weekly["Weekly Highlights\n(src/app/pages/weekly-highlights/page.tsx)"]:::frontend
    end

    %% UI Library & Components
    subgraph "Design System (UI Library)" 
        direction TB
        UIlib["ShadCN & Tailwind Primitives\n(src/components/ui/)"]:::ui
        Avatar["avatar.tsx"]:::ui
        Button["button.tsx"]:::ui
        Dialog["dialog.tsx"]:::ui
        Dropdown["dropdown-menu.tsx"]:::ui
        Input["input.tsx"]:::ui
        Scroll["scroll-area.tsx"]:::ui
    end

    Navbar["Navigation Bar\n(src/components/navbar.tsx)"]:::ui
    Utils["Utils\n(src/lib/utils.ts)"]:::integration

    %% Client & State
    ReactClient["React Client Components"]:::frontend
    WalletConnector["Wallet Connector\n(RainbowKit/Web3Modal)"]:::integration
    Wagmi["Wagmi + Zustand"]:::integration

    %% Blockchain & Integrations
    RPC["RPC Providers\n(Infura, Alchemy)"]:::external
    subgraph "Blockchain Networks" 
        direction TB
        Ethereum["Ethereum"]:::blockchain
        Polygon["Polygon"]:::blockchain
        OtherEVM["Other EVM Chains"]:::blockchain
    end
    subgraph "Smart Contracts" 
        direction TB
        DAO["DAO Voting Contract"]:::blockchain
        Rewards["Rewards Contract"]:::blockchain
        ForumsContract["Forums Storage Contract"]:::blockchain
    end
    Indexer["On-chain Data Indexer (optional)"]:::external

    %% Connections
    Browser -->|"Initial Load"| AppRouter
    AppRouter -->|"SSR Response"| Browser
    Browser --> ReactClient

    ReactClient --> Navbar
    ReactClient --> UIlib
    UIlib --> Avatar
    UIlib --> Button
    UIlib --> Dialog
    UIlib --> Dropdown
    UIlib --> Input
    UIlib --> Scroll
    ReactClient --> Utils
    ReactClient --> Billing
    ReactClient --> Forums
    ReactClient --> Leaderboard
    ReactClient --> Profile
    ReactClient --> Settings
    ReactClient --> Weekly

    ReactClient --> WalletConnector
    ReactClient --> Wagmi
    WalletConnector --> RPC
    Wagmi --> RPC

    RPC --> Ethereum
    RPC --> Polygon
    RPC --> OtherEVM

    Ethereum --> DAO
    Polygon --> Rewards
    OtherEVM --> ForumsContract

    Ethereum -->|Events| RPC
    Polygon -->|Events| RPC
    OtherEVM -->|Events| RPC
    RPC -->|Data| ReactClient

    ReactClient -->|Tx Calls| RPC
    RPC -->|Invoke| SmartContracts

    Indexer -->|Indexed Data| ReactClient

    %% Click Events
    click AppRouter "https://github.com/streamfi-x/streamfi-community/tree/main/src/app/"
    click Globals "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/globals.css"
    click Layout "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/layout.tsx"
    click Home "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/page.tsx"
    click Billing "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/pages/billing/page.tsx"
    click Forums "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/pages/forums/page.tsx"
    click Leaderboard "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/pages/leaderboard/page.tsx"
    click Profile "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/pages/profile/page.tsx"
    click Settings "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/pages/settings/page.tsx"
    click Weekly "https://github.com/streamfi-x/streamfi-community/blob/main/src/app/pages/weekly-highlights/page.tsx"
    click UIlib "https://github.com/streamfi-x/streamfi-community/tree/main/src/components/ui/"
    click Navbar "https://github.com/streamfi-x/streamfi-community/blob/main/src/components/navbar.tsx"
    click Utils "https://github.com/streamfi-x/streamfi-community/blob/main/src/lib/utils.ts"
    click Ethereum "https://github.com/streamfi-x/streamfi-community/tree/main/public/fonts/"
    click NextConfig "https://github.com/streamfi-x/streamfi-community/blob/main/next.config.mjs"
    click TailwindConfig "https://github.com/streamfi-x/streamfi-community/blob/main/tailwind.config.ts"
    click Tsconfig "https://github.com/streamfi-x/streamfi-community/blob/main/tsconfig.json"
    click ESLintConfig "https://github.com/streamfi-x/streamfi-community/blob/main/.eslintrc.json"

    %% Styles
    classDef frontend fill:#CFE2F3,stroke:#0366d6,color:#0366d6
    classDef ui fill:#D9EAD3,stroke:#6AA84F,color:#274E13
    classDef integration fill:#E2EFDA,stroke:#6AA84F,color:#38761D
    classDef blockchain fill:#D9D2E9,stroke:#674EA7,color:#351C75
    classDef external fill:#F2F2F2,stroke:#A0A0A0,color:#636363
```
