This is the backend for the MyGarage app. It exposes a REST API for managing vehicles and related data. The frontend (Ionic + React) consumes these endpoints.
➡ Frontend Repository: MyGarage Frontend
➡ LIVE DEMO TEST: MyGarage
- Django + Django REST Framework
- CRUD for cars (create / list / retrieve / update / delete)
- Optional image upload endpoints (if enabled)
- CORS configured for local development
- SQLite by default, easy to switch to Postgres/MySQL
# Clone & enter
git clone https://github.com/AbbasEl11/mygarage-backend.git
cd mygarage-backend
# Create virtual env
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
# source venv/bin/activate
# Install deps
pip install -r requirements.txt
# Migrate & run
python manage.py migrate
python manage.py runserver
The API will be available at: http://127.0.0.1:8000/
Assuming a CarViewSet
is registered on cars
:
GET /cars/ # list
POST /cars/ # create
GET /cars/{id}/ # retrieve
PUT /cars/{id}/ # update (full)
PATCH /cars/{id}/ # update (partial)
DELETE /cars/{id}/ # delete
Your frontend should call
DELETE /cars/{id}/
(no request body) and expect204 No Content
on success.
If you have an image upload route (example):
POST /cars/{id}/upload-images/ # multipart/form-data
In settings.py
make sure CORS is enabled and your frontend origin is allowed:
INSTALLED_APPS += ['corsheaders', 'rest_framework']
MIDDLEWARE = ['corsheaders.middleware.CorsMiddleware', *MIDDLEWARE]
CORS_ALLOWED_ORIGINS = [
"http://localhost:5173", # Vite (Ionic React)
# "https://your-frontend-domain.tld",
]
DEBUG=True
for development only- Do not commit secrets. Load them from environment variables or a
.env
file (not committed).
See requirements.txt
. Minimal set:
- Django
- djangorestframework
- django-cors-headers
- (Optional) Pillow for image uploads
- (Optional) drf-spectacular for API docs
To load demo vehicles into the database, run:
python manage.py loaddata cars_fixture.json
This will insert sample Car
records (with image paths) into your local database.
Interactive API documentation is available via Swagger UI.
URL: API Documentation
You can explore available endpoints, view request/response schemas, and test API calls directly from the browser.
mygarage-backend/
├─ mysite/
│ ├─ settings.py
│ ├─ urls.py
│ └─ __init__.py
├─ garage/
│ ├─ admin.py
│ ├─ apps.py
│ ├─ models.py
│ ├─ serializers.py
│ ├─ views.py
│ ├─ urls.py
│ ├─ migrations/
│ └─ __init__.py
├─ manage.py
├─ requirements.txt
├─ README.md
├─ .gitignore
└─ cars_fixture.json
- Remove
venv/
anddb.sqlite3
from the repo if present - Ensure
.gitignore
includesvenv/
,db.sqlite3
,__pycache__/
,.env
- Run migrations successfully
- Test CRUD via
curl
or your frontend
Developed by AbbasEl11