A comprehensive RESTful API for managing a mechanic shop's operations, including customers, mechanics, service tickets, and inventory management.
Jen Planque
Software Development Graduate | Backend Specialization
GitHub: @jenplanque
- Author
- Introduction
- Tech Stack
- Features
- Project Structure
- Prerequisites
- Installation
- Usage
- API Documentation
- Testing
- Deployment
- CI/CD Pipeline
- Screenshots
- Collaborators
- Acknowledgments
This Mechanic Shop API is my final capstone project for the Software Development Backend Specialization program at Coding Temple. The project was developed in four comprehensive phases:
- Foundation & Documentation: Core API development with Flask-Swagger documentation
- Advanced Features: Rate limiting, caching, token authentication and advanced queries
- Resource Expansion: Inventory management with many-to-many relationships
- Deployment & CI/CD: Production deployment on Render with automated testing pipeline
The API provides complete CRUD operations for managing a Mechanic Shop's daily operations, featuring secure authentication, comprehensive testing and production-ready deployment with continuous integration.
As someone with ADHD, I pivoted from the built-in unittest to pytest during development to leverage its visual, color-coded feedback system. This choice significantly improved my ability to identify patterns and debug tests effectively while maintaining full compatibility with unittest concepts and meeting all learning objectives.
| Feature | Technology / Tool |
|---|---|
| Language | Python 3.11 |
| Framework | Flask 3.1.1 |
| ORM | Flask-SQLAlchemy 3.1.1, SQLAlchemy 2.0.41 |
| Database | PostgreSQL (Production), SQLite (Dev/Test) |
| Adapter | pg8000 1.31.2 |
| Auth & Security | JWT (python-jose), Werkzeug, Flask-Limiter |
| Caching | Flask-Caching, Redis 6.2.0 |
| Documentation | Swagger (flask-swagger), Swagger-UI |
| Testing | Pytest, pytest-html, Hypothesis, Postman |
| Deployment | Gunicorn, Render |
| CI/CD | GitHub Actions |
- JWT token-based authentication for customers
- Secure password hashing with Werkzeug
- Token-protected routes for sensitive operations
- Rate limiting to prevent API abuse
- Customer registration and login
- Profile management (view, update, delete)
- Secure token generation for session management
- Customer-specific service ticket access
- Mechanic profile management
- Advanced queries: mechanics ranked by ticket completion
- Search functionality for finding mechanics
- Many-to-many relationships with service tickets
- Complete CRUD operations for service tickets
- VIN-based vehicle tracking
- Dynamic mechanic assignment/removal
- Customer-specific ticket retrieval with authentication
- Status tracking and updates
- Parts inventory with pricing
- Many-to-many relationships with service tickets
- CRUD operations for inventory items
- Inventory assignment to service tickets
- Flask-Caching for improved response times
- Pagination for large datasets
- Optimized database queries with SQLAlchemy 2.0
- Connection pooling for database efficiency
- Mechanics ranked by service ticket completion
- Customer service history
- Inventory usage tracking
- Comprehensive filtering and search capabilities
Mechanic_Shop/
├── .github/
│ └── workflows/
│ └── main.yaml # CI/CD pipeline configuration
├── app/
│ ├── blueprints/ # API route modules
│ │ ├── customers/ # Customer management endpoints
│ │ ├── mechanics/ # Mechanic management endpoints
│ │ ├── service_tickets/ # Service ticket operations
│ │ └── inventory/ # Inventory management
│ ├── static/
│ │ └── swagger.yaml # API documentation
│ ├── utils/
│ │ └── util.py # Authentication utilities
│ ├── __init__.py # Flask app factory
│ ├── extensions.py # Flask extensions setup
│ └── models.py # Database models
├── tests/ # Comprehensive test suite
│ ├── test_customers.py
│ ├── test_mechanics.py
│ ├── test_service_tickets.py
│ ├── test_inventory.py
│ └── test_validation.py
├── instance/ # Database files
├── config.py # Environment configurations
├── flask_app.py # Production entry point
├── requirements.txt # Python dependencies
├── pytest.ini # Test configuration
└── README.md # Project documentation
- Python 3.9+ (Tested with Python 3.12)
- pip (Python package manager)
- Git (for cloning the repository)
- PostgreSQL (for production deployment)
git clone https://github.com/jenplanque/mechanic_shop_api.git
cd mechanic_shop_apipython -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install --upgrade pip
pip install -r requirements.txtCreate a .env file in the root directory:
FLASK_APP=flask_app.py
FLASK_ENV=development
SECRET_KEY=your-secret-key-here
DB_PW=your-database-password
DATABASE_URL=your-database-url (for production)# Initialize the database
python -c "from app import create_app; from app.models import db; app = create_app('DevelopmentConfig'); app.app_context().push(); db.create_all()"python run.pyThe API will be available at http://localhost:5000
gunicorn flask_app:appNavigate to interactive Swagger documentation
The API is fully documented using Swagger/OpenAPI 2.0 specification. Each endpoint includes:
- Path & Method: GET, POST, PUT, DELETE operations
- Tags: Organized by resource (Customers, Mechanics, Service Tickets, Inventory)
- Summary & Description: Clear endpoint documentation
- Parameters: Required and optional parameters with validation
- Security: Token authentication requirements
- Response Examples: Sample responses with status codes
| Resource | Method | Endpoint | Description |
|---|---|---|---|
| Customers | POST | /customers |
Register new customer |
| Customers | POST | /customers/login |
Customer authentication |
| Customers | GET | /customers/my-tickets |
Get customer's service tickets (Auth) |
| Mechanics | GET | /mechanics |
List all mechanics |
| Mechanics | GET | /mechanics/usage |
Mechanics ranked by tickets completed |
| Service Tickets | GET | /service_tickets |
List all service tickets |
| Service Tickets | PUT | /service_tickets/<id>/edit |
Update mechanics on ticket |
| Inventory | GET | /inventory |
List inventory items |
| Inventory | POST | /service_tickets/<id>/inventory |
Add parts to service ticket |
The project includes comprehensive testing using pytest with 52 test cases covering:
- ✅ Customer Operations: Registration, login, CRUD operations
- ✅ Mechanic Management: Creation, updates, search functionality
- ✅ Service Tickets: Full lifecycle testing with authentication
- ✅ Inventory Management: CRUD operations and ticket integration
- ✅ Authentication: Token generation and validation
- ✅ Error Handling: Invalid inputs and edge cases
- ✅ Advanced Queries: Pagination, search, and ranking
# Run all tests
pytest tests/ -v
# Run with HTML report
pytest tests/ --html=report.html
# Run specific test file
pytest tests/test_customers.py -v
# Run with coverage
pytest tests/ --cov=appThe project uses TestingConfig with in-memory SQLite database for isolated, fast testing:
class TestingConfig:
SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"
TESTING = True
DEBUG = TrueThe API is deployed on Render with the following configuration:
- PostgreSQL database hosted on Render
- Automatic
DATABASE_URLenvironment variable - Connection pooling for optimal performance
DATABASE_URL=postgresql://... # Automatically provided by Render
SECRET_KEY=production-secret-key
FLASK_ENV=productionThe ProductionConfig class handles:
- PostgreSQL URL transformation for pg8000 compatibility
- Runtime database URI resolution
- Production-optimized caching and security settings
# render.yaml (conceptual)
services:
- type: web
name: mechanic-shop-api
env: python
buildCommand: pip install -r requirements.txt
startCommand: gunicorn flask_app:app
envVars:
- key: SECRET_KEY
value: your-production-secretLive API: https://mechanic-shop-api-1-ezx9.onrender.com
API Documentation: https://mechanic-shop-api-1-ezx9.onrender.com/api/docs
The project includes a comprehensive CI/CD pipeline with:
- Python 3.12 environment setup
- Dependency installation from requirements.txt
- Pytest execution with verbose output
- Test failure prevention of deployment
- Automatic deployment to Render
- Secure API key management via GitHub Secrets
- Production environment activation
- Trigger: Automatic on push to
mainbranch - Testing: All 52 tests must pass before deployment
- Security: Encrypted secrets for deployment credentials
- Reliability: Deployment only occurs after successful testing
SERVICE_ID: srv-xxxxxxxxxxxxxxxxxxxxx (Render Service ID)
RENDER_API_KEY: rnd_xxxxxxxxxxxxxxxx (Render API Key)
name: Flask CI
on:
push:
branches: [main, master]
jobs:
test: # Run comprehensive test suite
deploy: # Deploy to Render (only if tests pass)
needs: testThis project was developed independently as a capstone project. However, special thanks to:
- Coding Temple Staff - Technical Support & Code Reviews
- Pytest Community - For creating an accessible testing framework that supports neurodiverse learning styles
This project represents the culmination of intensive backend development study, showcasing:
- RESTful API Design Principles
- Test-Driven Development (TDD)
- Production Deployment Strategies
- CI/CD Pipeline Implementation
- Database Design & Optimization
Special recognition for choosing pytest over unittest to accommodate ADHD learning needs:
- Visual, color-coded test feedback
- Enhanced readability and debugging capabilities
- HTML report generation for pattern recognition
- Maintained full compatibility with unittest principles
From initial Flask routes to production deployment with automated testing - this project demonstrates:
- ✅ Professional Development Practices
- ✅ Comprehensive Testing Strategies
- ✅ Security Implementation
- ✅ Performance Optimization
- ✅ Documentation Excellence
- ✅ Deployment Automation
🔗 Repository: https://github.com/jenplanque/mechanic_shop_api
🌐 Live API: https://mechanic-shop-api-1-ezx9.onrender.com
📚 Documentation: https://mechanic-shop-api-1-ezx9.onrender.com/api/docs
Built with ❤️ and ☕ by Jen Planque | Final Capstone Project 2025


