ποΈ A modern, high-performance RESTful API for managing your auto repair shop operations. Built with Flask and love! π
π§βπΌ Customer Management
- Track customer details and history
- Seamless CRUD operations
- Secure data handling
- Preferred mechanics selection
- Vehicle ownership tracking
π Vehicle Management
- Comprehensive vehicle tracking
- Service history logging
- Multiple vehicles per customer
- Detailed service records
- Mileage tracking
π¨βπ§ Mechanic Management
- Skill tracking and specializations
- Work schedule management
- Performance monitoring
- Tool certifications
- Customer preferences tracking
π οΈ Service Management
- Customizable service catalog
- Dynamic pricing with parts
- Service categorization
- Required tools tracking
- Parts inventory management
π Service Tickets
- Real-time status tracking
- Detailed service records
- Automated notifications
- Cost estimation and tracking
- Service history integration
π¦ pthon-API
β£ π app
β β£ π auth # Authentication module
β β£ π blueprints # API blueprints
β β β£ π customers # Customer management
β β β£ π vehicles # Vehicle management
β β β£ π services # Service catalog
β β β£ π mechanics # Mechanic management
β β β£ π service_tickets # Service tickets
β β β£ π models # Common models
β β β π associations.py # Many-to-many relationships
β β£ π common # Common utilities
β β β£ π models.py # Base model class
β β β π utils.py # Utility functions
β β£ π extensions.py # Flask extensions
β β π __init__.py # App initialization
β£ π wsgi.py # Application entry point
β£ π config.py # Configuration
β£ π requirements.txt # Dependencies
β π README.md # Documentation
- Mechanic-Specialization: Mechanics can have multiple specializations
- Service-Parts: Services require multiple parts with quantities
- Vehicle-Service History: Tracks services performed on vehicles
- Customer-Preferred Mechanics: Customers can have preferred mechanics
- Service-Required Tools: Services require specific tools
- Mechanic-Tool Certifications: Mechanics are certified for specific tools
- Customer -> Vehicles
- Customer -> Service Tickets
- Vehicle -> Service Tickets
- Mechanic -> Service Tickets
- Service -> Service Tickets
- Python 3.9+
- pip (Python package manager)
- Virtual environment (recommended)
- SQLite (default) or PostgreSQL
- Clone the repository
git clone https://github.com/yourusername/mechanic-shop-api.git
cd mechanic-shop-api
- Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Set up environment variables in
.env
:
FLASK_APP=wsgi.py
FLASK_ENV=development
SECRET_KEY=your-secret-key
DATABASE_URL=sqlite:///app.db
JWT_SECRET_KEY=your-jwt-secret
- Initialize the database
flask db init
flask db migrate
flask db upgrade
- Run the application
flask run
The API uses JWT (JSON Web Token) authentication. To access protected endpoints:
- Register a new user or login
- Use the returned JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>
Method | Endpoint | Description | Auth Required |
---|---|---|---|
POST |
/auth/register |
Register new customer | β |
POST |
/auth/login |
Login customer | β |
GET |
/customers |
List all customers | β |
GET |
/customers/<id> |
Get customer details | β |
PUT |
/customers/<id> |
Update customer | β |
DELETE |
/customers/<id> |
Delete customer | β |
POST |
/customers/<id>/preferred-mechanics |
Add preferred mechanic | β |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET |
/vehicles |
List all vehicles | β |
POST |
/vehicles |
Add new vehicle | β |
GET |
/vehicles/<id> |
Get vehicle details | β |
PUT |
/vehicles/<id> |
Update vehicle | β |
DELETE |
/vehicles/<id> |
Delete vehicle | β |
GET |
/vehicles/<id>/service-history |
Get service history | β |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET |
/mechanics |
List all mechanics | β |
POST |
/mechanics |
Add new mechanic | β |
GET |
/mechanics/<id> |
Get mechanic details | β |
PUT |
/mechanics/<id> |
Update mechanic | β |
DELETE |
/mechanics/<id> |
Delete mechanic | β |
GET |
/mechanics/<id>/specializations |
Get specializations | β |
POST |
/mechanics/<id>/certifications |
Add tool certification | β |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET |
/services |
List all services | β |
POST |
/services |
Add new service | β |
GET |
/services/<id> |
Get service details | β |
PUT |
/services/<id> |
Update service | β |
DELETE |
/services/<id> |
Delete service | β |
GET |
/services/<id>/required-parts |
Get required parts | β |
GET |
/services/<id>/required-tools |
Get required tools | β |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET |
/service-tickets |
List all tickets | β |
POST |
/service-tickets |
Create ticket | β |
GET |
/service-tickets/<id> |
Get ticket details | β |
PUT |
/service-tickets/<id> |
Update ticket | β |
DELETE |
/service-tickets/<id> |
Delete ticket | β |
PUT |
/service-tickets/<id>/status |
Update status | β |
- id: Integer (Primary Key)
- name: String
- email: String (Unique)
- phone: String
- address: String
- preferred_mechanics: Relationship (Many-to-Many with Mechanic)
- vehicles: Relationship (One-to-Many with Vehicle)
- service_tickets: Relationship (One-to-Many with ServiceTicket)
- id: Integer (Primary Key)
- make: String
- model: String
- year: Integer
- vin: String (Unique)
- license_plate: String
- color: String
- mileage: Integer
- last_service_date: DateTime
- owner: Relationship (Many-to-One with Customer)
- service_history: Relationship (Many-to-Many with Service)
- id: Integer (Primary Key)
- name: String
- email: String (Unique)
- phone: String
- hourly_rate: Float
- years_of_experience: Integer
- specializations: Relationship (Many-to-Many with Specialization)
- certified_tools: Relationship (Many-to-Many with Tool)
- service_tickets: Relationship (One-to-Many with ServiceTicket)
- id: Integer (Primary Key)
- name: String
- description: Text
- base_price: Float
- estimated_hours: Float
- complexity_level: Integer
- is_diagnostic: Boolean
- required_parts: Relationship (Many-to-Many with Part)
- required_tools: Relationship (Many-to-Many with Tool)
- id: Integer (Primary Key)
- description: Text
- status: String
- scheduled_date: DateTime
- completion_date: DateTime
- estimated_cost: Float
- final_cost: Float
- diagnostic_notes: Text
- completion_notes: Text
- priority: Integer
- customer: Relationship (Many-to-One with Customer)
- vehicle: Relationship (Many-to-One with Vehicle)
- mechanic: Relationship (Many-to-One with Mechanic)
- service: Relationship (Many-to-One with Service)
pytest
The project follows the Black code style. Format your code with:
black .
After model changes:
flask db migrate -m "Description of changes"
flask db upgrade
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request