A Next.js 14+ application that displays NHL teams, games, and live scores using the NHL Companion API.
- Teams Grid: View all active NHL teams with their logos
- Game Status Indicators: See which teams have live, upcoming, or completed games today
- Team Detail Pages: Click on any team to view detailed information and today's game
- Live Game Monitoring: Real-time play-by-play updates for live games
- Timezone Support: View games in your local timezone
- Real-time Data: Fetches live game data from the NHL Companion API
This frontend application:
- Built with Next.js 14 (App Router)
- Styled with Tailwind CSS
- Deployed on Vercel
- Communicates with NHL Companion API (FastAPI on Heroku)
- Uses Next.js API routes as a proxy layer (keeps API token server-side)
- Node.js 18+ and npm
- NHL Companion API service (local or deployed)
- API Bearer Token from the API service
npm installCopy the example environment file and add your API bearer token:
# Create .env.local from the example
copy env.example .env.localEdit .env.local and set your configuration:
# API Configuration (server-side only, not exposed to browser)
API_BEARER_TOKEN=your-actual-token-here
API_BASE_URL=http://localhost:8001
# Feature Flags
NEXT_PUBLIC_ENABLE_TEST_MODE=falseImportant Notes:
API_BEARER_TOKENshould match the token configured in your API serviceAPI_BASE_URLshould point to your API service (local:http://localhost:8001, production: your Heroku URL)- Variables without
NEXT_PUBLIC_prefix are server-side only (more secure)
npm run devThe application will be available at http://localhost:3000.
frontend/
├── app/
│ ├── layout.tsx # Root layout with metadata
│ ├── page.tsx # Home page (teams grid)
│ ├── globals.css # Global styles
│ └── team/
│ └── [teamId]/
│ └── page.tsx # Team detail page
├── lib/
│ ├── api-client.ts # API client with authentication
│ └── utils.ts # Utility functions
├── types/
│ └── api.ts # TypeScript type definitions
└── env.example # Environment variables template
The application determines game status for each team based on today's games:
- 🔴 LIVE: Team has a game with state
LIVEorCRIT - 📅 Upcoming Today: Team has a game with state
FUT - ✓ Completed Today: Team has a game with state
FINALorOFF - No game today: Team has no scheduled game today
All API calls are made server-side using Next.js Server Components:
- Bearer token is kept secure (not exposed to browser)
- Data is fetched at request time (no caching for real-time updates)
- Error handling for all API responses
- Fetches all active teams
- Fetches today's games
- Displays teams in a responsive grid
- Shows game status badge for each team
- Links to team detail pages
- Displays team logo and name
- Shows today's game information (if exists):
- Game status (live/upcoming/completed)
- Score and opponent
- Period and clock
- Venue and game details
- Shots on goal
- Displays "No game scheduled today" if no game
npm run devnpm run build
npm startnpm run lintSee DEPLOYMENT.md for detailed deployment instructions to Vercel.
- Push to GitHub
- Import repository in Vercel
- Set environment variables:
API_BEARER_TOKENAPI_BASE_URL(your Heroku API URL)NEXT_PUBLIC_ENABLE_TEST_MODE=false
- Deploy!
The frontend consumes the following API endpoints via Next.js API routes:
GET /api/teams/active- Fetch all active NHL teamsGET /api/teams/{teamId}/players- Fetch team rosterGET /api/games?date={YYYY-MM-DD}&timezone={timezone}- Fetch games for a dateGET /api/games/{gameId}- Fetch game details with play-by-playGET /api/players/{playerId}- Fetch player details
Local Development:
- Ensure your
API_BEARER_TOKENin.env.localmatches the token in your API service - Verify the API service is running
Production:
- Check environment variables in Vercel dashboard
- Verify API service is accessible from Vercel
Local Development:
- Check that the API service is running:
python api_app.pyin API repo - Verify the database has data
- Check the API URL in
.env.localis correct
Production:
- Verify
API_BASE_URLis set correctly in Vercel - Check API service health:
curl https://your-api.herokuapp.com/health - Check Vercel function logs
- Update CORS configuration in API service to include your Vercel domain
- Redeploy API service after CORS changes
- Ensure the database has been populated with data (via DB CLI service)
- Check the API service logs for errors
- Verify the date format is correct (YYYY-MM-DD)
- Check browser console for JavaScript errors
frontend/
├── app/ # Next.js App Router
│ ├── api/ # API route handlers (proxy to backend)
│ ├── live/[gameId]/ # Live game page
│ ├── team/[teamId]/ # Team detail page
│ ├── page.tsx # Home page
│ └── layout.tsx # Root layout
├── components/ # React components
│ └── live/ # Live game components
├── lib/ # Utilities
│ ├── api-client.ts # API client functions
│ └── utils.ts # Helper functions
├── types/ # TypeScript types
│ └── api.ts # API response types
└── public/ # Static assets
- API Service: NHL Companion API (FastAPI on Heroku)
- DB CLI Service: NHL Companion DB CLI (data sync on Heroku)
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally
- Submit a pull request
MIT