This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SAFE-Chat is a real-time chat application built with F#, .NET, Akka.NET, and Fable. The architecture follows a client-server model where:
- Server: F# with Akka.NET actors for concurrent chat handling, Giraffe for HTTP/WebSocket serving
- Client: F# compiled to JavaScript via Fable, using Elmish (MVU pattern) and React
- Shared: Common protocol definitions between client and server
- Switch to proper node version:
nvm use - Install dependencies:
yarn
# Full production build
./build.cmd
# Manual steps:
cd src/Client
dotnet fable webpack -- -p
cd ../Server
dotnet build# Start server with hot reload
./dev-server.cmd
# or manually: cd src/Server && dotnet watch run
# Start client dev server (separate terminal)
./dev-cli.cmd
# or manually: cd src/Client && dotnet fable webpack-dev-server- Server runs on
http://localhost:8083 - Client dev server runs on
http://localhost:8080with HMR - Client proxies API calls to server
# E2E tests (Windows only, requires server running)
cd test/e2e
dotnet restore
dotnet run- WebSocket Protocol: All real-time communication uses WebSockets after authentication
- Shared Protocol:
src/Shared/ChatProtocol.fsdefines all message types between client/server - Actor System: Server uses Akka.NET actors for concurrent message handling
- ChatServer.fs: Main server actor managing channels and user sessions
- GroupChatChannelActor.fs: Individual channel actors handling chat messages
- UserSessionFlow.fs: Manages individual user WebSocket connections
- SocketFlow.fs: WebSocket connection wrapper
- App.fs: Main Elmish application entry point with routing
- State.fs: Global application state management
- Channel/: Channel-specific UI components and state
- Chat/: Chat message handling and state
- Supports anonymous users
- OAuth is not restored yet
- Akka.NET persistence for chat channels using event sourcing
- Custom JSON event adapter in
AkkaStuff.fs - Journal database in
CHAT_DATA/journal.db/
src/
├── Client/ # Fable F# → JavaScript client
│ ├── webpack.config.js
│ ├── public/ # Static assets and generated bundle
│ └── sass/ # Styling
├── Server/ # F# server with Akka.NET
├── Shared/ # Shared protocol definitions
└── Dockerfile # Container configuration
test/e2e/ # Canopy-based integration tests
- Uses Fable compiler with Webpack for bundling
- Elmish MVU (Model-View-Update) architecture
- Hot module reloading enabled in development
- React components via Fable.React
- Akka.NET actors for concurrency
- Event sourcing for persistence
- Giraffe for HTTP/WebSocket handling
dotnet watch runprovides hot reload
When modifying src/Client/src/Shared/ChatProtocol.fs:
- Update both client and server message handlers
- Consider backward compatibility for persistent data
- Test with both OAuth and anonymous authentication flows