Running with Cosmos DB. Database operations might take longer when the service is initializing.

FitFormBlazor

A modern, lightweight Blazor Server application for tracking personal fitness workouts with intelligent data management.


Overview

FitFormBlazor is a personal workout tracking application designed for Carlos and his son. Built with Blazor Server and MudBlazor, it provides an intuitive interface for logging workouts while leveraging a sophisticated two-tier storage architecture for optimal performance and cost efficiency.

Workout Tracking Capabilities
Chin-Up Tracking

Track bodyweight chin-up variations with detailed metrics:

  • Grip types: Overhand, Underhand, Neutral, Mixed, Wide
  • Sets and reps: Track volume and progression
  • Added weight: Record weighted chin-ups (lbs)
  • Assist weight: Log assisted chin-ups (kg)
  • Hold time: Track static holds (seconds)
  • Notes: Custom observations and form notes
Machine Workouts

Log structured resistance training across different machines:

  • Machine identification: A-F labeling system
  • Exercise type: Custom machine names
  • Weight tracking: Load in pounds or kilograms
  • Sets and reps: Complete workout volume
  • Resistance types: Weight Stack, Plate Loaded, Hydraulic, Pneumatic, Elastic
  • Location: Home, Planet Fitness, YMCA, or custom
Key Features
Multi-User Support
Quick user switching between Carlos and Son with preference persistence
Mobile-Friendly Forms
Responsive design with large touch-friendly inputs on tablets and phones
Data Validation
Client and server-side validation prevents invalid entries and future dates
Progress Reports
View last 30 days of workouts with detailed breakdowns by type
Weekly Summaries
Track workout frequency and volume trends over time
Dark Mode
Toggle between light and dark themes for comfortable viewing
Data Architecture

FitFormBlazor employs a sophisticated two-tier storage strategy that balances performance, cost, and data retention:

Tier 1: Azure Cosmos DB (Hot Storage)

Recent workouts are stored in Cosmos DB for lightning-fast access and global distribution:

  • Container: Single `Workouts` container with `/userId` partition key
  • Type discriminator: Documents tagged with `ChinUpWorkout` or `MachineWorkout`
  • TTL: 30-day default time-to-live ensures automatic cleanup
  • Performance: Optimized composite index on (userId ASC, date DESC)
  • Development: Uses Cosmos DB Emulator for local testing
Tier 2: SQL Server (Cold Storage)

Historical data is automatically migrated to SQL Server for cost-effective long-term retention:

  • Automated migration: Azure Functions process runs nightly at 2:00 AM
  • Safety window: Data migrated 5 days before TTL expiration
  • Schema: Normalized using Entity Framework Core
  • Reliability: Custom tracking ensures no data loss
  • Cost optimization: Long-term storage at lower cost than Cosmos DB
Technical Stack

Frontend & Framework

  • .NET 8 - Long-term support (LTS) until November 2026
  • Blazor Server - Real-time SignalR communication
  • MudBlazor 6.15 - Material Design component library
  • Razor Pages - Classic "_Host" hosting model

Backend & Data

  • Azure Cosmos DB - Microsoft.Azure.Cosmos SDK 3.37
  • SQL Server - Entity Framework Core 8.0.3
  • Azure Functions v4 - Isolated process model for background jobs
  • Hosted Services - Cosmos DB setup and validation on startup
Deployment & Hosting

The application is designed for Azure deployment with the following considerations:

  • Hosting Model: Blazor Server requires persistent SignalR connections
  • Configuration: Environment-based settings for dev, staging, and production
  • Security: Production uses actual Cosmos DB accounts (not emulator)
  • Functions Hosting: Azure Functions on Consumption or Premium plan
  • Backup Policy: Both Cosmos DB and SQL Server configured with backups
Development Setup

The application is ready to run locally with minimal setup:

1. Install Cosmos DB Emulator

Download and install the Azure Cosmos DB Emulator from Microsoft

2. Start the Emulator

Launch the emulator (accessible at https://localhost:8081/)

3. Run the Application

Start FitFormBlazor - it will auto-configure the database and container

4. Track Workouts

Navigate to /chinup or /machinemockup to start logging workouts

On startup, the `CosmosSetupHostedService` automatically ensures the database exists, creates the container with the correct partition key, sets TTL, and adds composite indexes for optimal query performance.

Future Enhancements

Planned features and improvements:

  • Charts and data visualization for progress tracking
  • Workout templates for common routines
  • Personal records (PR) tracking with notifications
  • Progressive overload suggestions based on workout history
  • Integration with additional fitness tracking APIs
  • Comprehensive form validation tests
  • Migration to .NET 10 LTS when available

Built with ❤️ for personal fitness tracking | .NET 8 LTS | Azure Cloud Native Back to Home
An unhandled error has occurred. Reload ??