# vencc/game architecture

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

- Interactive diagram: https://gitdiagram.com/vencc/game
- Repository: https://github.com/vencc/game

## Overview

##### Project type and purpose
- This is a standalone Java-based online Gomoku (五子棋) client application with optional local human-AI play and an online multiplayer mode.
- No heavy frameworks are used—just core Java, Swing for UI, JDBC for database access, and sockets for networking.

##### File structure
- Top-level “src” contains packages:
- chess – Swing UI forms, main entry point, game table and lobby screens
- dao – Database access layer (BaseDao, IUserDao)
- entity – Domain models (User, RoomPojo, UpdatePicture)
- msg – Message definitions (Client* and Server* classes for every action/event)
- net – Networking layer (MyClient, MyServer)
- util – Utility classes (AudioPlayer, ChessImpl, UI renderers)
- “resource” holds static assets: audio clips, images, SQL script, third-party jars (MySQL connector, mail libs).
- README describes two modes: local human-robot game and online mode (requires MySQL user table and configuration in BaseDao/MyClient).

##### README
- Explains overall function, dependencies (database, IP), and no additional frameworks.

7. Every critical path—login, room listing, move exchange, game over—is represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Main["Main"]:::ui
        Home["Home"]:::ui
        ChessTable["ChessTable"]:::ui
        RoomList["RoomList"]:::ui
        Room["Room"]:::ui
        NameDialog["NameDialog"]:::ui
        Personal["Personal"]:::ui
        WinNumFrame["WinNumFrame"]:::ui
        SendmailFrame["SendmailFrame"]:::ui
    end

    %% Game Logic Layer
    subgraph "Game Logic Layer"
        direction TB
        IChess["IChess"]:::logic
        ChessImpl["ChessImpl"]:::logic
        HumanThread["HumanThread"]:::logic
        RobotThread["RobotThread"]:::logic
    end

    %% Networking Layer
    subgraph "Networking Layer"
        direction TB
        MyClient["MyClient"]:::network
        MyServer["MyServer"]:::network
        MsgPkg["Message Classes (Client*/Server*)"]:::network
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        BaseDao["BaseDao"]:::persistence
        IUserDao["IUserDao"]:::persistence
        IUserDaoImp["IUserDaoImp"]:::persistence
        User["User"]:::persistence
        RoomPojo["RoomPojo"]:::persistence
        UpdatePicture["UpdatePicture"]:::persistence
        DB["MySQL Database"]:::database
    end

    %% Media Layer
    subgraph "Media Layer"
        direction TB
        AudioPlayer["AudioPlayer"]:::media
        AudioFiles[".wav Files"]:::media
        Images["GUI Images"]:::media
    end

    %% External Services
    subgraph "External Services"
        direction TB
        MailLibs["JavaMail Libraries"]:::external
    end

    %% Connections
    Main -->|"user actions"| IChess
    Home -->|invokes| ChessImpl
    ChessTable -->|renders| ChessImpl
    RoomList -->|requests| MyClient
    ChessImpl -->|starts| HumanThread
    ChessImpl -->|starts| RobotThread
    IChess -->|defines| ChessImpl

    ChessImpl -->|serializes ClientMovePieces| MsgPkg
    MyClient -->|sends/receives| MsgPkg
    MsgPkg -->|to/from| MyServer
    MyClient -->|login/register calls| BaseDao
    BaseDao -->|JDBC calls| DB
    IUserDaoImp -->|implements| IUserDao
    IUserDaoImp -->|CRUD| DB

    ChessImpl -->|plays sound| AudioPlayer
    AudioPlayer -->|loads| AudioFiles
    ChessTable -->|loads| Images

    SendmailFrame -->|uses| MailLibs

    %% Click Events
    click Main "https://github.com/vencc/game/blob/master/src/chess/Main.java"
    click Home "https://github.com/vencc/game/blob/master/src/chess/Home.java"
    click ChessTable "https://github.com/vencc/game/blob/master/src/chess/ChessTable.java"
    click RoomList "https://github.com/vencc/game/blob/master/src/chess/RoomList.java"
    click Room "https://github.com/vencc/game/blob/master/src/chess/Room.java"
    click NameDialog "https://github.com/vencc/game/blob/master/src/chess/NameDialog.java"
    click Personal "https://github.com/vencc/game/blob/master/src/chess/Personal.java"
    click WinNumFrame "https://github.com/vencc/game/blob/master/src/chess/WinNumFrame.java"
    click SendmailFrame "https://github.com/vencc/game/blob/master/src/chess/SendmailFrame.java"

    click IChess "https://github.com/vencc/game/blob/master/src/util/IChess.java"
    click ChessImpl "https://github.com/vencc/game/blob/master/src/util/ChessImpl.java"
    click HumanThread "https://github.com/vencc/game/blob/master/src/chess/HumanThread.java"
    click RobotThread "https://github.com/vencc/game/blob/master/src/chess/RobotThread.java"

    click MyClient "https://github.com/vencc/game/blob/master/src/net/MyClient.java"
    click MyServer "https://github.com/vencc/game/blob/master/src/net/MyServer.java"
    click MsgPkg "https://github.com/vencc/game/tree/master/src/msg"

    click BaseDao "https://github.com/vencc/game/blob/master/src/dao/BaseDao.java"
    click IUserDao "https://github.com/vencc/game/blob/master/src/dao/IUserDao.java"
    click IUserDaoImp "https://github.com/vencc/game/blob/master/src/dao/IUserDaoImp.java"
    click User "https://github.com/vencc/game/blob/master/src/entity/User.java"
    click RoomPojo "https://github.com/vencc/game/blob/master/src/entity/RoomPojo.java"
    click UpdatePicture "https://github.com/vencc/game/blob/master/src/entity/UpdatePicture.java"

    click AudioPlayer "https://github.com/vencc/game/blob/master/src/util/AudioPlayer.java"
    click AudioFiles "https://github.com/vencc/game/tree/master/resource/audio"
    click Images "https://github.com/vencc/game/tree/master/resource/imag"

    click MailLibs "https://github.com/vencc/game/tree/master/resource/lib"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef logic fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef network fill:#ffdead,stroke:#333,stroke-width:1px
    classDef persistence fill:#ffffcc,stroke:#333,stroke-width:1px
    classDef media fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef database fill:#ffd1dc,stroke:#333,stroke-width:1px,shape:cylinder
```
