# @tencentcloud/chat SDK v3.6.6 — Code Structure Map

> Annotated and formatted for readability. Logic 100% preserved from ESM distribution.

## Quick Navigation

### Core Infrastructure

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `s` | — | L157-181 | 25 | Middleware chain |
| `i` | — | L182-202 | 21 | Uint64 implementation |
| `ni` | — (extends Error) | L3227-3243 | 17 | SDK custom error |
| `ui` | — | L3381-3460 | 80 | **Module base class** (all `extends ui` inherit this) |
| `Mo` | **SocketHandler** | L18135-18685 | **551** | WebSocket connection, reconnection, heartbeat |
| `To` | **PHandler** | L18964-22460 | **3497** | Protocol handler — frame serialize/deserialize |
| `vo` | **MsgDispatcher** | L22462-22797 | 336 | Routes incoming WS messages to modules |
| `Pr` | **ModuleManager** | L27279-27690 | 412 | Central registry — instantiates all modules |
| `Gr` | — | L27770-28854 | 1085 | **Main SDK class** (TencentCloudChat instance) |

### Messaging

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `Qi` | **C2CModule** | L5031-5896 | 866 | One-to-one private chat |
| `tn` | **MsgListHandler** | L5904-6342 | 439 | Message list storage & pagination |
| `Xn` | **MessageModule** | L15343-16350 | **1008** | Core message create/send/receive |
| `Yn` | MergerMessageHandler | L15076-15312 | 237 | Combined message handling |
| `Zn` | MsgExtModule | L16351-16752 | 402 | Message extensions |
| `Qn` | MsgReactionModule | L16753-17172 | 420 | Message reactions (emoji) |
| `eo` | ComboMsgModule | L17173-17370 | 198 | Combo message handling |
| `so` | SyncUnreadMsgModule | L17392-17499 | 108 | Unread message sync |

### Conversations

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `fn` | MsgRemindHandler | L6873-7134 | 262 | Message notification settings |
| `Mn` | **ConvGroupHandler** | L7135-8124 | 990 | Conversation group (folder) management |
| `In` | **ConvModule** | L8125-10961 | **2837** | Conversation list, unread counts |

### Groups & Topics

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `vn` | TopicModule | L11067-11768 | 702 | Community topic (sub-channel) |
| `Co` | ChannelModule | L18745-18963 | 219 | Channel/Room messaging |

### User & Profile

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `Sn` | ProfileHandler | L11769-12222 | 454 | User profile management |
| `Dn` | BlacklistHandler | L12231-12384 | 154 | Blocklist |
| `Ln` | UserStatusHandler | L12400-12669 | 270 | Online/offline status |
| `An` | UserModule | L12670-12798 | 129 | User operations |

### Auth & Session

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `Pn` | SignModule | L13042-13354 | 313 | Authentication signing |
| `Lo` | **SessionModule** | L22904-23260 | 357 | Login/logout lifecycle |

### Upload & Media

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `Wn` | **UploadModule** | L14043-15075 | 1033 | File/image/video upload to COS |

### Quality & Monitoring

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `Di` | SSOLogData | L3666-3812 | 147 | SSO log entry |
| `bn` | EventStatModule | L13576-13703 | 128 | Event statistics |
| `qn` | NetMonitorModule | L13706-13823 | 118 | Network monitoring |
| `No` | AvgE2EDelay | L23620-23707 | 88 | End-to-end delay metric |
| `Po` | AvgRTT | L23708-23774 | 67 | Round-trip time metric |
| `ko` | QualityStatModule | L24015-24226 | 212 | Quality statistics |
| `wo` | WorkerTimerModule | L24227-24298 | 72 | Web Worker timer |

### Plugins & Extensions

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `to` | PluginModule | L17371-17391 | 21 | Plugin registration |
| `bo` | PurchasedFeatureHandler | L24299-24401 | 103 | Feature gating |
| `Fo` | CommercialConfigModule | L24402-24500 | 99 | Commercial config |
| `qo` | TIMPushModule | L24767-25114 | 348 | Push notifications |
| `xo` | ProfanityFilterModule | L25115-25321 | 207 | Content moderation |
| `Ao` | CloudControlModule | L23261-23383 | 123 | Cloud config |
| `Gn` | StorageModule | L13358-13531 | 174 | Local storage |

### Other

| Class | Module Name | Lines | Size | Purpose |
|-------|-------------|-------|------|---------|
| `Oo` | RecoverMsgModule | L23384-23619 | 236 | Message recovery |
| `Vo` | TransCmdModule | L25322-25398 | 77 | Translation commands |
| `Bo` | ErrMsgModule | L25399-25568 | 170 | Error message mapping |
| `Nr` | InflateModule | L27240-27278 | 39 | Data decompression |
| `Ur` | SafetyCallback | L27691-27769 | 79 | Safe callback wrapper |

---

## Key Top-Level Variables

| Variable | Lines | Size | Purpose |
|----------|-------|------|---------|
| `e` | L1-39 | 39 | **EVENT** enum — all SDK event names |
| `t` | L40-156 | 117 | **TYPES** enum — message/group/conversation types |
| `n` | L203-317 | 115 | WebSocket server addresses by region |
| `o` | L318-333 | 16 | Platform IDs |
| `r` | L334 | 1 | SDK version: `"1.7.3"` |
| `a` | L335 | 1 | Build number: `537048168` |
| `f` | L345-392 | 48 | Server host config (current host, service names) |
| `M` | L393-412 | 20 | Feature capability bitfields |
| `Ee` | L563-643 | 81 | **Logger** (d/l/i/w/e methods, level control) |
| `Ts` | L1453-3035 | **1583** | **API command definitions** (wslogin, sendmsg, etc.) |
| `ys` | L3036-3186 | 151 | **Error codes** (NO_SDKAPPID, NETWORK_TIMEOUT, etc.) |
| `dr` | L26129-26948 | 820 | **SDK factory** — creates TencentCloudChat instances |

## Key Patch Points

| Line | Content | Clawlink Usage |
|------|---------|----------------|
| L514 | `globalThis.__CLAWLINK_SDK_LOGGER` | Logger injection — redirects SDK logs to file |
| L18135 | `class Mo` (SocketHandler) | WebSocket timeout/reconnect behavior |
| L18148 | `MAX_RECONNECT_COUNT = 3` | Max reconnection attempts |
| L5031 | `class Qi` (C2CModule) | Private messaging logic |

---

## External Modules (in `modules/` directory)

| File | Formatted Lines | Classes | Purpose |
|------|-----------------|---------|---------|
| `group-module.js` | 6,078 | 28 | Group create/join/quit/update + member mgmt |
| `relationship-module.js` | 1,981 | 11 | Friend add/delete/check + friend groups |
| `signaling-module.js` | 1,272 | 7 | Invite/accept/reject signaling |
| `cloud-search-module.js` | 999 | 5 | Cloud message/group/user search |
| `follow-module.js` | 935 | 4 | Follow/unfollow user relationships |
