Skip to content

saaiarjun27/devopsAssignment1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‹οΈ ACEest Fitness & Gym – DevOps CI/CD Pipeline

A Flask-based fitness and gym management web application with a fully automated CI/CD pipeline using GitHub Actions and Jenkins.


πŸ“‹ Table of Contents


🎯 Project Overview

ACEest Fitness & Gym is a web application designed for managing gym clients, tracking workouts, generating AI-style training programs, monitoring membership status, and calculating BMI. The project demonstrates modern DevOps practices including:

  • Version Control with Git/GitHub (descriptive commits, branch management)
  • Unit Testing with Pytest (30+ test cases)
  • Containerization with Docker (optimized, non-root image)
  • CI/CD Automation with GitHub Actions & Jenkins

✨ Features

Feature Description
Client Management Full CRUD operations for gym clients
Workout Tracking Log and retrieve workout sessions per client
AI Program Generator Generate workout plans based on program type and experience
BMI Calculator Calculate BMI and get WHO category classification
Calorie Estimator Estimate daily calorie needs based on weight and program
Membership Tracking Check active/expired membership status with expiry dates
Health Check Endpoint /health endpoint for container orchestration and monitoring

πŸ›  Tech Stack

Layer Technology
Backend Python 3.12 + Flask
Database SQLite3
Testing Pytest
Linting Flake8
Containerization Docker
CI/CD GitHub Actions
Build Server Jenkins

πŸ“ Project Structure

devopsAssignment1/
β”œβ”€β”€ app.py                          # Flask application (main source)
β”œβ”€β”€ test_app.py                     # Pytest test suite
β”œβ”€β”€ requirements.txt                # Python dependencies
β”œβ”€β”€ Dockerfile                      # Docker image definition
β”œβ”€β”€ Jenkinsfile                     # Jenkins pipeline definition
β”œβ”€β”€ .gitignore                      # Git ignore rules
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── main.yml                # GitHub Actions CI/CD workflow
β”œβ”€β”€ templates/
β”‚   └── index.html                  # Landing page template
└── README.md                       # This file

πŸš€ Local Setup & Execution

Prerequisites

  • Python 3.10+ installed
  • pip (Python package manager)
  • Git
  • Docker (optional, for container testing)

Steps

# 1. Clone the repository
git clone https://github.com/saaiarjun27/devopsAssignment1.git
cd devopsAssignment1

# 2. Create a virtual environment (recommended)
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Run the application
python app.py

The application will start on http://localhost:5000


πŸ§ͺ Running Tests Manually

# Run the full test suite with verbose output
pytest test_app.py -v

# Run with detailed failure info
pytest test_app.py -v --tb=long

# Run a specific test class
pytest test_app.py::TestBMICalculation -v

# Run with coverage (install pytest-cov first)
pip install pytest-cov
pytest test_app.py --cov=app --cov-report=term-missing

Test Coverage Summary

The test suite validates:

  • βœ… Health-check endpoint
  • βœ… Home page rendering
  • βœ… BMI calculation logic + endpoint (including edge cases)
  • βœ… Calorie estimation with all program types
  • βœ… AI program generation (beginner / intermediate / advanced)
  • βœ… Client CRUD (create, read, update, delete)
  • βœ… Workout logging & retrieval
  • βœ… Membership status checking (active / expired / not found)
  • βœ… Programs listing endpoint
  • βœ… Error handling (missing fields, invalid data)

🐳 Docker Usage

Build the Docker Image

docker build -t aceest-fitness:latest .

Run the Container

docker run -p 5000:5000 aceest-fitness:latest

Visit http://localhost:5000 in your browser.

Run Tests Inside the Container

docker run --rm aceest-fitness:latest python -m pytest test_app.py -v

Docker Image Highlights

  • Base image: python:3.12-slim (minimal footprint)
  • Non-root user: Runs as aceest user for security
  • Layer caching: Dependencies installed before copying source
  • Health check: Built-in HEALTHCHECK instruction

βš™οΈ CI/CD Pipeline Overview

GitHub Actions

The pipeline is defined in .github/workflows/main.yml and is triggered on every push or pull_request to the main branch.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 1:           β”‚     β”‚  Stage 2:            β”‚     β”‚  Stage 3:               β”‚
β”‚  Build & Lint       │────▢│  Docker Image        │────▢│  Automated Testing      β”‚
β”‚                     β”‚     β”‚  Assembly            β”‚     β”‚  (Pytest in Container)  β”‚
β”‚  β€’ Install deps     β”‚     β”‚  β€’ docker build      β”‚     β”‚  β€’ Run test_app.py      β”‚
β”‚  β€’ flake8 lint      β”‚     β”‚  β€’ Verify image      β”‚     β”‚  β€’ All 30+ tests        β”‚
β”‚  β€’ Verify imports   β”‚     β”‚                      β”‚     β”‚                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Stage What It Does
Build & Lint Installs dependencies, runs flake8 syntax/error checks
Docker Assembly Builds the Docker image and verifies it was created
Automated Testing Runs the full Pytest suite inside the Docker container

Jenkins Integration

The Jenkinsfile defines a declarative pipeline with:

  1. Checkout – Pulls latest code from GitHub
  2. Install Dependencies – pip install -r requirements.txt
  3. Lint – Runs flake8 for syntax validation
  4. Test – Executes Pytest suite
  5. Docker Build – Builds and tags Docker image

Jenkins Setup Steps

  1. Install Jenkins on your server/local machine
  2. Install required plugins: Git, Pipeline, Docker Pipeline
  3. Create a New Pipeline job
  4. Under Pipeline β†’ Definition, select Pipeline script from SCM
  5. Set SCM to Git and enter the repository URL:
    https://github.com/saaiarjun27/devopsAssignment1.git
    
  6. Set Script Path to Jenkinsfile
  7. Save and click Build Now

πŸ“‘ API Endpoints

Method Endpoint Description
GET / Landing page
GET /health Health check
GET /api/programs List available programs
GET /api/clients List all clients
POST /api/clients Create/update a client
GET /api/clients/<name> Get a specific client
DELETE /api/clients/<name> Delete a client
GET /api/workouts/<client_name> Get workouts for a client
POST /api/workouts Log a new workout
POST /api/bmi Calculate BMI
POST /api/generate-program Generate AI workout program
GET /api/membership/<client_name> Check membership status

πŸ“œ Version History

Version Description
1.0 Initial Tkinter GUI – basic program display
1.1 Added client profile inputs, calorie estimation
1.1.2 Multi-client support, CSV export, progress chart
2.0.1 SQLite database integration
2.1.2 Database schema with workouts and exercises tables
2.2.1 Role-based login system
2.2.4 Full dashboard with AI program generator and PDF reports
3.0.1 Membership management and billing
3.1.2 Refactored UI with modal login and analytics tab
3.2.4 Streamlined codebase, workout treeview
4.0 Flask web app + Docker + CI/CD pipeline (current)

πŸ‘€ Author

Sai Arjun – Junior DevOps Engineer
GitHub: @saaiarjun27


πŸ“„ License

This project is developed as part of a DevOps academic assignment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors