How abdullahbakir97/barber-salon works
Project type and purpose
• This is a monolithic full-stack Django web application (“Salon Management System”) enhanced with AJAX & HTMX for dynamic client interactions and a RESTful API (Django REST Framework + drf-yasg).
• It manages salon entities: barbers, appointments, reviews, gallery items, products, service categories, pricing, owner profiles, and user accounts.
File structure
• Top-level Django apps:
• accounts/ – user, owner, profile management
• contact/ – core salon entities (barber, appointment, review, gallery, product, message, services) + API serializers/views
• settings/ – salon-wide settings (context processors, owner details, home/404/500 pages)
• project/ – Django project configuration (settings.py, urls.py, wsgi.py, asgi.py)
• Static assets under static/ (CSS, JS, fonts, images) plus collected staticfiles/ for production.
• Media assets under media/ (uploaded images for barbers, gallery, profiles, products, reviews).
• Configuration: requirements.txt, runtime.txt, Procfile (Heroku), dummy_data.py, db.sqlite3 (dev).
• REST documentation static under staticfiles/drf-yasg.
README for additional insights
• Core features: CRUD over barbers, appointments, reviews, gallery, products, services, owner management.
• Uses AJAX & HTMX on the client to fetch partial HTML or JSON responses for dynamic updates without full page reloads.
• REST API for external integration.
Main components and relationships
a. Client Layer
• Web Browser / Mobile Client
• Renders HTML (Django templates + static assets)
• Sends HTTP requests (full page load, AJAX calls, HTMX requests, REST API calls).
b. Web & Application Layer
• Web server (e.g., Gunicorn behind Nginx/Heroku router)
• Django application (project/ + apps) implementing:
• URL routing (project/urls.py → app urls)
• Views:
– Template views (accounts.views, contact.views, settings.views)
– API endpoints (contact/api.py, DRF viewsets/serializers)
• Business logic in forms.py, models.py, context processors, custom pagination/filter classes.
c. Data Layer
• Relational database (PostgreSQL/MySQL in production; SQLite in development)
• Django ORM mapping (models in accounts/models.py, contact/models.py, settings/models.py).
d. Static & Media Storage
• Static files served via WhiteNoise or CDN (collected under staticfiles/)
• Uploaded media (local media/ folder or AWS S3 in production).
e. External Services (optional)
• SMTP/email service for appointment notifications
• CDN for static content
• Third-party analytics / monitoring.
f. Admin Interface
• Django admin with custom SimpleUI theme (staticfiles/admin/…)
g. API Documentation
• drf-yasg-generated Swagger/Redoc UI under /swagger/ endpoints served by staticfiles/drf-yasg.
Architectural patterns & design principles
• Django’s MTV pattern (Model–Template–View)
• Layered architecture: presentation, business logic, data access
• App modularity: each Django app encapsulates a domain concept
• AJAX & HTMX progressive enhancement: partial page updates
• RESTful API design for external integrations
• Separation of static, media, and dynamic content.
Detail & separation
• Both template rendering paths and API paths.
• API docs endpoint as a separate node.
• Content flow for appointment scheduling (client → AJAX → Appointment API → DB → response).