How giavinh79/gymtrackapiv2 works
Main Components
• API Server (Spring Boot)
• Represented by the bulk of the source code under src/main/java, organized by feature (e.g., auth, exercise, routine, etc.).
• Contains controllers, services, repositories, exception handling, and filters.
• Database (PostgreSQL)
• Managed by Flyway using versioned SQL migration files (located in src/main/resources/db/migration).
• Connections to PostgreSQL are set up locally via Docker (see docker-compose.yml in the db folder).
• External Services and Integrations
• Firebase: Used for authentication (code and filters under src/main/java/com/gymtrack/api/filter/auth and src/main/java/com/gymtrack/api/platform/firebase).
• Cache: Redis is mentioned in the README (commands are provided for clearing it via Docker), even though it might be part of the Docker Compose in the db folder.
• AWS Secrets Manager (not yet implemented but mentioned for production) and AWS S3 for image storage.
• CI/CD and Deployment
• GitHub Actions (workflow files in .github/workflows) for automated builds and tests.
• The deployment is set to eventually utilize AWS Lightsail with a Supabase-hosted PostgreSQL instance.
• Additional Components:
• Postman collection for API testing located in the postman folder.
• Infrastructure configurations such as appspec.yml and buildspec.yml.
• Build automation with Maven, denoted by pom.xml and maven-wrapper files.
Relationships and Interactions
• The API Server (Spring Boot) communicates with
• the PostgreSQL database for data persistence (via repositories).
• external authentication services (Firebase) for securing protected API endpoints.
• Redis for caching (if used during runtime).
• The controllers route requests that propagate to the corresponding services and then to the repositories.
• The data migration and schema evolution is handled by Flyway on the PostgreSQL instance.
• The CI/CD pipeline (via GitHub Actions) automates testing, building, and potentially deployment tasks.
• The front-end communicates with this API server via REST calls and the documentation is available via Swagger.
Architectural Patterns and Principles
• N-tier Architecture:
• The project organization by feature/domain across separate packages (controllers, services, repositories) reflects a layered architecture.
• Dependency Injection:
• Standard in Spring Boot for managing service and repository lifecycles.
• Externalized Configuration and Secrets Management:
• The project employs configuration files (application.yml, application-prod.sample.yml, etc.) for language-level and environment level configuration.
• Versioned Database Migrations:
• Use of Flyway guarantees that each deployment’s database schema is in sync with application expectations.
• Modularization by Feature:
Technologies and Frameworks
• Java Spring Boot
• PostgreSQL (via Docker for local development)
• Docker Compose (for orchestrating the database and possibly Redis/pgAdmin)
• Firebase (for authentication)
• Flyway (for database migrations)
• MapStruct (for DTO and entity mapping)
• Maven (for build automation)
• GitHub Actions (for CI/CD)