34 KiB
FitPub - Federated Fitness Tracking Platform
Project Overview
FitPub is a decentralized fitness tracking application that integrates with the Fediverse through the ActivityPub protocol. It allows users to upload FIT (Flexible and Interoperable Data Transfer) files from their fitness devices and share their activities with followers across the federated social web. The application renders GPS tracks on interactive maps and federates workout data as ActivityPub activities.
Core Concept
The platform bridges the gap between fitness tracking and social networking by leveraging the open ActivityPub standard. Users can:
- Upload FIT files from GPS-enabled fitness devices (Garmin, Wahoo, etc.)
- View their tracks rendered on interactive maps
- Share activities with followers on Mastodon, Pleroma, and other Fediverse platforms
- Follow other athletes and see their public workouts
- Maintain full data ownership and privacy control
Technical Architecture
Technology Stack
Backend:
- Java 17+ (LTS version)
- Maven for dependency management and build automation
- Spring Boot 4 for application framework
- Spring Web MVC for REST API
- Spring Data JPA for database operations
- Spring Security for authentication and authorization
- PostgreSQL for primary data storage
- PostGIS extension for geospatial data
Frontend:
- Thymeleaf or React for UI rendering
- Leaflet.js for interactive map display
- Chart.js for activity statistics visualization
- Bootstrap or Tailwind CSS for responsive design
Protocols & Standards:
- ActivityPub (W3C Recommendation)
- WebFinger (RFC 7033) for actor discovery
- HTTP Signatures for authenticated federation
- JSON-LD for linked data representation
- GeoJSON for geographic data interchange
System Components
1. FIT File Processing Module
Responsibilities:
- Parse binary FIT files uploaded by users
- Extract GPS coordinates (latitude, longitude, elevation)
- Parse activity metrics (heart rate, cadence, power, speed, distance)
- Validate file integrity and format
- Store parsed data in normalized database schema
Key Classes:
FitFileParser: Core parsing logic using FIT SDKTrackPointEntity: Database entity for GPS coordinatesActivityMetricsEntity: Database entity for performance dataFitFileValidator: Validation and sanitization
2. ActivityPub Federation Module
Responsibilities:
- Implement ActivityPub server-to-server (S2S) protocol
- Implement ActivityPub client-to-server (C2S) protocol
- Handle incoming activities from other servers
- Distribute local activities to followers' servers
- Manage actor profiles and collections
Key Components:
Actor Model:
Actor (User Profile)
├── inbox: OrderedCollection
├── outbox: OrderedCollection
├── followers: Collection
├── following: Collection
└── publicKey: For HTTP signature verification
Activity Types:
Create: New workout activity postedUpdate: Activity edited (title, description, privacy)Delete: Activity removedFollow: User follows another athleteAccept: Follow request acceptedAnnounce: Sharing/boosting another user's activityLike: Appreciating someone's workout
Endpoints:
/.well-known/webfinger: User discovery/users/{username}: Actor profile (ActivityPub object)/users/{username}/inbox: Receive activities (POST)/users/{username}/outbox: User's activities (GET)/users/{username}/followers: Followers collection/users/{username}/following: Following collection/activities/{id}: Individual activity objects
3. Geospatial Data Module
Responsibilities:
- Store GPS track data efficiently
- Generate map-ready GeoJSON from track points
- Calculate route statistics (distance, elevation gain/loss)
- Support spatial queries (nearby activities, route matching)
- Render track simplification for performance
Data Structure:
Activity
├── id: UUID
├── user: Actor reference
├── activityType: (Run, Ride, Hike, Swim, etc.)
├── startTime: Timestamp
├── endTime: Timestamp
├── title: String
├── description: Text
├── visibility: (Public, Followers, Private)
├── track: LineString (PostGIS geometry)
├── metrics: JSON (distance, duration, avg_speed, etc.)
└── statistics: JSON (elevation profile, splits, etc.)
GeoJSON Output Format:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [[lon, lat, elevation], ...]
},
"properties": {
"time": "ISO-8601 timestamp",
"heartRate": 145,
"cadence": 85,
"speed": 4.5
}
}]
}
4. Web API Module
REST Endpoints:
Activity Management:
POST /api/activities/upload: Upload FIT fileGET /api/activities/{id}: Retrieve activity detailsGET /api/activities/{id}/track: Get GeoJSON track dataPUT /api/activities/{id}: Update activity metadataDELETE /api/activities/{id}: Remove activityGET /api/activities: List user's activities (paginated)
User Management:
POST /api/users/register: Create new accountGET /api/users/{username}: Public profileGET /api/users/{username}/activities: User's public activitiesPUT /api/users/profile: Update profile information
Social Features:
POST /api/follow/{username}: Follow a userDELETE /api/follow/{username}: UnfollowGET /api/timeline: Federated timeline of followed usersPOST /api/activities/{id}/like: Like an activityPOST /api/activities/{id}/comment: Comment on activity
5. Authentication & Authorization
Implementation:
- JWT tokens for session management
- OAuth 2.0 for third-party integrations (optional)
- HTTP Signatures (required for ActivityPub federation)
- RSA key pairs per user for signature verification
Security Considerations:
- Password hashing with bcrypt
- Rate limiting on API endpoints
- CORS configuration for frontend
- Content-Security-Policy headers
- Input validation and sanitization
- Protection against SSRF in federation
Database Schema
Core Tables
users
- id (UUID, PK)
- username (VARCHAR, UNIQUE)
- email (VARCHAR, UNIQUE)
- password_hash (VARCHAR)
- display_name (VARCHAR)
- bio (TEXT)
- avatar_url (VARCHAR)
- public_key (TEXT)
- private_key (TEXT, encrypted)
- created_at (TIMESTAMP)
- updated_at (TIMESTAMP)
activities
- id (UUID, PK)
- user_id (UUID, FK → users)
- activity_type (VARCHAR)
- title (VARCHAR)
- description (TEXT)
- started_at (TIMESTAMP)
- ended_at (TIMESTAMP)
- visibility (VARCHAR)
- track (GEOMETRY LineString, PostGIS)
- total_distance (DECIMAL)
- total_duration (INTERVAL)
- elevation_gain (DECIMAL)
- elevation_loss (DECIMAL)
- raw_fit_file (BYTEA, optional)
- created_at (TIMESTAMP)
- updated_at (TIMESTAMP)
track_points
- id (BIGSERIAL, PK)
- activity_id (UUID, FK → activities)
- timestamp (TIMESTAMP)
- position (GEOMETRY Point, PostGIS)
- elevation (DECIMAL)
- heart_rate (INTEGER)
- cadence (INTEGER)
- power (INTEGER)
- speed (DECIMAL)
- temperature (DECIMAL)
follows
- id (UUID, PK)
- follower_id (UUID, FK → users)
- following_id (UUID, FK → users OR remote_actor_id)
- status (VARCHAR: pending, accepted)
- created_at (TIMESTAMP)
remote_actors
- id (UUID, PK)
- actor_uri (VARCHAR, UNIQUE)
- username (VARCHAR)
- domain (VARCHAR)
- inbox_url (VARCHAR)
- outbox_url (VARCHAR)
- public_key (TEXT)
- avatar_url (VARCHAR)
- display_name (VARCHAR)
- last_fetched (TIMESTAMP)
activity_pub_activities
- id (UUID, PK)
- activity_type (VARCHAR)
- actor_id (UUID)
- object_id (VARCHAR)
- target_id (VARCHAR)
- content (JSONB)
- created_at (TIMESTAMP)
likes
- id (UUID, PK)
- activity_id (UUID, FK → activities)
- user_id (UUID, FK → users OR remote_actor_id)
- created_at (TIMESTAMP)
comments
- id (UUID, PK)
- activity_id (UUID, FK → activities)
- user_id (UUID, FK → users OR remote_actor_id)
- content (TEXT)
- created_at (TIMESTAMP)
- updated_at (TIMESTAMP)
ActivityPub Integration Details
Actor Object Example
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1"
],
"type": "Person",
"id": "https://fitpub.example/users/runner123",
"preferredUsername": "runner123",
"name": "Jane Runner",
"summary": "Marathon runner | Trail enthusiast | 🏃♀️",
"inbox": "https://fitpub.example/users/runner123/inbox",
"outbox": "https://fitpub.example/users/runner123/outbox",
"followers": "https://fitpub.example/users/runner123/followers",
"following": "https://fitpub.example/users/runner123/following",
"publicKey": {
"id": "https://fitpub.example/users/runner123#main-key",
"owner": "https://fitpub.example/users/runner123",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\n..."
},
"icon": {
"type": "Image",
"mediaType": "image/jpeg",
"url": "https://fitpub.example/avatars/runner123.jpg"
}
}
Activity Object Example (Workout Post)
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"id": "https://fitpub.example/activities/create/12345",
"actor": "https://fitpub.example/users/runner123",
"published": "2025-11-27T10:30:00Z",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://fitpub.example/users/runner123/followers"],
"object": {
"type": "Note",
"id": "https://fitpub.example/workouts/98765",
"attributedTo": "https://fitpub.example/users/runner123",
"content": "Morning 10K run through the park! Felt strong today. 💪",
"published": "2025-11-27T10:30:00Z",
"attachment": [
{
"type": "Document",
"mediaType": "application/geo+json",
"name": "GPS Track",
"url": "https://fitpub.example/workouts/98765/track.geojson"
},
{
"type": "Image",
"mediaType": "image/png",
"name": "Route Map",
"url": "https://fitpub.example/workouts/98765/map.png"
}
],
"tag": [
{
"type": "Hashtag",
"name": "#running"
},
{
"type": "Hashtag",
"name": "#10k"
}
],
"summary": "10.2 km • 48:23 • 4:44/km pace",
"workoutData": {
"distance": 10200,
"duration": "PT48M23S",
"activityType": "Run",
"averagePace": "PT4M44S",
"elevationGain": 127,
"averageHeartRate": 152
}
}
}
WebFinger Implementation
Request:
GET /.well-known/webfinger?resource=acct:runner123@fitpub.example
Response:
{
"subject": "acct:runner123@fitpub.example",
"aliases": [
"https://fitpub.example/users/runner123"
],
"links": [
{
"rel": "self",
"type": "application/activity+json",
"href": "https://fitpub.example/users/runner123"
},
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "https://fitpub.example/@runner123"
}
]
}
FIT File Processing Pipeline
Parse Flow
-
Upload Validation
- Verify file size (max 50MB)
- Check MIME type
- Validate FIT file header
-
Parsing
- Use FIT SDK to decode binary format
- Extract messages: FileId, Record, Lap, Session, Activity
- Handle corrupted or incomplete files gracefully
-
Data Extraction
- Record Messages: GPS coordinates, timestamp, heart rate, cadence, speed, power
- Lap Messages: Split data, lap times, lap distances
- Session Messages: Total distance, total time, average/max values
- Activity Messages: Activity type, timestamp
-
Data Transformation
- Convert semicircles to decimal degrees (lat/lon)
- Calculate derived metrics (pace, grade-adjusted pace)
- Detect pauses and stopped periods
- Smooth GPS noise using Kalman filtering (optional)
-
Storage
- Batch insert track points (optimize for performance)
- Create PostGIS LineString geometry from points
- Calculate bounding box for spatial indexing
- Generate activity statistics
-
Map Rendering Preparation
- Simplify track using Douglas-Peucker algorithm for web display
- Generate elevation profile data
- Create thumbnail static map image (optional)
- Prepare GeoJSON response
Privacy & Visibility Controls
Visibility Levels
- Public: Visible to everyone, federated across ActivityPub
- Followers Only: Visible to approved followers, sent to follower inboxes
- Private: Visible only to the user, not federated
Privacy Features
- Ability to hide exact start/end locations (fuzzy start/finish)
- Option to exclude specific segments from public view
- Bulk privacy updates for historical activities
- Export all personal data (GDPR compliance)
- Delete account with activity cleanup
Map Rendering
Frontend Map Stack
Leaflet.js Configuration:
- Base layer: OpenStreetMap tiles
- Alternative layers: Satellite, Terrain (Thunderforest, Mapbox)
- Custom track overlay as GeoJSON layer
- Markers for start (green) and finish (red)
- Popup markers for lap splits
- Heatmap overlay for intensity (heart rate zones)
Interactive Features:
- Click on track to see point-in-time metrics
- Elevation profile chart synchronized with map
- Segment highlighting
- Playback animation of activity
- Compare multiple activities on same map
Static Map Generation
For ActivityPub federated posts and thumbnails:
- Use StaticMap library or external service
- Generate PNG/JPEG preview of route
- Include in ActivityPub attachment
- Cache generated images
Federation Workflow Examples
Scenario 1: User Posts New Activity
- User uploads FIT file via web UI
- Backend parses file and stores data
- User adds title, description, and sets visibility to "Public"
- System creates ActivityPub
Createactivity - Activity is added to user's outbox
- System retrieves list of followers
- For each remote follower:
- Sign HTTP request with user's private key
- POST activity to follower's server inbox
- Remote servers receive and process the activity
- Activity appears in followers' timelines on their platforms
Scenario 2: Remote User Follows Local User
- Remote user (on Mastodon) clicks "Follow" on local user's profile
- Mastodon server sends
Followactivity to local user's inbox - FitPub receives and validates the activity
- FitPub creates
Acceptactivity in response - FitPub stores the follow relationship
- FitPub sends
Acceptto remote server's inbox - Follow relationship is now active
- Future public activities will be sent to remote follower
Scenario 3: Remote User Likes Local Activity
- Remote user views local activity on their platform
- User clicks "Like" or equivalent action
- Remote server sends
Likeactivity to local inbox - FitPub receives and processes the like
- Like count is incremented and stored
- Like appears on activity page
- Original poster may receive notification
Development Roadmap
Phase 1: MVP (Minimum Viable Product)
System Component 1: FIT File Processing Module ✅
- FIT file upload and parsing (FitParser)
- FIT file validation (FitFileValidator)
- Activity entity with JSONB track points and simplified LineString
- Activity metrics extraction and storage
- Track simplification using Douglas-Peucker algorithm
- FIT file service with comprehensive tests
- Integration test with real FIT file
User Management & Security ✅
- User entity with ActivityPub keys
- UserRepository with custom queries
- Password hashing with BCrypt
- JWT token provider for session management
- HTTP Signature validator for ActivityPub federation
- UserDetailsService implementation
- Security configuration (Spring Security)
- User registration endpoint (POST /api/auth/register)
- Login endpoint with JWT response (POST /api/auth/login)
Application Infrastructure ✅
- Main application class (FitPubApplication.java)
- Application configuration (application.yml)
- Database configuration (PostgreSQL + PostGIS with Testcontainers Dev Services)
- CORS configuration for frontend
- Exception handling (global error handlers)
- Logging configuration
- Profile-specific configs (application-dev.yml, application-prod.yml)
Activity REST API ✅
- POST /api/activities/upload - Upload FIT file
- GET /api/activities/{id} - Get activity details
- GET /api/activities - List user's activities (paginated)
- PUT /api/activities/{id} - Update activity metadata
- DELETE /api/activities/{id} - Delete activity
- Activity DTOs for API responses
- All endpoints tested and working
ActivityPub Actor Profile ✅
- Actor model classes (Person, PublicKey)
- GET /users/{username} - Actor profile endpoint
- Actor JSON-LD serialization with @context
- Public key embedding in actor profile
- Profile metadata (name, bio, avatar)
- Tested with application/activity+json and application/ld+json
WebFinger Support ✅
- WebFinger controller
- GET /.well-known/webfinger - User discovery
- WebFinger response DTO
- Account identifier parsing (acct:user@domain)
- Tested with valid and invalid requests
ActivityPub Collections ✅
- POST /users/{username}/inbox - Inbox endpoint (accepts activities with 202 Accepted)
- GET /users/{username}/outbox - Outbox endpoint (returns empty OrderedCollection)
- GET /users/{username}/followers - Followers collection (returns empty OrderedCollection)
- GET /users/{username}/following - Following collection (returns empty OrderedCollection)
- OrderedCollection model classes
- Basic collection structure (TODOs exist for populating with actual data)
- All endpoints tested and working
Basic Federation ✅
- Federation service for outbound activities (FederationService.java)
- HTTP signature signing for outbound requests (signRequest method in HttpSignatureValidator)
- HTTP signature verification for inbound requests (validate method already existed)
- Follow activity - Remote user follows local user (InboxProcessor)
- Accept activity - Accept follow requests (FederationService.sendAcceptActivity)
- Undo activity - Unfollow support (InboxProcessor)
- Follow entity and repository (Follow.java, FollowRepository.java)
- Remote actor entity and repository (RemoteActor.java, RemoteActorRepository.java)
- Inbox processor for incoming activities (InboxProcessor.java)
- Remote actor fetching and caching
- Follower inbox collection for activity distribution
Public Timeline ✅
- Timeline service (TimelineService.java)
- Timeline DTOs for response (TimelineActivityDTO.java with ActivityMetricsSummary)
- GET /api/timeline/federated - Federated timeline for authenticated user
- GET /api/timeline/public - Public timeline (all public activities)
- GET /api/timeline/user - User's own timeline
- Timeline filtering and pagination (Spring Data Pageable)
- Activity visibility enforcement (PUBLIC, FOLLOWERS)
- Repository methods for timeline queries (findByUserIdInAndVisibilityInOrderByStartedAtDesc, findByVisibilityOrderByStartedAtDesc)
Database Migrations ✅
- Flyway setup and configuration
- V1: Enable PostGIS extension
- V2: Users table with indexes (username, email, created_at)
- V3: Activities table with geospatial support (GIST index on simplified_track, GIN index on track_points_json)
- V4: Activity metrics table with one-to-one relationship
- V5: Follows table for federation (follower_id, following_actor_uri, status)
- V6: Remote actors table for ActivityPub federation cache
- All indexes for performance (user lookups, activity queries, spatial queries)
- Changed Hibernate ddl-auto from 'update' to 'validate'
Frontend Infrastructure ✅
- Choose frontend approach (Thymeleaf + HTMX for server-side rendering with dynamic interactions)
- Static asset structure (css/, js/, img/ directories)
- HTMX dependency setup (via CDN in layout.html)
- Leaflet.js dependency setup (via CDN in layout.html)
- Chart.js dependency setup (via CDN in layout.html)
- CSS framework setup (Bootstrap 5.3.2 via CDN + Bootstrap Icons)
- Base Thymeleaf layout template with navigation (layout.html)
- Responsive mobile design foundation (Bootstrap grid + custom CSS)
- Custom CSS with FitPub theme (fitpub.css)
- Custom JavaScript utilities (fitpub.js with map/chart helpers)
- Thymeleaf dependencies added to pom.xml
- Home page template (index.html)
- Home controller for routing
Authentication UI ✅
- User registration page/form (auth/register.html)
- Login page/form (auth/login.html)
- JWT token storage (localStorage in auth.js)
- Authentication state management (FitPubAuth object in auth.js)
- Protected route handling (SecurityConfig.java + client-side checks)
- Logout functionality (client-side token removal + server endpoint)
- Session expiration handling (JWT expiration check + warning)
- Login/registration error display (alert components in forms)
- Authentication view controller (AuthViewController.java)
- Dynamic navigation menu (shows/hides based on auth status)
- Form validation with Bootstrap
- Loading states for submit buttons
- Password confirmation validation
- Authenticated API fetch helper (authenticatedFetch in auth.js)
Activity Upload & Management UI ✅
- FIT file upload form with drag-and-drop
- Upload progress indicator
- Activity metadata form (title, description, visibility)
- Activity list view (user's own activities)
- Activity pagination controls
- Activity delete confirmation dialog
- Activity edit form
- File upload validation and error messages
Map Rendering & Visualization ✅
- Leaflet.js map initialization
- OpenStreetMap tile layer integration
- GeoJSON track rendering on map
- Start/finish markers (green/red)
- Map bounds auto-fitting to track
- Track click handler for point-in-time metrics
- Map loading states and error handling
- Responsive map sizing
Activity Detail Page
- Activity metadata display (title, description, date, type)
- Interactive map with GPS track
- Activity metrics display (distance, duration, pace, elevation)
- Elevation profile chart (Chart.js)
- Heart rate chart (if available)
- Speed/pace chart
- Activity statistics summary cards
- Visibility indicator (Public/Followers/Private)
Timeline & Social Features UI
- Public timeline page
- Federated timeline page (following feed)
- User timeline page (own activities)
- Timeline activity cards with preview maps
- Activity card metrics summary
- Pagination for timeline
- Empty state messages
- Loading states for timelines
User Profile UI
- Public user profile page
- User profile display (avatar, bio, display name)
- User's activity list on profile
- Follower/following counts
- Profile edit page
- Avatar upload (optional for MVP)
- Profile settings form
Navigation & Layout
- Top navigation bar with logo
- Navigation links (Timeline, My Activities, Upload, Profile)
- User menu dropdown (Profile, Settings, Logout)
- Breadcrumb navigation
- Footer with app info
- Mobile hamburger menu
- Active route highlighting
Error Handling & User Feedback
- Global error boundary/handler
- API error message display
- Success notifications/toasts
- Form validation error display
- 404 Not Found page
- 403 Forbidden page
- Loading spinners/skeletons
- Empty state illustrations
Testing & Documentation
- Integration tests for REST endpoints
- Integration tests for ActivityPub federation
- Integration tests for WebFinger
- Frontend E2E tests (optional: Playwright/Cypress)
- README with setup instructions
- API documentation (Swagger/OpenAPI)
- Database setup guide
- Deployment instructions
- Frontend development guide
Phase 2: Social Features
- Likes and comments
- Activity sharing (Announce)
- User search and discovery
- Followers/following lists
- Notifications system
- Privacy controls
- Activity editing and deletion
Phase 3: Advanced Analytics
- Personal records tracking
- Training load and recovery metrics
- Segment comparison (Strava-like)
- Achievement/badge system
- Weekly/monthly summaries
- Route recommendations
- Weather data integration
Phase 4: Enhanced Federation
- Rich preview cards for activities
- Media attachments (photos from workout)
- Activity challenges (federated events)
- Group/club support
- Cross-platform activity sync
Phase 5: Mobile & Integrations
- Mobile-responsive web design
- Progressive Web App (PWA)
- Native mobile apps (optional)
- Direct device sync (Garmin Connect API)
- Webhook integrations
- Import from Strava, Garmin, etc.
Maven Project Structure
fitpub/
├── pom.xml
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── fitpub/
│ │ │ ├── FitPubApplication.java
│ │ │ ├── config/
│ │ │ │ ├── SecurityConfig.java
│ │ │ │ ├── WebConfig.java
│ │ │ │ └── ActivityPubConfig.java
│ │ │ ├── controller/
│ │ │ │ ├── ActivityController.java
│ │ │ │ ├── UserController.java
│ │ │ │ ├── ActivityPubController.java
│ │ │ │ └── WebFingerController.java
│ │ │ ├── service/
│ │ │ │ ├── FitFileService.java
│ │ │ │ ├── ActivityService.java
│ │ │ │ ├── FederationService.java
│ │ │ │ ├── UserService.java
│ │ │ │ └── GeospatialService.java
│ │ │ ├── model/
│ │ │ │ ├── entity/
│ │ │ │ │ ├── User.java
│ │ │ │ │ ├── Activity.java
│ │ │ │ │ ├── TrackPoint.java
│ │ │ │ │ ├── Follow.java
│ │ │ │ │ └── RemoteActor.java
│ │ │ │ ├── dto/
│ │ │ │ │ ├── ActivityDTO.java
│ │ │ │ │ ├── UserDTO.java
│ │ │ │ │ └── TrackDTO.java
│ │ │ │ └── activitypub/
│ │ │ │ ├── Actor.java
│ │ │ │ ├── Activity.java
│ │ │ │ └── Collection.java
│ │ │ ├── repository/
│ │ │ │ ├── UserRepository.java
│ │ │ │ ├── ActivityRepository.java
│ │ │ │ ├── TrackPointRepository.java
│ │ │ │ └── FollowRepository.java
│ │ │ ├── security/
│ │ │ │ ├── JwtTokenProvider.java
│ │ │ │ ├── HttpSignatureValidator.java
│ │ │ │ └── UserDetailsServiceImpl.java
│ │ │ └── util/
│ │ │ ├── FitParser.java
│ │ │ ├── GeoJsonConverter.java
│ │ │ └── ActivityPubUtil.java
│ │ └── resources/
│ │ ├── application.yml
│ │ ├── application-dev.yml
│ │ ├── application-prod.yml
│ │ ├── static/
│ │ │ ├── css/
│ │ │ ├── js/
│ │ │ └── img/
│ │ └── templates/
│ │ ├── index.html
│ │ ├── activity.html
│ │ └── profile.html
│ └── test/
│ └── java/
│ └── com/
│ └── fitpub/
│ ├── service/
│ ├── controller/
│ └── integration/
└── README.md
Key Maven Dependencies
<dependencies>
<!-- Spring Boot Starters -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Database -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
</dependency>
<!-- FIT File Processing -->
<dependency>
<groupId>com.garmin</groupId>
<artifactId>fit</artifactId>
<version>21.XX.XX</version>
</dependency>
<!-- JSON Processing -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- HTTP Client -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
</dependency>
<!-- Validation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Configuration Examples
application.yml
spring:
application:
name: fitpub
datasource:
url: jdbc:postgresql://localhost:5432/fitpub
username: fitpub_user
password: ${DB_PASSWORD}
jpa:
hibernate:
ddl-auto: validate
properties:
hibernate:
dialect: org.hibernate.spatial.dialect.postgis.PostgisDialect
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB
fitpub:
domain: fitpub.example
base-url: https://fitpub.example
activitypub:
enabled: true
max-federation-retries: 3
security:
jwt:
secret: ${JWT_SECRET}
expiration: 86400000 # 24 hours
storage:
fit-files:
path: /var/fitpub/fit-files
retention-days: 365
Deployment Considerations
Infrastructure Requirements
- Application Server: JVM-based (Java 17+)
- Database: PostgreSQL 13+ with PostGIS extension
- Reverse Proxy: Nginx or Traefik for HTTPS termination
- Storage: File storage for FIT files and generated assets
- Cache: Redis (optional, for session management)
Scaling Strategy
- Horizontal scaling of application servers
- Database read replicas for heavy read operations
- CDN for static assets and map tiles
- Background job processing for FIT file parsing (Spring Batch or async)
- Rate limiting and request throttling
Monitoring & Observability
- Application metrics (Micrometer + Prometheus)
- Database query performance monitoring
- Federation success/failure rates
- API response times
- User activity analytics
Legal & Compliance
Licensing Considerations
- Choose appropriate open-source license (AGPL, MIT, Apache 2.0)
- Comply with FIT SDK licensing terms
- Attribute map tile providers
- Terms of Service for user-generated content
- Privacy Policy (GDPR, CCPA compliance)
Data Retention
- User data export functionality
- Right to be forgotten (account deletion)
- Activity data backup procedures
- Federation data cleanup (remove data from remote deleted actors)
Community & Contribution
Open Source Goals
- Public GitHub repository
- Contribution guidelines
- Code of conduct
- Issue templates
- Documentation for developers
- Public roadmap and feature requests
Fediverse Integration
- Publish FEP (Fediverse Enhancement Proposal) if introducing custom extensions
- Collaborate with other ActivityPub developers
- Test interoperability with major platforms (Mastodon, Pleroma, Pixelfed)
- Participate in Fediverse developer community
Future Enhancements
- AI-Powered Insights: Training recommendations, injury prevention
- Virtual Racing: Compete on same routes asynchronously
- Route Planning: Create routes and share with community
- Live Tracking: Real-time activity sharing during workout
- Wearable Integration: Direct sync with smartwatches
- Audio Cues: Export audio-guided workouts
- Social Challenges: Group goals and competitions
- Marketplace: Routes, training plans, coaching services
Getting Started
Prerequisites
- Java 17 or higher
- Maven 3.8+
- PostgreSQL 13+ with PostGIS
- Git
Quick Start
- Clone repository
- Set up PostgreSQL database with PostGIS extension
- Configure
application.ymlwith database credentials - Run
mvn clean install - Start application:
mvn spring-boot:run - Access at
http://localhost:8080
First Steps
- Register a user account
- Upload a FIT file from your GPS device
- View your activity on the interactive map
- Set up ActivityPub federation (optional)
- Follow other athletes on the Fediverse
Project Status: Planning & Initial Development
License: TBD
Contributors Welcome: Yes
Contact: [Project repository or contact information]