{"id":29749040,"url":"https://github.com/vinayakvispute/go-workout-tracker-api","last_synced_at":"2025-10-24T17:02:26.630Z","repository":{"id":292570358,"uuid":"948129751","full_name":"VinayakVispute/go-workout-tracker-api","owner":"VinayakVispute","description":"The Go Workout Tracker API is built using Go to help users track and manage workout routines and fitness data efficiently. It offers APIs for logging exercises, tracking progress, and analyzing metrics, ensuring scalability and performance for fitness enthusiasts and developers.","archived":false,"fork":false,"pushed_at":"2025-05-11T18:22:21.000Z","size":79,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T11:42:28.968Z","etag":null,"topics":["api","backend-api","backend-development","fitness-tracker","go","golang","webservice"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VinayakVispute.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-13T19:53:30.000Z","updated_at":"2025-05-11T18:25:05.000Z","dependencies_parsed_at":"2025-05-10T20:36:43.637Z","dependency_job_id":null,"html_url":"https://github.com/VinayakVispute/go-workout-tracker-api","commit_stats":null,"previous_names":["vinayakvispute/go-workout-tracker-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VinayakVispute/go-workout-tracker-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinayakVispute%2Fgo-workout-tracker-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinayakVispute%2Fgo-workout-tracker-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinayakVispute%2Fgo-workout-tracker-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinayakVispute%2Fgo-workout-tracker-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VinayakVispute","download_url":"https://codeload.github.com/VinayakVispute/go-workout-tracker-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VinayakVispute%2Fgo-workout-tracker-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267156088,"owners_count":24044409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","backend-api","backend-development","fitness-tracker","go","golang","webservice"],"created_at":"2025-07-26T11:16:24.697Z","updated_at":"2025-10-24T17:02:26.538Z","avatar_url":"https://github.com/VinayakVispute.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workout Tracker API\n\nA robust RESTful API built with Go for tracking and managing workout sessions. This application allows users to create, read, update, and delete workout records with detailed exercise entries.\n\n## Project Overview\n\nThis project is a Go-based backend service that provides a complete workout tracking solution with user authentication. The application follows clean architecture principles with clear separation of concerns between handlers, business logic, and data storage.\n\n### Key Features\n\n- **User Authentication**: Secure registration and token-based authentication\n- **Workout Management**: Create, read, update, and delete workout sessions\n- **Exercise Tracking**: Add detailed exercise entries to workouts including sets, reps, duration, and weight\n- **Authorization**: Users can only modify their own workouts\n\n## Technology Stack\n\n- **Language**: Go 1.24.1\n- **Web Framework**: Chi Router\n- **Database**: PostgreSQL\n- **Authentication**: JWT-based token authentication\n- **Containerization**: Docker and Docker Compose for development environment\n\n## Project Structure\n\n```\ngo-workout-tracker-api/\n├── database/               # Database data directories\n├── docs/                   # Detailed documentation\n├── docker-compose.yml      # Docker configuration for PostgreSQL\n├── go.mod                  # Go module dependencies\n├── go.sum                  # Go module checksums\n├── internal/               # Application internal packages\n│   ├── api/                # API handlers\n│   │   ├── tokens_handler.go\n│   │   ├── user_handler.go\n│   │   └── workout_handler.go\n│   ├── app/                # Application setup and configuration\n│   │   └── app.go\n│   ├── middleware/         # HTTP middleware\n│   ├── routes/             # Route definitions\n│   │   └── routes.go\n│   ├── store/              # Data access layer\n│   │   ├── database.go\n│   │   ├── tokens.go\n│   │   ├── user_store.go\n│   │   └── workout_store.go\n│   ├── tokens/             # Token management\n│   └── utils/              # Utility functions\n├── main.go                 # Application entry point\n└── migrations/             # Database migrations\n└── .env                    # Environment variables\n```\n\n## API Endpoints\n\n### Authentication\n\n- `POST /users` - Register a new user\n- `POST /tokens/authentication` - Create authentication token (login)\n\n### Workouts (Authenticated Routes)\n\n- `GET /workouts/{id}` - Get a specific workout by ID\n- `POST /workouts` - Create a new workout\n- `PUT /workouts/{id}` - Update an existing workout\n- `DELETE /workouts/{id}` - Delete a workout\n\n### Health Check\n\n- `GET /health` - Check API health status\n\n## Data Models\n\n### Workout\n\n```go\ntype Workout struct {\n    ID              int            `json:\"id\"`\n    UserID          int            `json:\"user_id\"`\n    Title           string         `json:\"title\"`\n    Description     string         `json:\"description\"`\n    DurationMinutes int            `json:\"duration_minutes\"`\n    CaloriesBurned  int            `json:\"calories_burned\"`\n    Entries         []WorkoutEntry `json:\"entries\"`\n}\n```\n\n### Workout Entry\n\n```go\ntype WorkoutEntry struct {\n    ID              int      `json:\"id\"`\n    ExerciseName    string   `json:\"exercise_name\"`\n    Sets            int      `json:\"sets\"`\n    Reps            *int     `json:\"reps\"`\n    DurationSeconds *int     `json:\"duration_seconds\"`\n    Weight          *float64 `json:\"weight\"`\n    Notes           string   `json:\"notes\"`\n    OrderIndex      int      `json:\"order_index\"`\n}\n```\n\n### User\n\n```go\ntype User struct {\n    ID           int       `json:\"id\"`\n    Username     string    `json:\"username\"`\n    Email        string    `json:\"email\"`\n    PasswordHash password  `json:\"-\"` // Not exposed in JSON\n    Bio          string    `json:\"bio\"`\n    CreatedAt    time.Time `json:\"created_at\"`\n    UpdatedAt    time.Time `json:\"updated_at\"`\n}\n```\n\n### Token\n\n```go\ntype Token struct {\n    Plaintext string    `json:\"token\"`\n    Hash      []byte    `json:\"-\"` // Not exposed in JSON\n    UserID    int       `json:\"-\"` // Not exposed in JSON\n    Expiry    time.Time `json:\"expiry\"`\n    Scope     string    `json:\"-\"` // Not exposed in JSON\n}\n```\n\n## Getting Started\n\n### Prerequisites\n\n- Go 1.24.1 or higher\n- Docker and Docker Compose (for local development)\n\n### Setup and Installation\n\n1. Clone the repository:\n\n   ```\n   git clone https://github.com/vinayakvispute/go-lang.git\n   cd go-lang\n   ```\n\n2. Create a `.env` file in the root directory with this env variable and add your own database credentials:\n\n   ```env\n   DB_HOST=localhost\n   DB_PORT=5432\n   DB_USER=your_db_user\n   DB_PASSWORD=your_db_password\n   DB_NAME=your_db_name\n   DB_SSLMODE=your_jwt_secret\n\n   ```\n\n3. Start the PostgreSQL database:\n\n   ```\n   docker-compose up\n   ```\n\n4. Run the application:\n\n   ```\n   go run main.go\n   ```\n\n   By default, the server runs on port 8080. You can specify a different port using the `-port` flag:\n\n   ```\n   go run main.go -port 3000\n   ```\n\n## Development\n\n### Database Migrations\n\nThe application uses the `goose` migration tool to manage database schema changes. Migrations are automatically applied when the application starts.\n\n### Testing\n\nTo run tests:\n\n```\ngo test ./...\n```\n\nA separate test database is configured in the Docker Compose file to ensure tests don't interfere with development data.\n\n## Security Considerations\n\n- Authentication is implemented using JWT tokens\n- Passwords are securely hashed before storage\n- API endpoints are protected with middleware to ensure proper authorization\n- Users can only access and modify their own workout data\n\n## Future Enhancements\n\n- Add support for workout categories and tags\n- Implement workout statistics and reporting\n- Add social features like sharing workouts\n- Create mobile app integration\n\n## Documentation\n\nDetailed documentation for the API, including endpoints, data models, and implementation details, can be found in the [docs/](./docs/) directory.\n\n### Code Improvement's To-Do List\n\n- [ ] Create detailed documentation in docs/ directory covering API endpoints, data models, and implementation details\n- [ ] Implement query timeouts for database operations\n- [ ] Add proper database locking mechanisms\n- [ ] Improve concurrency handling\n- [ ] Add more comprehensive error handling\n\n## Important Commands\n\n```bash\npm2 start /root/go-workout-tracker-api/mainFile \\\n  --name workout-api \\\n  --cwd /root/go-workout-tracker-api \\\n  --time            # timestamps in logs\n\npm2 save            # remember the process list for reboot\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinayakvispute%2Fgo-workout-tracker-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinayakvispute%2Fgo-workout-tracker-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinayakvispute%2Fgo-workout-tracker-api/lists"}