# codeslips/bamboo_growth architecture

> Architecture diagram of the GitHub repository codeslips/bamboo_growth, 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/codeslips/bamboo_growth
- Repository: https://github.com/codeslips/bamboo_growth

## Overview

##### Main System Components

a) Client Layer:
- React Frontend (Vite-based)
- UI Components (Material UI)
- Specialized Media Components (Video.js, Peaks.js)
- WebSocket Connections
- State Management (Context API evident from contexts folder)

b) Server Layer:
- Sanic API Framework
- Authentication System (JWT)
- Course Management
- User Management
- Lesson Management
- File Management

c) External Services:
- Tencent COS (File Storage)
- Database (PostgreSQL with asyncpg)

##### Component Relationships

**[Client Layer] <---> [API Gateway Layer] <---> [Service Layer] <---> [Data Layer]**
- ↑                                              ↑

- >
- (WebSocket Connection for Real-time Features)

##### Detailed Component Breakdown

Frontend Components (Top):
- Course Management (/src/components/course)
- Lesson Management (/src/components/lesson)
- User Management (/src/components/users)
- Media Components (/src/components/media)
- Authentication Context
- WebSocket Context

Backend Services (Middle):
- Course Service (course/)
- Lesson Service (lessons/)
- User Service (user/)
- Resource Service (resources/)
- Authentication Service (utils/auth.py)
- File Management Service (local_file_api/)

Data Layer (Bottom):
- Database (PostgreSQL)
- File Storage (Tencent COS)

##### Flow Indicators

- API calls between frontend and backend
- Database queries
- File storage operations
- WebSocket communications
- Authentication flows

##### Additional Elements

Include:
- Version information
- Technology stack labels
- Security boundaries
- Load balancing indicators (if applicable)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        UI[UI Components]:::frontend
        AuthContext[Authentication Context]:::frontend
        WSContext[WebSocket Context]:::frontend
        
        subgraph FrontendComponents
            CourseComp[Course Management]:::frontend
            LessonComp[Lesson Management]:::frontend
            UserComp[User Management]:::frontend
            MediaComp[Media Components]:::frontend
            ResourceComp[Resource Management]:::frontend
        end
        
        StateManagement[State Management]:::frontend
        APIIntegration[API Integration Layer]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        APIGateway[Sanic API Gateway]:::backend
        
        subgraph Services
            AuthService[Authentication Service]:::security
            CourseService[Course Service]:::backend
            LessonService[Lesson Service]:::backend
            UserService[User Service]:::backend
            FileService[File Management Service]:::backend
            ResourceService[Resource Service]:::backend
        end
        
        DBIntegration[Database Integration]:::backend
    end

    %% External Services
    subgraph External
        DB[(PostgreSQL)]:::database
        TencentCOS[Tencent COS]:::external
    end

    %% Relationships
    UI --> StateManagement
    StateManagement --> APIIntegration
    APIIntegration --> APIGateway
    
    AuthContext --> AuthService
    WSContext --> APIGateway
    
    APIGateway --> Services
    Services --> DBIntegration
    DBIntegration --> DB
    FileService --> TencentCOS

    %% Click Events
    click AuthContext "https://github.com/codeslips/bamboo_growth/blob/main/frontend/src/contexts/AuthContext.js"
    click AuthService "https://github.com/codeslips/bamboo_growth/blob/main/backend/utils/auth.py"
    click CourseComp "https://github.com/codeslips/bamboo_growth/tree/main/frontend/src/components/course/"
    click CourseService "https://github.com/codeslips/bamboo_growth/tree/main/backend/course/"
    click UserComp "https://github.com/codeslips/bamboo_growth/tree/main/frontend/src/components/users/"
    click UserService "https://github.com/codeslips/bamboo_growth/tree/main/backend/user/"
    click LessonComp "https://github.com/codeslips/bamboo_growth/tree/main/frontend/src/components/lesson/"
    click LessonService "https://github.com/codeslips/bamboo_growth/tree/main/backend/lessons/"
    click FileService "https://github.com/codeslips/bamboo_growth/tree/main/backend/local_file_api/"
    click MediaComp "https://github.com/codeslips/bamboo_growth/tree/main/frontend/src/components/media/"
    click WSContext "https://github.com/codeslips/bamboo_growth/blob/main/frontend/src/contexts/WebSocketContext.js"
    click ResourceComp "https://github.com/codeslips/bamboo_growth/blob/main/frontend/src/pages/Resources.js"
    click ResourceService "https://github.com/codeslips/bamboo_growth/tree/main/backend/resources/"
    click StateManagement "https://github.com/codeslips/bamboo_growth/tree/main/frontend/src/contexts/"
    click APIIntegration "https://github.com/codeslips/bamboo_growth/tree/main/frontend/src/api/"
    click APIGateway "https://github.com/codeslips/bamboo_growth/blob/main/backend/routes.py"
    click DBIntegration "https://github.com/codeslips/bamboo_growth/blob/main/backend/database.py"

    %% Legend
    subgraph Legend
        Frontend_L[Frontend]:::frontend
        Backend_L[Backend]:::backend
        External_L[External Service]:::external
        Security_L[Security Component]:::security
        DB_L[(Database)]:::database
    end
```
