How garopabus/garopabus-backend works
Project type and purpose
• This is a Django-based RESTful backend (no frontend code here) that powers the “GaropaBus” transport service. It exposes APIs for routes, schedules, notifications (including push subscriptions), and persists data in a relational database.
File structure
• Top level: Dockerfile, docker-compose.yml, GitHub Actions workflows for dev/prod, pyproject.toml for Python dependencies.
• Django project “garopabus” holds global settings, ASGI/WGI entry points, and URL router.
• Single Django app “transporte” implements domain logic:
• models.py – ORM definitions (routes, schedules, notifications)
• serializers.py – DRF serializers
• views.py – API viewsets/endpoints
• urls.py – app-level routing
• filters.py, utils.py, logging.py – cross-cutting concerns
• migrations/ – database evolution history
• manage.py for CLI commands.
README
• Standard Django setup in a Python virtual environment.
• Uses pyproject.toml to declare dependencies.
a. Main components
• Client(s): mobile app, web app, or third-party integrators
• API Gateway/Reverse Proxy: Nginx (in front of the app container)
• Application Server: Uvicorn (ASGI) or Gunicorn (WSGI) running the Django project
• Django MVT layers:
– URL Dispatcher
– View layer (transporte.views)
– Serializer layer (transporte.serializers)
– Model layer (transporte.models)
• Database: PostgreSQL (or your chosen RDBMS in docker-compose)
• External services: Push Notification Provider (FCM/Web Push), Email/SMS gateway if used
• Infrastructure: Docker containers, docker-compose orchestration, GitHub Actions CI/CD
b. Relationships and interactions
1. Client → HTTP request to Nginx
2. Nginx → forwards to Uvicorn/Gunicorn → Django’s ASGI/WGI
3. Django URL router → maps to transporte.viewsets or APIView
4. View → invokes serializers and business logic (utils, filters) → interacts with models
5. Models → ORM → Database reads/writes
6. For event-driven actions (e.g. push notifications), View or utils → calls external Push Service API
7. All logs emitted via transporte.logging → captured by Docker log driver or forwarded to external logging system
c. Architectural patterns and design principles
• Layered (MVT) architecture
• RESTful API design with Django REST Framework
• Twelve-factor app guidelines (environment via .env, declarative dependencies, stateless processes)
• Containerization (Docker), orchestration via docker-compose
• CI/CD pipelines (GitHub Actions) for dev & prod deployments
d. Key technologies/frameworks
• Python 3.x
• Django & Django REST Framework
• Uvicorn (ASGI) or Gunicorn (WSGI)
• PostgreSQL (configured in docker-compose)
• Docker & docker-compose
• GitHub Actions for CI/CD
Detail but keep it uncluttered
• Don’t “over-componentize” – separate only by logical/service boundaries (proxy vs. app vs. DB vs. external).
• Every essential layer: client → proxy → ASGI/WGI → Django MVT → database & external services → CI/CD.