This repository contains the backend API for a workout tracker application. It allows users to manage workout templates, log their workouts (including exercises and sets), and track their progress. Built with .NET 8, ASP.NET Core Web API, Entity Framework Core, and MS SQL Server.
- User Authentication & Authorization: Secure registration and login using JWT tokens. Users can only access their own data.
- Workout Templates: Predefined workout plans (e.g., "Full Body", "Push", "Pull", "Legs") with associated exercises.
- Workout Logging: Users can create workout logs, add exercises from the directory or templates, and record sets (reps & weight).
- Exercise Directory: A comprehensive list of exercises categorized by muscle group.
- Pagination & Filtering: Efficiently retrieve lists of workouts, templates, and exercises with pagination and filtering options.
- Role-Based Access (Admin): Functionality to manage roles and potentially protect administrative actions (like editing the Exercise Directory).
- Backend: ASP.NET Core Web API (.NET 8)
- Database: MS SQL Server
- ORM: Entity Framework Core 8
- Authentication: ASP.NET Core Identity, JWT Bearer Tokens
- Mapping: AutoMapper
- Architecture: 3-Tier (API Layer, Business Logic Layer, Data Access Layer) with Repository and Unit of Work patterns.
- .NET 8 SDK
- MS SQL Server (e.g., SQL Server Express)
- An IDE like Visual Studio or VS Code
- Clone the repository:
git clone [https://github.com/NazarPolit/WorkoutTracker.git](https://github.com/NazarPolit/WorkoutTracker.git) cd WorkoutTracker/backend - Configure User Secrets:
- Right-click on the
Back_WorkoutTracketproject in Visual Studio and select "Manage User Secrets". - Add the following configuration, replacing placeholders with your actual values:
{ "ConnectionStrings": { "DefaultConnection": "Server=YOUR_SQL_SERVER_INSTANCE;Database=workouttracker_dev;Trusted_Connection=True;TrustServerCertificate=True;" }, "Jwt": { "Key": "YOUR_SUPER_SECRET_JWT_KEY_MINIMUM_32_CHARS", "Issuer": "https://localhost:XXXX", // Check your launchSettings.json "Audience": "https://localhost:XXXX" // Check your launchSettings.json } }
- Right-click on the
- Apply Database Migrations:
Open a terminal in the
backendfolder and run:dotnet ef database update --project DataAccess -s Back_WorkoutTracket
- (Optional) Seed Initial Data:
If you want to populate the database with exercise types and workout templates:
dotnet run --project Back_WorkoutTracket seeddata
- Run the Application:
The API will be available at the address specified in
dotnet run --project Back_WorkoutTracket
Properties/launchSettings.json(e.g.,https://localhost:7157).
Auth:/api/auth/register,/api/auth/loginExerciseTypes: CRUD operations for the exercise directory (Admin restricted for CUD).WorkoutTemplates: Read operations for workout templates.Workouts: CRUD operations for user workout logs.WorkoutExercises: Operations to add/remove exercises within a workout log.Sets: CRUD operations for sets within a workout exercise.Admin: Endpoints for managing user roles.Stats: (Optional) Endpoints for retrieving workout statistics.