# lightning-bounties/lb-next architecture

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

- Interactive diagram: https://gitdiagram.com/lightning-bounties/lb-next
- Repository: https://github.com/lightning-bounties/lb-next

## Overview

##### Main Architecture Components

The system follows a Feature-Sliced Design (FSD) architecture, as evidenced by the numbered folders in the src directory. Here's how to represent the main components:

a) Layer Structure (Top to Bottom):
- App Layer (0_app)
- Pages Layer (1_pages)
- Widgets Layer (2_widgets)
- Features Layer (3_features)
- Entities Layer (4_entities)
- Shared Layer (5_shared)

##### Key Components

Frontend (Next.js Application):
- Authentication System (AuthProvider)
- Theme System (ThemeProvider)
- Query Management (QueryProvider)
- API Integration Layer
- Routing Layer (Next.js Pages)

Backend Integration:
- Authentication Service
- Issues Service
- Rewards Service
- Users Service
- Wallets Service
- Lightning Network Integration

##### Component Relationships

**User Interface Layer**
**↓**
**Features Layer (3_features)**
**↓**
**Entities Layer (4_entities)**
**↓**
**Shared Layer (5_shared)**
**↓**
**External Services**

##### Specific Implementation Details

Create sections for:

a) Frontend Architecture:
- Next.js Pages Router
- React Components Structure
- State Management
- API Integration Layer

b) Authentication Flow:
- Auth Provider
- JWT Token Management
- Interceptors

c) Bitcoin Integration:
- Lightning Network Connection
- Wallet Management
- Transaction Processing

##### Important Notes

- Clear separation between client-side and server-side components
- Authentication flow
- Demonstrate the payment processing flow
- Relationship with GitHub integration
- How the bounty system interacts with both users and repositories

##### Technical Stack Indicators

Technology badges for:
- Next.js
- TypeScript
- Bitcoin Lightning Network
- REST API
- CSS Modules

##### Data Flow Representation

- Payment flows (thick lines)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "App Layer"
        AP["AuthProvider"]:::provider
        TP["ThemeProvider"]:::provider
        QP["QueryProvider"]:::provider
    end

    subgraph "Pages Layer"
        FP["Feed Page"]:::page
        IP["Issue Page"]:::page
        PP["Profile Page"]:::page
        LP["Login Page"]:::page
        MP["Me Page"]:::page
    end

    subgraph "Widgets Layer"
        HW["Header Wallet"]:::widget
    end

    subgraph "Features Layer"
        PD["Profile Deposit"]:::feature
        PW["Profile Withdraw"]:::feature
    end

    subgraph "Entities Layer"
        USER["User Entity"]:::entity
        FEED["Feed Entity"]:::entity
        ISSUE["Issue Entity"]:::entity
        PROF["Profile Entity"]:::entity
        AI["Auth Interceptors"]:::entity
    end

    subgraph "Shared Layer"
        API["API Integration"]:::shared
        MODELS["API Models"]:::shared
        CONFIG["Config"]:::shared
        UI["UI Components"]:::shared
        UTILS["Utils"]:::shared
    end

    subgraph "Backend Services"
        AUTH["Auth Service"]:::service
        ISSUES["Issues Service"]:::service
        REWARDS["Rewards Service"]:::service
        USERS["Users Service"]:::service
        WALLETS["Wallets Service"]:::service
    end

    subgraph "External Services"
        GH["GitHub"]:::external
        LN["Lightning Network"]:::external
    end

    %% Relationships
    AP --> USER
    TP --> UI
    QP --> API

    FP & IP & PP & LP & MP --> API
    HW --> WALLETS
    PD & PW --> WALLETS

    USER --> AI
    AI --> API
    API --> AUTH & ISSUES & REWARDS & USERS & WALLETS
    WALLETS --> LN
    ISSUES --> GH

    %% Click Events
    click AP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/0_app/providers/AuthProvider"
    click TP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/0_app/providers/ThemeProvider"
    click QP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/0_app/providers/QueryProvider"
    click FP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/1_pages/feed"
    click IP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/1_pages/issue"
    click PP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/1_pages/profile"
    click LP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/1_pages/login"
    click MP "https://github.com/Lightning-Bounties/lb-next/tree/master/src/1_pages/me"
    click HW "https://github.com/Lightning-Bounties/lb-next/tree/master/src/2_widgets/header/headerWallet"
    click PD "https://github.com/Lightning-Bounties/lb-next/tree/master/src/3_features/me/profileDeposit"
    click PW "https://github.com/Lightning-Bounties/lb-next/tree/master/src/3_features/me/profileWithdraw"
    click USER "https://github.com/Lightning-Bounties/lb-next/tree/master/src/4_entities/user"
    click FEED "https://github.com/Lightning-Bounties/lb-next/tree/master/src/4_entities/feed"
    click ISSUE "https://github.com/Lightning-Bounties/lb-next/tree/master/src/4_entities/issue"
    click PROF "https://github.com/Lightning-Bounties/lb-next/tree/master/src/4_entities/profile"
    click AI "https://github.com/Lightning-Bounties/lb-next/blob/master/src/4_entities/user/interceptors/auth.intercerptors.ts"
    click API "https://github.com/Lightning-Bounties/lb-next/blob/master/src/5_shared/api/app.api.ts"
    click MODELS "https://github.com/Lightning-Bounties/lb-next/tree/master/src/5_shared/gen/models"
    click CONFIG "https://github.com/Lightning-Bounties/lb-next/tree/master/src/5_shared/config"
    click UI "https://github.com/Lightning-Bounties/lb-next/tree/master/src/5_shared/ui"
    click UTILS "https://github.com/Lightning-Bounties/lb-next/tree/master/src/5_shared/utils"
    click AUTH "https://github.com/Lightning-Bounties/lb-next/blob/master/src/5_shared/gen/services/AuthService.ts"
    click ISSUES "https://github.com/Lightning-Bounties/lb-next/blob/master/src/5_shared/gen/services/IssuesService.ts"
    click REWARDS "https://github.com/Lightning-Bounties/lb-next/blob/master/src/5_shared/gen/services/RewardsService.ts"
    click USERS "https://github.com/Lightning-Bounties/lb-next/blob/master/src/5_shared/gen/services/UsersService.ts"
    click WALLETS "https://github.com/Lightning-Bounties/lb-next/blob/master/src/5_shared/gen/services/WalletsService.ts"

    %% Styles
    classDef provider fill:#a8dadc,stroke:#457b9d
    classDef page fill:#457b9d,stroke:#1d3557,color:#fff
    classDef widget fill:#e63946,stroke:#1d3557
    classDef feature fill:#f1faee,stroke:#1d3557
    classDef entity fill:#fca311,stroke:#14213d
    classDef shared fill:#8338ec,stroke:#3a0ca3,color:#fff
    classDef service fill:#2a9d8f,stroke:#264653
    classDef external fill:#e76f51,stroke:#264653
```
