How shreyash-03-codes/sportiq works
Purpose and deployment shape
SportIQ is a full-stack application for authenticated users to submit sports-skill videos, receive AI analysis and scores, and view saved analysis history. It consists of an Angular SPA, a Spring Boot API, PostgreSQL persistence, FFmpeg-based video processing, and an Ollama-backed Spring AI integration. Container orchestration is defined in docker-compose.yml; service images are built from backend/Dockerfile and frontend/Dockerfile.
Entry points and API boundary
The backend starts at backend/src/main/java/com/sportiq/backend/BackendApplication.java. HTTP endpoints are organized by responsibility: authentication, user/profile, sport/skill discovery, and analysis submission/history:
• backend/src/main/java/com/sportiq/backend/web/AuthController.java
• backend/src/main/java/com/sportiq/backend/web/AnalysisController.java
• backend/src/main/java/com/sportiq/backend/web/SportController.java
Controllers accept/return web DTOs and delegate business work to services; GlobalExceptionHandler converts domain, validation, media, and LLM failures to API errors.
Frontend application
The Angular application bootstraps from frontend/src/main.ts, with route and provider composition in frontend/src/app/app.routes.ts and frontend/src/app/app.config.ts. Major user workflows are login/registration, analysis upload, history, and profile:
• frontend/src/app/analyze/analyze.component.ts
• frontend/src/app/history/history.component.ts
• frontend/src/app/core/analysis.service.ts
Core services call the backend. An authentication interceptor attaches tokens, while route guards separate authenticated and guest-only routes (frontend/src/app/core/auth.interceptor.ts, frontend/src/app/core/auth.guard.ts).
Identity and authorization
JWT security is enforced at the backend boundary. SecurityConfig configures protected access; JwtAuthenticationFilter extracts and validates bearer tokens; JwtService creates and verifies tokens. AuthService owns registration/login behavior and persists users through AppUserRepository.
• backend/src/main/java/com/sportiq/backend/security/SecurityConfig.java
• backend/src/main/java/com/sportiq/backend/security/JwtAuthenticationFilter.java
• backend/src/main/java/com/sportiq/backend/service/AuthService.java
Analysis pipeline
AnalysisService is the orchestration point for a submitted video. The expected flow is: validate uploaded video → extract frames via FFmpeg/process execution → construct skill-specific AI prompt → invoke Ollama → validate structured AI output → persist a session and associated score(s) → return an analysis response. Media files are temporary operational artifacts and are cleaned up by the media layer.
• backend/src/main/java/com/sportiq/backend/service/AnalysisService.java
• backend/src/main/java/com/sportiq/backend/media/VideoValidationService.java
• backend/src/main/java/com/sportiq/backend/media/FrameExtractionService.java
• backend/src/main/java/com/sportiq/backend/ai/SpringAiOllamaService.java
• backend/src/main/java/com/sportiq/backend/ai/AnalysisValidator.java
AI and media infrastructure boundaries
The AI adapter is isolated in ai: PromptService selects/builds prompts using SkillPrompt; SpringAiOllamaService calls the external Ollama model runtime; AnalysisResult is the internal result contract. FFmpeg is an external host/container executable invoked through ProcessRunner, with properties separating executable/media configuration from business logic.
• backend/src/main/java/com/sportiq/backend/ai/AiConfig.java
• backend/src/main/java/com/sportiq/backend/media/ProcessRunner.java
• backend/src/main/java/com/sportiq/backend/media/FfmpegProperties.java
Domain persistence and history
JPA entities model users, sport/skill taxonomy, analysis sessions, and scores. SportSkillService supplies available sports/skills; HistoryService retrieves user-scoped sessions; AnalysisService creates durable results. Repository interfaces form the persistence boundary, backed by PostgreSQL in deployment and integration testing.
• backend/src/main/java/com/sportiq/backend/entity/AnalysisSession.java
• backend/src/main/java/com/sportiq/backend/entity/AnalysisScore.java
• backend/src/main/java/com/sportiq/backend/service/HistoryService.java
• backend/src/main/java/com/sportiq/backend/repository/AnalysisSessionRepository.java
Configuration and initialization
Spring configuration resides in backend/src/main/resources/application.yml, with container-specific overrides in backend/src/main/resources/application-docker.yml. DataSeeder initializes the sport/skill catalog, making taxonomy available to both analysis prompt selection and frontend selection flows.
• backend/src/main/java/com/sportiq/backend/config/DataSeeder.java
• backend/src/main/resources/application.yml
Main entry points: AnalysisController.java HTTP controllers · AnalysisSessionRepository.java JPA repositories · docker-compose.yml Container orchestration · AnalysisService.java Analysis orchestration
Components 19
Angular SPA
- Angular application · Authenticated video analysis UI.
frontend/src/main.ts - Routes and providers
frontend/src/app/app.routes.ts - Analyze and history UI
frontend/src/app/analyze/analyze.component.ts - Analysis API client
frontend/src/app/core/analysis.service.ts - Token interceptor and guards · Attaches tokens and gates routes.
frontend/src/app/core/auth.interceptor.ts
Spring Boot API
- Spring Boot API
backend/src/main/java/com/sportiq/backend/BackendApplication.java - HTTP controllers · Auth, analysis, and sport endpoints use web DTOs.
backend/src/main/java/com/sportiq/backend/web/AnalysisController.java - JWT security · Protects API requests and validates bearer tokens.
backend/src/main/java/com/sportiq/backend/security/SecurityConfig.java - Authentication service · Registers users and issues JWTs.
backend/src/main/java/com/sportiq/backend/service/AuthService.java - History and sport catalog · Provides user-scoped history and available skills.
backend/src/main/java/com/sportiq/backend/service/HistoryService.java
Analysis pipeline
- Analysis orchestration · Coordinates media, AI, and durable results.
backend/src/main/java/com/sportiq/backend/service/AnalysisService.java - Video validation and frames · Validates uploads and cleans temporary media artifacts.
backend/src/main/java/com/sportiq/backend/media/FrameExtractionService.java - AI prompt and validation · Builds skill prompts and validates structured model output.
backend/src/main/java/com/sportiq/backend/ai/AnalysisValidator.java
Persistence
- JPA repositories
backend/src/main/java/com/sportiq/backend/repository/AnalysisSessionRepository.java - PostgreSQL · Stores users, taxonomy, sessions, and scores.
- Sport and skill seeder · Initializes the taxonomy catalog.
backend/src/main/java/com/sportiq/backend/config/DataSeeder.java
External runtimes
- FFmpeg process · Invoked through ProcessRunner to extract frames.
backend/src/main/java/com/sportiq/backend/media/ProcessRunner.java - Ollama runtime
backend/src/main/java/com/sportiq/backend/ai/SpringAiOllamaService.java - Container orchestration · Runs application and infrastructure services.
docker-compose.yml
Connections 23
- Angular application → Routes and providers: bootstraps
- Routes and providers → Analyze and history UI: routes users
- Analyze and history UI → Analysis API client: submits and reads analyses
- Token interceptor and guards → Analysis API client: adds bearer token
- Analysis API client → HTTP controllers: HTTP API
- Spring Boot API → HTTP controllers: hosts
- HTTP controllers → JWT security: protected requests
- HTTP controllers → Authentication service: login and registration
- HTTP controllers → Analysis orchestration: analysis submission
- HTTP controllers → History and sport catalog: history and skills
- Analysis orchestration → Video validation and frames: validates and extracts frames
- Video validation and frames → FFmpeg process: executes
- Analysis orchestration → AI prompt and validation: sends frames and skill context
- AI prompt and validation → Ollama runtime: model invocation
- Analysis orchestration → JPA repositories: persists sessions and scores
- Authentication service → JPA repositories: persists users
- History and sport catalog → JPA repositories: reads user data and taxonomy
- JPA repositories → PostgreSQL: JPA persistence
- Sport and skill seeder → JPA repositories: seeds taxonomy
- Container orchestration → Spring Boot API: runs backend image
- Container orchestration → Angular application: runs frontend image
- Container orchestration → PostgreSQL: runs database
- Container orchestration → Ollama runtime: runs model runtime