A modern take on the classic Snake game, built with Blazor WebAssembly and .NET 9. Battle against AI-controlled snakes in a fast-paced arena where survival is key! This project demonstrates modern web application architecture using Vertical Slice Architecture, Azure cloud integration, comprehensive testing, and production-ready DevOps practices.
- Multi-Snake Battle Arena: Compete against AI-controlled snakes with unique personalities and behaviors
- Time-Limited Matches: Fast-paced 30-second rounds with increasing difficulty
- Cross-Platform Controls:
- Desktop: Arrow keys or WASD for movement
- Mobile: Touch-based virtual joystick
- High Score System: Enter your 3-letter initials to immortalize your achievements
- Game Statistics: Track total games, average score, longest snake, and more
- Azure Integration: High scores and statistics stored in Azure Table Storage
- Real-time Telemetry: Application Insights monitoring with custom metrics
- Health Monitoring: Built-in health checks and diagnostics pages
- Responsive Design: Optimized for both desktop and mobile play
- Modern Architecture: Vertical Slice Architecture with Clean Architecture principles
- Comprehensive Testing: 89 passing tests (Unit, Integration, Functional)
- CI/CD Pipeline: Automated testing and deployment with GitHub Actions
- .NET 9.0 SDK - Download
- Visual Studio 2022 (17.8+) or Visual Studio Code with C# extension
- Azurite - Azure Storage emulator for local development
- Azure Developer CLI (azd) - For Azure deployment (Install)
- Git - Version control
-
Clone the repository
git clone https://github.com/punkouter26/PoSnakeGame.git cd PoSnakeGame -
Start Azurite (local storage emulator)
# Install globally (one-time) npm install -g azurite # Start Azurite with dedicated storage directory azurite --location ./.azurite --debug ./.azurite/debug.log
-
Build and run the application
# Restore dependencies dotnet restore PoSnakeGame.sln # Build solution dotnet build PoSnakeGame.sln # Run the API (includes hosting the Blazor WASM client) dotnet run --project PoSnakeGame.Api
-
Access the application
- Open browser to
https://localhost:7066(or URL shown in console) - Try
/swaggerfor API documentation - Access
/diagfor diagnostics and health status - Start playing Snake Battle Royale at
/
- Open browser to
-
Run tests
dotnet test --filter "FullyQualifiedName!~E2ETests"
This project follows Vertical Slice Architecture with Clean Architecture principles:
PoSnakeGame/
โโโ PoSnakeGame.Api/ # ASP.NET Core Web API
โ โโโ Controllers/ # REST API endpoints
โ โโโ Middleware/ # Custom middleware (telemetry enrichment)
โ โโโ HealthChecks/ # Health check implementations
โ โโโ Models/ # API models and DTOs
โโโ PoSnakeGame.Core/ # Domain models and business logic
โ โโโ Models/ # Domain entities (Snake, Arena, HighScore)
โ โโโ Services/ # Business logic (GameService, CpuSnakeAI)
โ โโโ Interfaces/ # Service abstractions
โโโ PoSnakeGame.Infrastructure/ # Data access and external services
โ โโโ Services/ # Table Storage implementation
โ โโโ Configuration/ # Configuration models
โโโ PoSnakeGame.Wa/ # Blazor WebAssembly frontend
โ โโโ Pages/ # Blazor pages/components
โ โโโ Services/ # Client-side services
โ โโโ wwwroot/ # Static assets
โโโ PoSnakeGame.Tests/ # Comprehensive test suite
โ โโโ Unit Tests # Business logic tests
โ โโโ Integration Tests # Database integration tests
โ โโโ Functional Tests # API endpoint tests
โโโ infra/ # Azure Bicep infrastructure
โ โโโ main.bicep # Main deployment template
โ โโโ core/ # Reusable Bicep modules
โโโ docs/ # Documentation
โ โโโ DEPLOYMENT.md # Deployment guide
โ โโโ TELEMETRY.md # Monitoring guide
โ โโโ queries/ # KQL queries for monitoring
โโโ .github/ # GitHub configuration
โโโ workflows/ # CI/CD pipelines
โโโ copilot-agents.md # AI assistant instructions
- Vertical Slice Architecture: Features organized as self-contained slices
- Clean Architecture: Business logic independent of infrastructure
- Dependency Injection: All services registered with proper lifetimes
- SOLID Principles: Clean, maintainable, testable code
- Test-Driven Development: Tests written before implementation
{
"TableStorage": {
"ConnectionString": "UseDevelopmentStorage=true",
"HighScoresTableName": "PoSnakeGameHighScores",
"GameStatisticsTableName": "PoSnakeGameGameStatistics",
"IsUsingLocalStorage": true
},
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=..."
}
}APPLICATIONINSIGHTS_CONNECTION_STRING- Application InsightsTableStorage__ConnectionString- Azure Table StorageTableStorage__HighScoresTableName- High scores tableTableStorage__GameStatisticsTableName- Statistics tableTableStorage__IsUsingLocalStorage- Set tofalse
This prevents conflicts when multiple applications share the same storage account.
Comprehensive technical documentation is available in the /Diagrams folder:
GET /api/health- Basic health checkGET /api/diagnostics/health- Detailed system healthGET /api/diagnostics/tablestorage- Table Storage connectivity
GET /api/highscores- Retrieve top 10 scoresPOST /api/highscores/save- Save a new high scoreGET /api/highscores/check/{score}- Check if score qualifiesDELETE /api/highscores/clear- Clear all scores (debug only)
GET /api/statistics- Retrieve aggregate statisticsPOST /api/statistics/save- Save game session statistics
POST /api/logging/client- Single log entry from BlazorPOST /api/logging/client/batch- Multiple log entries
See api-tests.http for request examples.
Unit Tests
GameServiceTests.cs- Game logic and state managementCpuSnakeAITests.cs- AI behavior and pathfindingModelTests.cs- Domain model validation
Integration Tests
TableStorageServiceIntegrationTests.cs- Database operationsHighScoresControllerTests.cs- High score API endpointsStatisticsControllerTests.cs- Statistics API endpoints
Functional Tests
StatisticsApiTests.cs- End-to-end API testingHealthControllerTests.cs- Health check endpointsStatisticsE2ETests.cs- Full workflow validation
# Run all tests (except E2E)
dotnet test --filter "FullyQualifiedName!~E2ETests"
# Run specific test class
dotnet test --filter "FullyQualifiedName~StatisticsApiTests"
# Run with detailed output
dotnet test --logger "console;verbosity=detailed"
# Generate coverage report
dotnet test --collect:"XPlat Code Coverage"# Install Azure Developer CLI
winget install microsoft.azd
# Login to Azure
azd auth login
# Deploy to Azure (provisions + deploys)
azd up# 1. Provision infrastructure
azd provision
# 2. Deploy application
azd deploy
# 3. Browse deployed app
azd browseSee docs/DEPLOYMENT.md for comprehensive deployment guide.
GitHub Actions workflow (.github/workflows/main.yml) automatically:
- Tests - Runs all 89 tests on every push/PR
- Provisions - Creates/updates Azure infrastructure
- Deploys - Deploys application to Azure App Service
- Validates - Runs health checks and functional tests
Required GitHub Secrets:
AZURE_CLIENT_ID- Service principal client IDAZURE_TENANT_ID- Azure AD tenant IDAZURE_SUBSCRIPTION_ID- Azure subscription ID
- App Service - Hosts API and Blazor WASM
- Storage Account - Table Storage for data
- Application Insights - Telemetry and monitoring
- Log Analytics - Advanced log queries
Estimated Cost: ~$0-5/month (Free/Basic tiers)
- Framework: Serilog with structured JSON logging
- Sinks: Console, File (
logs/log.txt), Application Insights - Client Logging: Blazor logs sent to
/api/logging/client
- Real-time metrics and telemetry
- Custom events and metrics tracking
- Exception tracking with full stack traces
- KQL queries in
docs/queries/:user-activity.kql- User engagement metricsslowest-requests.kql- Performance bottleneckserror-rate.kql- Error tracking and trends
/api/health- Basic availability/api/diagnostics/health- Detailed system status/diag- Blazor diagnostics page with connectivity tests
See docs/TELEMETRY.md for complete monitoring guide.
- DEPLOYMENT.md - Comprehensive deployment guide
- TELEMETRY.md - Monitoring and logging guide
- PRD.md - Product requirements document
- copilot-agents.md - AI assistant instructions
- api-tests.http - HTTP file for API testing
- .NET 9.0 - Latest .NET framework (preview)
- ASP.NET Core - Web API with REST endpoints
- Serilog - Structured logging
- xUnit - Testing framework
- Azure SDK - Azure service integration
- Blazor WebAssembly - Client-side SPA framework
- Radzen.Blazor - UI component library
- .NET 9.0 - Blazor runtime
- Azure App Service - Application hosting (F1 Free tier)
- Azure Table Storage - NoSQL data storage (Standard LRS)
- Azure Application Insights - APM and monitoring
- Azure Log Analytics - Advanced log queries
- Azure Bicep - Infrastructure as Code
- GitHub Actions - CI/CD pipelines
- Azure Developer CLI (azd) - Deployment automation
- Azurite - Local storage emulator
- Git - Source control
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Follow TDD: Write tests first, then implement
- Ensure all 89 tests pass:
dotnet test --filter "FullyQualifiedName!~E2ETests" - Update documentation if needed
- Commit with clear message:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow C# coding conventions and .NET best practices
- Maintain test coverage (all features must have tests)
- Use SOLID principles and Clean Architecture
- Update relevant documentation
- Keep files under 500 lines (refactor if larger)
- Remove unused code proactively
This project is licensed under the MIT License.
- .NET Team - For the amazing .NET 9.0 platform
- Blazor Team - For making WebAssembly development enjoyable
- Radzen - For excellent Blazor components
- Azure Team - For comprehensive cloud services
- Community - For feedback and contributions
- Classic Snake - For timeless inspiration
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Repository: https://github.com/punkouter26/PoSnakeGame
๐ฎ Built with โค๏ธ using .NET 9.0 and Blazor WebAssembly
Last Updated: October 24, 2025