Go Game with AT Protocol Integration#
A SvelteKit application that implements the game of Go using the Wgo library, with AT Protocol OAuth authentication and custom lexicons to record game state and moves on the decentralized network.
Features#
- AT Protocol OAuth: Login with your Bluesky account
- Custom Lexicons: Game state stored as AT Protocol records
boo.sky.go.game- Game recordsboo.sky.go.move- Move recordsboo.sky.go.pass- Pass records
- Wgo.js Integration: Professional Go board rendering and game logic
- Real-time Updates: Firehose subscription for network-wide game updates
- Multiple Board Sizes: Support for 9x9, 13x13, and 19x19 boards
- Local Caching: SQLite database for fast queries
Implementation Status#
This is a demonstration project showing the architecture for integrating a Go game with AT Protocol. The core implementation includes:
✅ Completed:
- SvelteKit application structure
- Custom AT Protocol lexicon definitions for games, moves, and passes
- SQLite database schema with Kysely
- Wgo.js board component integration
- Game creation and joining UI
- Move recording logic
- Pass functionality
- Game state management
⚠️ Partially Implemented:
- OAuth authentication (structure in place, needs full AT Protocol OAuth client setup)
- AT Protocol record creation (URIs generated, but not actually written to network)
- Firehose subscription (placeholder implementation provided)
📝 Notes:
- The application demonstrates the data structures and flow for AT Protocol integration
- OAuth and record creation are simplified for demo purposes
- To fully implement, you'll need to properly configure NodeOAuthClient and AtpAgent
- The Node version (v17.9.0) is below the recommended 18+, which may cause some warnings
Getting Started#
Prerequisites#
- Node.js 18+ recommended (project currently on v17.9.0)
- npm or pnpm
Installation#
-
Clone the repository
-
Install dependencies:
npm install -
Copy the environment file:
cp .env.example .env -
Edit
.envand update theSESSION_SECRETto a random string:DATABASE_PATH=./data/app.db SESSION_SECRET=your-random-secret-here PUBLIC_BASE_URL=http://localhost:5173
Running the Development Server#
npm run dev
The application will be available at http://localhost:5173
Building for Production#
npm run build
npm run preview
How to Play#
- Login: Click login and enter your Bluesky handle (e.g.,
yourname.bsky.social) - Create Game: Choose a board size and create a new game
- Wait or Join: Either wait for another player to join your game, or join an existing waiting game
- Play: Take turns placing stones on the board
- Pass: Click the Pass button if you want to pass your turn
- Game End: The game ends when both players pass consecutively
Project Structure#
/src
/routes
+page.svelte # Home page with game list
+page.server.ts # Server-side data loading
+layout.svelte # Layout wrapper
/auth
/login/+server.ts # OAuth login initiation
/callback/+server.ts # OAuth callback handler
/logout/+server.ts # Logout handler
/game/[id]
+page.svelte # Game board view
+page.server.ts # Game data loading
/api
/games
+server.ts # Create game API
/[id]
/join/+server.ts # Join game API
/move/+server.ts # Record move API
/pass/+server.ts # Record pass API
/lib
/server
auth.ts # OAuth client setup
db.ts # Database configuration
firehose.ts # Firehose subscription
/components
Board.svelte # Wgo board component
hooks.server.ts # Server hooks
/lexicons # Custom lexicon definitions
boo.sky.go.game.json
boo.sky.go.move.json
boo.sky.go.pass.json
/static
oauth-client-metadata.json # OAuth client metadata
Architecture#
Technology Stack#
- Frontend: SvelteKit 5 with TypeScript
- Go Engine: Wgo.js (v3.0.0-alpha.10)
- Authentication: AT Protocol OAuth (
@atproto/oauth-client-node) - Data Storage: AT Protocol records with custom lexicons
- Database: SQLite with Kysely query builder
- Real-time: AT Protocol Firehose (placeholder implementation)
Custom Lexicons#
The application defines three custom AT Protocol lexicons:
- boo.sky.go.game: Represents a game between two players
- boo.sky.go.move: Represents a stone placement move
- boo.sky.go.pass: Represents a pass action
All game data is stored as AT Protocol records, making it decentralized and portable.
Known Limitations#
- The firehose implementation is a placeholder - full implementation would require WebSocket connection to AT Protocol relay
- No automatic scoring - game ends on two consecutive passes but doesn't calculate winner
- OAuth session management is simplified for development (should use proper encryption in production)
- No time controls or undo functionality
- Real-time updates require page refresh
Future Enhancements#
- Automatic territory scoring
- Game chat/comments using AT Protocol
- Game history and replay functionality
- Time controls (byo-yomi, Fischer)
- Player ranking system
- SGF (Smart Game Format) export
- Game analysis tools
- Spectator mode
Contributing#
This is a demonstration project showing AT Protocol integration with a game application. Feel free to fork and extend!
License#
MIT