Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔧 Mechanic Shop API 🚗

License: MIT Python Flask SQLAlchemy

Mechanic Shop API

🚀 A professional Flask-based REST API for managing a mechanic shop, built using the Application Factory Pattern. Features robust error handling, input validation, and comprehensive documentation.

FeaturesInstallationAPI ReferenceExamplesLicense

✨ Features

🔹 Modern Architecture

  • RESTful API design principles
  • Application Factory Pattern for scalability
  • Modular codebase organization

🔹 Robust Backend

  • SQLite database with SQLAlchemy ORM
  • Comprehensive input validation
  • Professional error handling

🔹 Advanced Functionality

  • Smart pagination for list endpoints
  • Powerful search capabilities
  • Real-time data validation

🔹 Developer Experience

  • Clear documentation
  • Easy-to-use endpoints
  • Consistent API responses

🛠 API Endpoints

🏥 Health Check

GET /api/v1/health - System health status

👨‍🔧 Mechanics

GET    /api/v1/mechanics        # List all mechanics
POST   /api/v1/mechanics        # Create a new mechanic
GET    /api/v1/mechanics/<id>   # Get mechanic details
PUT    /api/v1/mechanics/<id>   # Update mechanic details
DELETE /api/v1/mechanics/<id>   # Delete a mechanic
GET    /api/v1/mechanics/search # Search mechanics

🔨 Services

GET    /api/v1/services        # List all services
POST   /api/v1/services        # Create a new service
GET    /api/v1/services/<id>   # Get service details
PUT    /api/v1/services/<id>   # Update service details
DELETE /api/v1/services/<id>   # Delete a service
GET    /api/v1/services/search # Search services

🚀 Setup

Prerequisites

  • Python 3.9 or higher
  • Git
  • pip (Python package installer)

Installation Steps

1️⃣ Clone the repository

git clone https://github.com/Anon23261/Module1Lesson4-Specialization.git
cd Module1Lesson4-Specialization

2️⃣ Set up virtual environment

python -m venv venv

# On Linux/macOS:
source venv/bin/activate

# On Windows:
venv\Scripts\activate

3️⃣ Install dependencies

pip install -r requirements.txt

4️⃣ Initialize database

python init_db.py

5️⃣ Start the server

python run.py

🌟 The API will be available at http://localhost:5000

📚 Example Usage

🔷 Create a Mechanic

Click to expand
curl -X POST -H "Content-Type: application/json" \
  -d '{
    "name": "John Smith",
    "email": "john.smith@mechanic.com",
    "specialty": "Engine Repair",
    "certification": "ASE Master Technician",
    "years_experience": 10
  }' \
  http://localhost:5000/api/v1/mechanics

Response:

{
  "id": 1,
  "name": "John Smith",
  "email": "john.smith@mechanic.com",
  "specialty": "Engine Repair",
  "certification": "ASE Master Technician",
  "years_experience": 10,
  "created_at": "2025-02-13T22:57:31.450566",
  "updated_at": "2025-02-13T22:57:31.450574"
}

🔷 Create a Service

Click to expand
curl -X POST -H "Content-Type: application/json" \
  -d '{
    "name": "Engine Tune-up",
    "description": "Complete engine tune-up service",
    "price": 299.99,
    "duration_hours": 2.5,
    "mechanic_id": 1
  }' \
  http://localhost:5000/api/v1/services

Response:

{
  "id": 1,
  "name": "Engine Tune-up",
  "description": "Complete engine tune-up service",
  "price": 299.99,
  "duration_hours": 2.5,
  "mechanic_id": 1,
  "created_at": "2025-02-13T22:57:40.902592",
  "updated_at": "2025-02-13T22:57:40.902597"
}

📁 Project Structure

📦 mechanic_shop
 ┣ 📂 app
 ┃ ┣ 📂 models
 ┃ ┃ ┣ 📜 __init__.py
 ┃ ┃ ┣ 📜 mechanic.py
 ┃ ┃ └ 📜 service.py
 ┃ ┣ 📂 routes
 ┃ ┃ ┣ 📜 __init__.py
 ┃ ┃ ┣ 📜 mechanic.py
 ┃ ┃ └ 📜 service.py
 ┃ ┣ 📂 utils
 ┃ ┃ ┣ 📜 __init__.py
 ┃ ┃ ┣ 📜 error_handlers.py
 ┃ ┃ └ 📜 validators.py
 ┃ ┣ 📜 __init__.py
 ┃ ┣ 📜 extensions.py
 ┃ └ 📜 config.py
 ┣ 📜 requirements.txt
 ┣ 📜 run.py
 ┣ 📜 init_db.py
 ┣ 📜 LICENSE
 └ 📜 README.md

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by Anon23261

About

Assignment

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages