How fmgarciaa/cride works
Project type and purpose
• This is a backend-only, containerized Django REST Framework application called CRide—a carpooling service API.
• It exposes HTTP endpoints for managing users, ride requests, rides, circles, invitations and ratings.
• It offloads asynchronous tasks (email verification, notifications) to Celery and uses Docker Compose for local and production orchestration.
File structure
• Top-level “compose” directories define two Docker Compose stacks:
– compose/local (Django app, Celery worker/beat/flower, Postgres, Redis, etc.)
– compose/production (adds Caddy reverse-proxy, production-grade Postgres maintenance scripts, optimized Django image).
• “config” hosts Django settings split by environment (base, local, production, test), URL routing (urls.py) and WSGI entrypoint.
• “cride” folder contains Django apps:
– users (models, serializers, views),
– circles (models, permissions, invitations),
– rides (models, serializers, views, ratings),
– taskapp (Celery configuration and tasks),
– templates for emails.
• Requirements and environment files for 12-factor config via django-environ.
README for technical stack
• Python 3.6-alpine, Django 3.2, DRF
• Docker Compose
• Celery with Redis as broker and cache
• Flower for Celery monitoring
• Caddy as HTTP reverse proxy
• PostgreSQL as the primary datastore
• Anymail for email delivery (Mailgun/AWS SES)
• S3/Google Cloud/Azure for media storage
Main components
• API Gateway / Reverse Proxy: Caddy server receiving external HTTP(S) traffic
• Web/API App: Gunicorn + Django (config/wsgi.py) running the REST API
• Database: PostgreSQL (main data persistence)
• Cache and Message Broker: Redis (caching layer, Celery broker)
• Asynchronous Workers: Celery worker and Celery Beat scheduler
• Monitoring: Celery Flower UI
• External Services:
– Object Storage (S3 or equivalent) for media
– Email Provider (Mailgun or SES) via Anymail
• Local development stack vs. production differ only by image choices and added maintenance tasks for Postgres.
Relationships and data flow
• Clients (mobile/web) → HTTP(S) → Caddy → Django/Gunicorn
• Django (sync) ↔ PostgreSQL
• Django (cache lookups, locks) ↔ Redis
• Django (enqueue tasks) → Redis broker → Celery Worker
• Celery Beat → schedules periodic Celery tasks
• Celery Worker → executes tasks (e.g., send email via Anymail → Email Provider; process image uploads → S3)
• Flower → monitors Celery Worker
• All containers communicate over an internal Docker network; config files define service dependencies.
Architectural patterns and design principles
• Monolithic Django service with multiple Django “apps” representing bounded contexts (users, rides, circles).
• Asynchronous task pattern via Celery.
• 12-factor app for environment configuration, backing services (DB, cache, broker), build and release separation.
• Separation of concerns: HTTP layer (Caddy, Gunicorn), application logic (Django views/serializers), data layer (ORM), background layer (Celery).