A professional bicycle wheel spoke length calculator built with Svelte, TypeScript, and Vite.
# Install dependencies
pnpm install
# Start development server
pnpm run dev
# Run tests
pnpm run test
# Run tests with coverage
pnpm run test:coverage
# Build for production
pnpm run build
The project includes comprehensive unit and integration tests:
# Run all tests
pnpm run test
# Run tests in watch mode
pnpm run test --watch
# Run tests with UI
pnpm run test:ui
# Generate coverage report
pnpm run test:coverage
# Build and run with Docker Compose
docker-compose up --build
# Access the application at http://localhost:3000
# Run development environment
docker-compose --profile dev up
# Access development server at http://localhost:5173
# Build production image
docker build -t wheelbuilder .
# Run production container
docker run -p 3000:80 wheelbuilder
The spoke length is calculated using the standard bicycle wheel formula:
L = √[(r - h×cos(θ))² + (h×sin(θ))²]
Where:
L
= spoke length (mm)r
= rim radius (effective diameter ÷ 2)h
= hub flange radius (flange diameter ÷ 2)θ
= cross angle in radians = (cross pattern × 360°) ÷ spoke countsrc/
├── lib/
│ ├── spokeCalculator.ts # Core calculation logic
│ ├── WheelBuilder.svelte # Main component
│ └── __tests__/ # Test files
├── App.svelte # Root component
└── main.ts # Application entry point
calculateSpokeLength(specs: WheelSpecs): CalculationResult
Calculates the required spoke length for given wheel specifications.
Parameters:
specs.rimEffectiveDiameter
- Rim effective diameter in mmspecs.spokeCount
- Number of spokes (must be divisible by 4)specs.crossPattern
- Cross pattern (0-4)specs.hubFlangeDiameter
- Hub flange diameter in mmReturns:
spokeLength
- Calculated spoke length in mm (rounded to 1 decimal)isValid
- Whether the calculation is validerrors
- Array of validation error messagesvalidateWheelSpecs(specs: WheelSpecs): string[]
Validates wheel specifications and returns any errors.
getCommonWheelSizes(): Array<{name: string, diameter: number}>
Returns an array of common wheel sizes for quick selection.
MIT License - see LICENSE file for details.