Directory Overview
Library Code (src/lib/)
Shared utilities, helpers, and business logic.
Core Utilities
-
fetch/- MLB API data fetchingindex.ts- Core fetch utilitieslive.svelte.ts- Live data polling with Svelte runespresets.ts- Pre-configured API endpoints
-
attachments/- DOM interaction utilitiesintersection-observer.ts- Viewport visibility detectionmutation-observer.ts- DOM change observationlabel-drag.ts- Draggable label interactions
-
server/- Server-side utilitiesposthog.ts- Analytics initializationrandom.ts- Random number generation
Utility Modules
utils.ts- General helper functionsstats.ts- Baseball statistics calculationstemporal.ts- Date/time utilitiescolors.ts- Color scheme utilitiesconsole.ts- Console logging helpersurl.svelte.ts- URL state management with Svelte runesindex.ts- Library exports
UI Components (src/ui/)
Reusable Svelte components organized by feature.
Component Categories
Game Components (ui/game/)
status.svelte- Game status displayteam-scores.svelte- Score displayprobable-pitchers.svelte- Starting pitcher infoplays.svelte- Play-by-play displaylinescore.svelte- Inning-by-inning scoreswin-probability.svelte- Win probability charttop-performers.svelte- Game highlights
Team Components (ui/team/)
logo.svelte- Team logo displayroster.svelte- Team roster displaystyled-team.svelte- Team-themed stylingteam-calendar.svelte- Team schedule view
Player Components (ui/player/)
headshot.svelte- Player photoplayer-info.svelte- Player detailssearch.svelte- Player searchroster-entries.svelte- Roster listingshot-cold-zones-list.svelte- Batting zones
Stats Components (ui/stats/)
year-by-year.svelte- Career statisticsyear-by-year-list.svelte- Stats tablehot-cold-zones.svelte- Zone visualizationstrikezone.svelte- Strike zone displayhome-plate.svelte- Home plate graphicseason-picker.svelte- Season selectionmonth-picker.svelte- Month selection
Schedule Components (ui/schedule/)
calendar.svelte- Calendar viewdate-picker.svelte- Date selectionweek-picker.svelte- Week navigationmonth-picker-with-year.svelte- Month/year selectoryear-picker.svelte- Year selectionstore.svelte.ts- Schedule state management
Sidebar Components (ui/sidebar/)
drawer.svelte- Sidebar containernav.svelte- Navigation menutoggle-sidebar.svelte- Sidebar toggletoggle-color-scheme.svelte- Theme switcherfavorites-list.svelte- Favorite teamscompare-list.svelte- Team comparisonspoiler-prevention-list.svelte- Spoiler settingsgame-count.svelte- Game counter
Season Components (ui/season/)
season-info.svelte- Season detailsseason-progress.svelte- Progress barcountdown.svelte- Game countdowncountdown-list.svelte- Multiple countdowns
Transaction Components (ui/transactions/)
transaction.svelte- Single transactiontransaction-list.svelte- Transaction feedby-team.svelte- Team transactionsutils.ts- Transaction helpers
Playground Components (ui/playground/)
select-endpoint.svelte- API endpoint selectorparameters-table.svelte- Parameter configurationparameter-row.svelte- Individual parameterresponse.svelte- API response displayaction.ts- Playground actionsconstants.ts- API constantsutils.ts- Playground utilities
Icons (ui/icons/)
SVG icon components:
- Baseball:
ball.svelte,bat.svelte,diamond.svelte,helmet.svelte,jersey.svelte - UI:
chevron-left.svelte,chevron-right.svelte,expand-*.svelte,collapse-*.svelte - Actions:
search.svelte,send.svelte,star.svelte,eye.svelte,split.svelte - Theme:
sun.svelte,moon.svelte,sidebar.svelte - Data:
calendar.svelte,rank.svelte,info.svelte,flag.svelte - Code:
code.svelte,json.svelte,github.svelte,robot.svelte index.ts- Icon exports
Spoiler Prevention (ui/spoiler-prevention/)
toggle-spoiler-prevention.svelte- Toggle controlstore.svelte.ts- Spoiler state
Root UI Components
store.svelte.ts- Global UI state (color scheme)header.svelte- Page headermetadata.svelte- SEO meta tagsloading.svelte- Loading statesoffline.svelte- Offline indicatorvideo.svelte- Video playerselect-team.svelte- Team selectorselect-sport.svelte- Sport selectorgame-type-picker.svelte- Game type filtertoggle-all-details.svelte- Expand/collapse all
Routes (src/routes/)
SvelteKit file-based routing.
Page Routes
/- Home page (+page.svelte)/game/[gamePk]- Individual game view/player/[playerId]- Player profile/player/[playerId]/[season]- Season-specific stats
/schedule- Schedule overview/schedule/[date]- Date-specific schedule
/standings- League standings/stats- Statistics leaders/teams/[teamId]- Team page/transactions- Transaction feed/chat- Chat/help interface
API Routes (routes/api/)
Server-side API endpoints for proxying MLB data or custom logic.
Layout Files
+layout.svelte- Root layout component+layout.ts- Layout load functionsapp.css- Global stylesfonts.css- Font definitions
Type Definitions
src/mlb.d.ts
Comprehensive TypeScript definitions for the MLB Stats API (1,953 lines). See API Types for details.
src/app.d.ts
Global SvelteKit type declarations:
Parameters (src/params/)
Route parameter matchers for type-safe routing:
Configuration Files
Root Directory
svelte.config.js- SvelteKit configurationvite.config.ts- Vite build configurationtsconfig.json- TypeScript configurationpackage.json- Dependencies and scripts.prettierrc- Code formatting rules
State Management
The application uses Svelte 5’s runes-based reactivity:Global Stores
$ui/store.svelte.ts- Color scheme state$ui/schedule/store.svelte.ts- Schedule navigation state$ui/spoiler-prevention/store.svelte.ts- Spoiler prevention settings$lib/url.svelte.ts- URL parameter state
Runes Used
$state- Reactive state$derived- Computed values$effect- Side effects$props- Component properties
Architectural Patterns
Component Composition
Components are designed to be:- Small and focused - Single responsibility
- Reusable - Shared across routes
- Type-safe - Full TypeScript support
- Accessible - Semantic HTML and ARIA attributes
Data Fetching
Styling Approach
- Utility-first with Tailwind CSS
- Component-scoped styles when needed
- Theme-aware (light/dark mode)
- Responsive design patterns