Client Server Chat

Basic client-server chat implementation using WebSocket and agent-swarm-kit.

Demonstrates fundamental capabilities:

  • WebSocket connection implementation between client and server
  • agent-swarm-kit integration in client-server architecture
  • Real-time message processing through agents
  • Basic architecture for scalable chat systems
  • WebSocket Communication: Bidirectional real-time communication
  • Client-Server Architecture: Separation of client and server logic
  • Agent Integration: Message processing through agents
  • Testing Environment: Simple setup for learning concepts
  • Runtime: Bun
  • Language: TypeScript
  • AI Framework: agent-swarm-kit
  • Protocol: WebSocket
  • AI Providers: Ollama, OpenAI
src/
├── client.ts # WebSocket client
├── server.ts # WebSocket server
└── lib/
└── swarm.ts # Swarm configuration
# Install dependencies
bun install

# Run server (terminal 1)
bun run src/server.ts

# Run client (terminal 2)
bun run src/client.ts

Create a .env file:

OLLAMA_API_URL=http://localhost:11434
OPENAI_API_KEY=your_openai_api_key
WS_PORT=8080
  1. Send Message: Enter text in the client
  2. Receive Response: Agent processes message and returns response
  3. Real-time Communication: Instant message exchange

This project serves as foundation for:

  • Chatbots and virtual assistants
  • Customer support systems
  • Educational platforms
  • Interactive web applications

Can be expanded by adding:

  • User authentication
  • Message persistence
  • Multiple rooms
  • File attachments