# chowa/ejyy architecture

> Architecture diagram of the GitHub repository chowa/ejyy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chowa/ejyy
- Repository: https://github.com/chowa/ejyy

## Overview

##### High-Level Architecture Overview

**[Client Layer]**
- WeChat Mini Programs (业主端/owner-mp, 物业端/property-mp)
- Web Console (console-web)
- WeChat Public Account
- IoT Devices

**[API Layer]**
- API Server (api-server)
- WebSocket Server (wss)
- Notification Services

**[Infrastructure Layer]**
- Database
- Redis Cache
- File Storage (OSS)
- WeChat Services

##### Detailed Component Breakdown

**[API Modules]**
- User Management (/module/pc/controller/user)
- Community Management (/module/pc/controller/community_manage)
- Property Management
- Repair Service
- Complaint Handling
- Payment Processing
- Access Control
- IoT Integration
- Elevator Control
- Energy Management
- Entrance Systems
- Parking Systems

##### Data Flow Representation

**[Client Apps] ←→ [API Gateway]**
- ↕
**[Authentication] ←→ [Core Services] ←→ [External Services]**
- ↕
- [Data Storage]

##### Key Technical Elements to Highlight

- Authentication & Authorization System
- Real-time Communication (WebSocket)
- File Storage System
- Payment Integration
- IoT Device Management
- Notification System

##### Specific Implementation Details

Technical stack information:
- Backend: Koa + TypeScript
- Frontend: Vue + View Design
- Database: MySQL
- Cache: Redis
- File Storage: OSS
- Real-time: WebSocket

##### Security Layer

Security implementations:
- Authentication middleware
- Role-based access control
- API security
- Data encryption

##### Integration Points

External service integrations:
- WeChat API
- Payment gateways
- IoT platforms
- SMS services

##### Data flow between components

Remember to:
- Use consistent notation
- Brief descriptions for complex components
- Both synchronous and asynchronous communication paths

This will provide a comprehensive view of the system while maintaining clarity and usefulness for technical discussions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef client fill:#2374AB,color:#fff
    classDef api fill:#45B7D1,color:#fff
    classDef infrastructure fill:#48A14D,color:#fff
    classDef security fill:#D64045,color:#fff
    classDef module fill:#D1AC00,color:#fff
    classDef integration fill:#9B6B8E,color:#fff

    %% Client Layer
    subgraph Clients
        WO["Owner WeChat Mini Program"]:::client
        WP["Property WeChat Mini Program"]:::client
        WC["Web Console"]:::client
        WPA["WeChat Public Account"]:::client
        IOT["IoT Devices"]:::client
    end

    %% API Layer
    API["API Server"]:::api
    WSS["WebSocket Server"]:::api
    NOTIFY["Notification Services"]:::api

    %% Infrastructure Layer
    subgraph Infrastructure
        DB[(Database)]:::infrastructure
        REDIS[(Redis Cache)]:::infrastructure
        OSS["File Storage (OSS)"]:::infrastructure
        WECHAT["WeChat Services"]:::infrastructure
    end

    %% Core Modules
    subgraph Modules
        UM["User Management"]:::module
        CM["Community Management"]:::module
        
        subgraph PropertyManagement
            RS["Repair Service"]:::module
            CH["Complaint Handling"]:::module
            PP["Payment Processing"]:::module
            AC["Access Control"]:::module
        end

        subgraph IoTIntegration
            EC["Elevator Control"]:::integration
            EM["Energy Management"]:::integration
            ES["Entrance Systems"]:::integration
            PS["Parking Systems"]:::integration
        end
    end

    %% Security Layer
    AUTH["Authentication & Authorization"]:::security

    %% Relationships
    Clients --> API
    Clients --> WSS
    API --> AUTH
    AUTH --> Modules
    Modules --> DB
    Modules --> REDIS
    Modules --> OSS
    API --> NOTIFY
    IoTIntegration --> IOT
    API --> WECHAT

    %% Click Events
    click WO "https://github.com/chowa/ejyy/tree/master/owner-mp"
    click WP "https://github.com/chowa/ejyy/tree/master/property-mp"
    click WC "https://github.com/chowa/ejyy/tree/master/console-web"
    click API "https://github.com/chowa/ejyy/blob/master/api-server/src/app.ts"
    click WSS "https://github.com/chowa/ejyy/tree/master/api-server/src/wss"
    click NOTIFY "https://github.com/chowa/ejyy/tree/master/api-server/src/module/notify"
    click UM "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/user"
    click CM "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/community_manage"
    click RS "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/repair"
    click CH "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/complain"
    click PP "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/payment"
    click AC "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/access"
    click EC "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/elevator"
    click EM "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/energy"
    click ES "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/entrance"
    click PS "https://github.com/chowa/ejyy/tree/master/api-server/src/module/pc/controller/park"
    click AUTH "https://github.com/chowa/ejyy/tree/master/api-server/src/middleware"
    click OSS "https://github.com/chowa/ejyy/blob/master/api-server/src/service/oss.ts"
    click DB "https://github.com/chowa/ejyy/tree/master/api-server/src/model"
```
