Skip to content

Commit 8b3f045

Browse files
Merge pull request #240 from OneBusAway/tests
Add Tests for Components
2 parents d4b0cd3 + 111fef7 commit 8b3f045

33 files changed

+9535
-70
lines changed

CLAUDE.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Wayfinder is the next-generation OneBusAway web application built with SvelteKit 5. It provides real-time transit information including bus stops, routes, arrivals/departures, and trip planning functionality. The application uses the OneBusAway REST API and supports both OpenStreetMap and Google Maps providers.
8+
9+
## Development Commands
10+
11+
```bash
12+
# Install dependencies
13+
npm install
14+
15+
# Copy environment configuration
16+
cp .env.example .env
17+
18+
# Start development server
19+
npm run dev
20+
21+
# Build for production
22+
npm run build
23+
24+
# Preview production build
25+
npm run preview
26+
27+
# Run tests
28+
npm run test
29+
30+
# Run tests with coverage
31+
npm run test:coverage
32+
33+
# Lint code
34+
npm run lint
35+
36+
# Format code
37+
npm run format
38+
39+
# Pre-push checks (format, lint, test)
40+
npm run prepush
41+
```
42+
43+
## Architecture
44+
45+
### Svelte 5 Usage
46+
47+
This project uses Svelte 5 with the new runes API (`$state`, `$derived`, `$effect`, `$props`) and snippets system. Components use the modern Svelte 5 syntax throughout.
48+
49+
### Key Directories
50+
51+
- `src/components/` - All Svelte components organized by feature
52+
- `src/lib/` - Reusable utilities and services
53+
- `src/stores/` - Svelte stores for global state management
54+
- `src/routes/` - SvelteKit routes (pages and API endpoints)
55+
- `src/config/` - Configuration files
56+
- `src/locales/` - Internationalization files
57+
58+
### Component Organization
59+
60+
- `components/navigation/` - Header, modals, menus
61+
- `components/map/` - Map-related components (MapView, markers, popups)
62+
- `components/stops/` - Stop information and scheduling
63+
- `components/routes/` - Route information and modals
64+
- `components/search/` - Search functionality
65+
- `components/trip-planner/` - Trip planning interface
66+
- `components/surveys/` - User survey system
67+
- `components/service-alerts/` - Alert notifications
68+
69+
### State Management
70+
71+
- Uses Svelte 5 runes (`$state`, `$derived`) for local component state
72+
- Svelte stores for global state (map loading, modal state, user location, surveys)
73+
- Modal state managed through a centralized modal system
74+
75+
### API Integration
76+
77+
- OneBusAway SDK integration via `src/lib/obaSdk.js`
78+
- API routes in `src/routes/api/` proxy requests to OBA servers
79+
- OpenTripPlanner integration for trip planning
80+
- Google Maps/Places API integration for geocoding
81+
82+
### Map Providers
83+
84+
- Supports both OpenStreetMap (via Leaflet) and Google Maps
85+
- Map provider abstraction in `src/lib/Provider/`
86+
- Configurable via `PUBLIC_OBA_MAP_PROVIDER` environment variable
87+
88+
### Key Features
89+
90+
- Real-time arrivals and departures
91+
- Interactive maps with stop and vehicle markers
92+
- Route visualization with polylines
93+
- Trip planning with multiple itineraries
94+
- Multi-language support (i18n)
95+
- Responsive design with mobile menu
96+
- Analytics integration (Plausible)
97+
- User surveys and feedback collection
98+
- Service alerts and notifications
99+
100+
## Environment Configuration
101+
102+
Required environment variables (see `.env.example`):
103+
104+
- `PRIVATE_OBA_API_KEY` - OneBusAway API key
105+
- `PUBLIC_OBA_SERVER_URL` - OBA server URL
106+
- `PUBLIC_OBA_REGION_*` - Region configuration
107+
- `PUBLIC_OBA_MAP_PROVIDER` - Map provider ("osm" or "google")
108+
109+
## Testing
110+
111+
- Tests use Vitest with jsdom environment
112+
- Test files located in `src/tests/`
113+
- Coverage reporting available via `npm run test:coverage`
114+
- Tests cover utilities, formatters, and SDK integration
115+
116+
## Styling
117+
118+
- Uses Tailwind CSS for styling
119+
- Flowbite components for UI elements
120+
- FontAwesome icons via Svelte FontAwesome
121+
- CSS custom properties for theming
122+
- Dark mode support
123+
124+
## Build Configuration
125+
126+
- Uses SvelteKit with Node.js adapter
127+
- Vite for bundling and development
128+
- Path aliases configured for imports (`$components`, `$lib`, etc.)
129+
- PostCSS for CSS processing
130+
- Prettier and ESLint for code formatting and linting
131+
132+
## Key Libraries
133+
134+
- `svelte` (v5) - UI framework with runes
135+
- `@sveltejs/kit` - Full-stack framework
136+
- `onebusaway-sdk` - OneBusAway API client
137+
- `leaflet` - Map rendering (OpenStreetMap)
138+
- `@googlemaps/js-api-loader` - Google Maps integration
139+
- `svelte-i18n` - Internationalization
140+
- `flowbite-svelte` - UI components
141+
- `tailwindcss` - CSS framework
142+
143+
## Working with Components
144+
145+
When creating new components:
146+
147+
- Use Svelte 5 runes syntax (`$state`, `$props`, `$derived`)
148+
- Follow the existing component structure and naming conventions
149+
- Use TypeScript JSDoc comments for prop types
150+
- Implement proper cleanup in `$effect` when needed
151+
- Use snippets for reusable markup patterns
152+
- Follow the established CSS classes and Tailwind patterns
153+
154+
## Common Patterns
155+
156+
- Modal management through centralized state
157+
- Event handling with custom events for cross-component communication
158+
- Map provider abstraction for supporting multiple mapping services
159+
- API error handling with standardized error responses
160+
- Internationalization using `svelte-i18n` with JSON locale files
161+
- Analytics tracking for user interactions

0 commit comments

Comments
 (0)