building / deploying / learning
Live Demo: tronswan.com
- Environment Configuration - Complete guide for setting up environment variables and API tokens
- CI/CD Setup - Automated testing and deployment verification setup
- Health Page Guide - Service health monitoring and deployment status features
- Logging Guide - Comprehensive guide to the structured logging system and best practices
- Google Docs Setup - Guide for setting up Google Docs API for dynamic resume content
- 🦢 Personal Blog Integration - Fetches posts from Hugo static site API (swantron.com)
- 🍳 AI Recipe App - chomptron.com - AI-powered recipe discovery using Gemini on GCP
- 🌡️ Weather Station - Real-time weather data for Bozeman, MT
- 🎵 Spotify Music Player - Full-featured Spotify integration with top tracks, artists, playlists, liked songs, and music playback (Premium required)
- ⚾ MLB Standings - Comprehensive MLB statistics with standings, team stats, playoff race, and rankings
- 📄 Dynamic Resume - Resume content dynamically loaded from Google Docs API (see Google Docs Setup)
- 🎬 Video Shorts Gallery - Collection of video shorts with modal player
- 🎮 Interactive Games - FizzBuzz calculator and fun components
- 📊 Health Monitoring - Real-time service health and deployment status (see Health Page Guide)
- 🔍 SEO Optimization - Comprehensive SEO with react-helmet-async for meta tags, Open Graph, and Twitter cards
- 📝 Structured Logging - Advanced logging system with performance tracking (see Logging Guide)
- 📱 Responsive Design - Works on all devices
- ⚡ Fast Performance - Optimized with modern React patterns
- 🧪 High Test Coverage - 93.98% test coverage with Vitest and Playwright E2E tests
- 🚀 Automated Deployment - CI/CD pipeline with post-deployment verification (see CI/CD Setup)
- Frontend: React 19.2, TypeScript, React Router 7.10
- Styling: CSS3 with CSS Variables, Responsive Design
- SEO: react-helmet-async for dynamic meta tags and Open Graph
- Testing: Vitest, React Testing Library, Playwright (E2E)
- Build Tools: Vite 7.1, TypeScript 5.9
- Server: Express.js 5.1 for production deployment
- Deployment: DigitalOcean App Platform
- APIs:
- Hugo JSON API (blog posts from static Hugo site)
- OpenWeatherMap API (weather data)
- GitHub API (CI/CD status)
- DigitalOcean API (infrastructure monitoring)
- Spotify Web API (music integration)
- MLB Stats API (baseball standings)
- Google Docs API (resume content)
- Package Manager: Yarn
- CI/CD: GitHub Actions with Playwright testing
- Node.js (v20 or higher)
- Yarn package manager
- Git
-
Clone the repository:
git clone https://github.com/swantron/tronswan.git cd tronswan -
Install dependencies:
yarn install
-
Create a
.envfile in the root directory. See Environment Configuration for detailed setup:# Basic weather configuration VITE_WEATHER_API_KEY=your_openweathermap_api_key VITE_WEATHER_CITY=Bozeman VITE_WEATHER_UNITS=imperial # Site configuration VITE_SITE_URL=https://tronswan.com # Optional: Health monitoring features VITE_GITHUB_TOKEN=your_github_token VITE_GITHUB_OWNER=swantron VITE_DIGITALOCEAN_TOKEN=your_digitalocean_token VITE_DIGITALOCEAN_APP_ID=your_digitalocean_app_id # Optional: Spotify integration (for music player) VITE_SPOTIFY_CLIENT_ID=your_spotify_client_id VITE_SPOTIFY_CLIENT_SECRET=your_spotify_client_secret VITE_SPOTIFY_REDIRECT_URI=http://localhost:5173/music/callback # Optional: Google Docs API (for dynamic resume) VITE_GOOGLE_DOCS_API_KEY=your_google_docs_api_key # Optional: Swantron Hugo API (for blog posts) VITE_SWANTRON_API_URL=https://swantron.com
Development:
yarn dev: Runs the app in development mode with Viteyarn start: Starts the Express production server (requires build first)yarn build: Builds the app for production with Viteyarn preview: Preview the production build locally
Testing:
yarn test: Launches the Vitest test runner in watch modeyarn test:run: Runs tests once and exitsyarn test:coverage: Runs tests with coverage reportingyarn test:ui: Launches the Vitest UI for interactive testingyarn test:e2e: Runs Playwright end-to-end testsyarn test:e2e:ui: Runs Playwright tests with UI modeyarn test:e2e:headed: Runs Playwright tests in headed browseryarn test:e2e:debug: Runs Playwright tests in debug modeyarn test:all: Runs both unit and e2e tests
Code Quality:
yarn type-check: Runs TypeScript type checking without emitting filesyarn lint: Runs ESLint to check code qualityyarn lint:fix: Runs ESLint and fixes auto-fixable issuesyarn format: Formats code with Prettieryarn format:check: Checks code formatting without making changesyarn check-all: Runs type-check, lint, and format:check
src/
├── components/ # React components
│ ├── music/ # Spotify music player components
│ ├── recipe/ # AI recipe app components
│ ├── status/ # Health monitoring components
│ ├── swantron/ # Blog post components
│ ├── ui/ # UI components (Weather, MLB, Resume, etc.)
│ └── video/ # Video player components
├── services/ # API service modules
│ ├── digitalOceanService.ts # DigitalOcean API integration
│ ├── githubService.ts # GitHub API integration
│ ├── spotifyService.ts # Spotify Web API integration
│ ├── spotifyPlaybackService.ts # Spotify playback control
│ ├── googleDocsService.ts # Google Docs API integration
│ └── swantronService.ts # Hugo JSON API for blog posts
├── hooks/ # Custom React hooks
│ ├── useResumeData.ts # Resume data fetching hook
│ ├── useApiRequest.ts # API request hook
│ └── useDateFormatter.ts # Date formatting hook
├── utils/ # Utility functions and configuration
│ ├── logger.ts # Structured logging system
│ └── runtimeConfig.ts # Runtime configuration
├── config/ # Configuration files
│ └── logging.ts # Logging configuration
├── types/ # TypeScript type definitions
├── data/ # Static data (study guides, etc.)
└── styles/ # CSS stylesheets
tests/ # Test files
├── e2e/ # Playwright end-to-end tests
├── smoke/ # Smoke tests
├── regression/ # Regression tests
├── page-objects/ # Page object models
└── fixtures/ # Test fixtures
server.js # Express production server
.github/workflows/ # GitHub Actions CI/CD
This project is fully migrated to TypeScript for enhanced type safety and developer experience.
- Full TypeScript: All components, hooks, services, and tests are written in TypeScript
- Type Safety: Comprehensive type definitions for all API responses, component props, and state
- Type Checking: Run
yarn type-checkto validate types without building - Configuration:
tsconfig.jsonconfigured for React and modern JavaScript features - Test Files: All test files use
.test.tsxextension with full TypeScript support - Migration Complete: Successfully migrated from Jest to Vitest with full TypeScript support
The application includes a comprehensive health monitoring system accessible at /health:
- GitHub Actions Integration: View recent workflow runs and deployment status
- DigitalOcean Infrastructure: Monitor droplets, load balancers, and databases
- Service Health Checks: Real-time monitoring of external services
- Deployment Status: Track application deployment and health metrics
See Health Page Guide for detailed information about the health monitoring features.
A full-featured Spotify integration that provides an enhanced music experience:
- Authentication: OAuth 2.0 flow with Spotify
- Top Tracks & Artists: View your top tracks and artists with customizable time ranges (last month, 6 months, year, all time)
- Recently Played: See your recent listening history
- Liked Songs: Browse and play your entire liked songs library with pagination
- Playlists: View all your playlists with track listings
- Music Playback: Direct playback control (requires Spotify Premium)
- Music Player Component: Embedded player with play/pause controls
- Currently Playing: Real-time display of currently playing track
Comprehensive Major League Baseball statistics and analysis:
- Standings View: Current standings for all divisions (AL/NL East, Central, West)
- Team Stats Deep Dive: Detailed team statistics including:
- Home vs Away records
- Day vs Night games
- Performance vs left/right-handed pitchers
- Surface type (grass/turf) performance
- Close games (extra innings, one-run games)
- Last 10 games performance
- Expected win-loss records
- Playoff Race: Wild card standings and playoff positioning
- Rankings: Top 10 teams ranked by:
- Best records
- Most runs scored
- Fewest runs allowed
- Best run differential
- Hottest teams (last 10 games)
- Best home field advantage
Resume content dynamically loaded from Google Docs:
- Google Docs Integration: Resume content fetched from Google Docs API
- Auto-refresh: Content updates automatically when Google Doc is modified
- Last Updated: Displays when content was last fetched
- Error Handling: Graceful error handling with retry functionality
See Google Docs Setup for setup instructions.
A collection of video shorts with an interactive gallery:
- Video Collection: Browse through a collection of video shorts
- Modal Player: Click any video to play in a full-screen modal
- Thumbnail Previews: Video thumbnails with hover effects
- Keyboard Navigation: Full keyboard support for accessibility
Comprehensive SEO implementation:
- Dynamic Meta Tags: Page-specific titles, descriptions, and keywords
- Open Graph: Facebook/LinkedIn sharing optimization
- Twitter Cards: Twitter sharing optimization
- Structured Data: JSON-LD structured data support
- Canonical URLs: Proper canonical URL handling
- Runtime Configuration: SEO tags configured at runtime
Advanced logging system with performance tracking:
- Log Levels: Debug, Info, Warn, Error with configurable levels
- Performance Tracking: Measure async operation performance
- Context Logging: Rich context data with every log entry
- Development Mode: Enhanced logging in development
- Production Mode: Optimized logging for production
See Logging Guide for detailed information.
This project maintains high test coverage with comprehensive unit tests and end-to-end tests.
- Current Coverage: 93.98%
- Unit Testing: Vitest + React Testing Library
- E2E Testing: Playwright for browser automation
- TypeScript Support: All tests written in TypeScript with full type safety
- Fast Execution: Vitest provides faster test execution compared to Jest
- Modern Tooling: Built on Vite for optimal performance and developer experience
- Coverage Reports: Generated automatically as part of CI/CD pipeline
- Coverage Badge: Shows current test coverage percentage
- Test Organization: Tests organized by type (smoke, regression, e2e) with page object models
Unit Tests:
# Run all tests in watch mode
yarn test
# Run tests once and exit
yarn test:run
# Run tests with coverage
yarn test:coverage
# Launch interactive test UI
yarn test:uiEnd-to-End Tests:
# Run Playwright E2E tests
yarn test:e2e
# Run with UI mode (interactive)
yarn test:e2e:ui
# Run in headed browser (see browser)
yarn test:e2e:headed
# Debug mode
yarn test:e2e:debug
# Run all tests (unit + e2e)
yarn test:allThe application is deployed to DigitalOcean using their App Platform. The deployment is automated through GitHub Actions with comprehensive testing and verification.
The application uses an Express.js server (server.js) for production deployment that:
- Serves static files from the Vite build
- Handles client-side routing (SPA fallback)
- Includes request logging and security middleware
- Detects and logs suspicious requests
- Provides graceful shutdown handling
The project includes a complete CI/CD pipeline that:
- Runs unit tests with coverage reporting
- Builds and verifies the application
- Deploys to DigitalOcean App Platform
- Runs Playwright tests against the deployed site
- Provides detailed test reports and artifacts
See CI/CD Setup for detailed information about the automated testing and deployment process.
For detailed environment variable setup, see Environment Configuration.
Required for basic functionality:
VITE_WEATHER_API_KEY: OpenWeatherMap API keyVITE_WEATHER_CITY: Default city for weather data (default:Bozeman)VITE_WEATHER_UNITS: Units for weather data (default:imperial)
Optional features:
VITE_SITE_URL: Site URL for SEO and links (default:https://tronswan.com)VITE_GITHUB_TOKEN: GitHub API token for health page monitoringVITE_GITHUB_OWNER: GitHub username/organization (default:swantron)VITE_DIGITALOCEAN_TOKEN: DigitalOcean API token for infrastructure monitoringVITE_DIGITALOCEAN_APP_ID: DigitalOcean App Platform app IDVITE_SPOTIFY_CLIENT_ID: Spotify Client ID for music player integrationVITE_SPOTIFY_CLIENT_SECRET: Spotify Client Secret for music player integrationVITE_SPOTIFY_REDIRECT_URI: Spotify OAuth redirect URI (default:/music/callback)VITE_GOOGLE_DOCS_API_KEY: Google Docs API key for dynamic resume contentVITE_SWANTRON_API_URL: Base URL for Hugo static site API (default:https://swantron.com)
Note: The Google Docs document ID is hardcoded in the service. See Google Docs Setup for details.
The project includes utility scripts for development and testing. All scripts are defined in package.json and can be run with yarn <script-name>.
This project is licensed under the MIT License.