CDA Analyzer
A full-stack web application for analyzing cycling aerodynamics (CDA - Coefficient of Drag Area) from FIT files.
Features
- Upload and parse FIT files from cycling computers
- Automatic weather data integration via OpenWeatherMap API
- Comprehensive CDA calculation considering:
- Speed, power, and elevation data
- Environmental factors (temperature, wind, humidity, pressure)
- Road surface type and rolling resistance
- Air density calculations
- Interactive results visualization:
- Route map with start/finish markers
- CDA trends over time
- Speed and power analysis
- Elevation profile
- Combined analysis view
Tech Stack
Backend
- Node.js with Express
- FIT file parsing with easy-fit
- OpenWeatherMap API integration
- Physics-based CDA calculation algorithm
Frontend
- React 18
- Ant Design UI components
- Recharts for data visualization
- React Leaflet for route mapping
- Axios for API communication
Setup Instructions
Prerequisites
- Node.js (v14 or higher)
- npm or yarn
- OpenWeatherMap API key (optional, but recommended)
Backend Setup
- Navigate to the server directory:
- Install dependencies:
-
Configure environment variables:
- Copy
.env.example to .env
- Add your OpenWeatherMap API key to
.env
OPENWEATHER_API_KEY=your_api_key_here
-
Start the backend server:
# Option 1: Use the startup script (recommended - handles port conflicts)
./start.sh
# Option 2: Manual start
npm run dev
The server will run on http://localhost:8000
Frontend Setup
- Navigate to the frontend directory:
- Install dependencies:
- Start the development server:
# Option 1: Use the startup script (recommended - handles port conflicts)
./start.sh
# Option 2: Manual start
npm start
The app will open at http://localhost:3000
Quick Start with Scripts
Start both services at once:
# From project root
./start.sh
Start services separately:
# Terminal 1 - Backend
cd server && ./start.sh
# Terminal 2 - Frontend
cd frontend && ./start.sh
All startup scripts automatically kill existing processes on the required ports to prevent conflicts!
Usage
-
Upload FIT File: Drag and drop or click to upload your cycling activity FIT file
-
Configure Parameters:
- Required: Rider weight, bike weight, road surface type
- Optional: Custom CRR, environmental conditions (if you want to override API data)
-
Analyze: Click "Analyze FIT File" to process your ride
-
View Results:
- Average CDA and ride statistics
- Interactive route map
- Time-series charts showing CDA variations
- Speed, power, and elevation analysis
CDA Calculation Method
The application calculates CDA using the fundamental cycling power equation:
P_total = P_aero + P_rolling + P_gravity
Where:
- P_aero = 0.5 × ρ × CDA × v³
- P_rolling = CRR × m × g × v × cos(slope)
- P_gravity = m × g × v × sin(slope)
Solving for CDA:
CDA = (2 × P_aero) / (ρ × v³)
The algorithm:
- Groups data into 1-minute intervals
- Calculates air density based on temperature, pressure, and humidity
- Accounts for wind speed and direction
- Filters unrealistic values (CDA between 0.1-0.6 m²)
- Returns per-minute CDA values and overall average
Project Structure
BBSClone/
├── server/
│ ├── services/
│ │ ├── fitAnalysis.js # FIT file upload and parsing
│ │ ├── cdaCalculator.js # CDA calculation engine
│ │ └── weatherService.js # Weather API integration
│ ├── routes/
│ │ └── index.js # API routes
│ ├── server.js # Express server
│ └── package.json
│
├── frontend/
│ ├── src/
│ │ ├── pages/
│ │ │ ├── Upload.js # File upload and parameters
│ │ │ └── Results.js # Analysis results and charts
│ │ ├── App.js # Main app component
│ │ └── index.js
│ └── package.json
│
└── README.md
API Endpoints
POST /api/v1/analyze
Upload and analyze a FIT file
Request:
- Content-Type: multipart/form-data
- Body: FormData with fitFile and parameters
Response:
{
"status": "success",
"data": {
"records": [...],
"cdaResults": {
"intervals": [...],
"avgCDA": 0.2834,
"avgSpeed": 32.5,
"avgPower": 245
},
"summary": {...},
"parameters": {...}
}
}
Typical CDA Values
- Pro time trial position: 0.20-0.25 m²
- Good aero position: 0.25-0.30 m²
- Standard road position: 0.30-0.35 m²
- Upright position: 0.35-0.45 m²
Notes
- The application requires valid power data in the FIT file for accurate CDA calculation
- CDA is calculated only for moving segments with speed > 1 km/h and power > 10W
- Weather data is fetched based on GPS coordinates and timestamp from the FIT file
- For best results, analyze rides with sustained efforts in consistent conditions
- Lots of help from Claude Code
License
ISC