MCPcopy Index your code
hub / github.com/dhij/go-next-ts_chat

github.com/dhij/go-next-ts_chat @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
71 symbols 126 edges 24 files 0 documented · 0% updated 3y ago★ 1342 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Realtime Chat

This is a realtime chat built with Go, Next, and Typescript.

The tutorial is available here

Hub Architecture

Initial Hub Architecture

First, we have the hub running on a separate goroutine which is the central place that manages different channels and contains a map of rooms. The hub has a Register and an Unregister channel to register/unregister clients, and a Broadcast channel that receives a message and broadcasts it out to all the other clients in the same room.

Client joins room

A room is initially empty. Only when a client hits the /ws/joinRoom endpoint, that will create a new client object in the room and it will be registered through the hub's Register channel.

Hub Architecture

Each client has a writeMessage and a readMessage method. readMessage reads the message through the client's websocket connection and send the message to the Broadcast channel in the hub, which will then broadcast the message out to every client in the same room. The writeMessage method in each of those clients will write the message to its websocket connection, which will be handled on the frontend side to display the messages accordingly.

Extension points exported contracts — how you extend this code

Service (Interface)
(no doc) [2 implementers]
server/internal/user/user.go
Repository (Interface)
(no doc) [1 implementers]
server/internal/user/user.go
DBTX (Interface)
(no doc)
server/internal/user/user_repository.go

Core symbols most depended-on inside this repo

getRooms
called by 2
client/pages/index.tsx
QueryRowContext
called by 2
server/internal/user/user_repository.go
CreateUser
called by 2
server/internal/user/user.go
Run
called by 2
server/internal/ws/hub.go
Close
called by 2
server/db/db.go
joinRoom
called by 1
client/pages/index.tsx
getUsers
called by 1
client/pages/app/index.tsx
GetUserByEmail
called by 1
server/internal/user/user.go

Shape

Function 26
Method 24
Struct 18
Interface 3

Languages

Go79%
TypeScript21%

Modules by API surface

server/internal/user/user.go11 symbols
server/internal/ws/ws_handler.go9 symbols
server/internal/user/user_repository.go9 symbols
server/internal/user/user_service.go5 symbols
server/internal/user/user_handler.go5 symbols
server/internal/ws/hub.go4 symbols
server/internal/ws/client.go4 symbols
server/db/db.go4 symbols
client/pages/index.tsx4 symbols
client/pages/app/index.tsx3 symbols
server/util/password.go2 symbols
server/router/router.go2 symbols

Datastores touched

go-chatDatabase · 1 repos

For agents

$ claude mcp add go-next-ts_chat \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact