# herchila/cride architecture

> Architecture diagram of the GitHub repository herchila/cride, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/herchila/cride
- Repository: https://github.com/herchila/cride

## Overview

##### Project type and purpose
- This is a Django-based, invite-only carpooling platform (“Comparte Ride”) exposing a REST API (via Django REST Framework) and sending email notifications.
- It uses Celery for background jobs (task processing, periodic tasks, monitoring via Flower), PostgreSQL for persistence, and Docker Compose for local/production deployments with Caddy as a reverse proxy.

##### File structure
- Top-level:
- manage.py, config/ (Django settings, URLs, WSGI)
- cride/ (Django apps: users, circles, rides, shared utils, templates, Celery config)
- compose/ (environment-specific Dockerfiles & startup scripts)
- local.yml & production.yml (Compose definitions)
- requirements/ (pip requirements per environment)
- Inside cride/:
- taskapp/ sets up Celery (“worker,” “beat,” “flower”)
- modular apps (users, circles, rides) each with models, serializers, views, permissions
- templates for transactional emails
- Environment separation:
- config/settings/{base,local,production,test}.py
- Docker Compose splits services for local vs. production (adds Caddy & maintenance scripts for Postgres)

##### Key insights from README
- Minimal description: group-bounded, invite-only carpooling
- No built-in frontend; likely mobile or SPA clients consume the API

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef api fill:#cfe2f3,stroke:#6fa8dc,color:#073763
    classDef async fill:#d9ead3,stroke:#6aa84f,color:#274e13
    classDef db fill:#fce5cd,stroke:#e69138,color:#7f6000
    classDef infra fill:#ead1dc,stroke:#b44e75,color:#741b47
    classDef external fill:#ffffff,stroke:#000000,color:#000000

    subgraph "Clients"
        Client["Mobile / SPA Clients"]:::external
    end

    Client -->|HTTPS| Caddy["Caddy Reverse Proxy"]:::infra
    click Caddy "https://github.com/herchila/cride/tree/master/compose/production/caddy/Caddyfile"

    Caddy --> DjangoAPI

    subgraph "Django API Layer"
        Manage["manage.py"]:::api
        URL["config/urls.py"]:::api
        WSGI["config/wsgi.py"]:::api
        SettingsBase["config/settings/base.py"]:::api
        SettingsLocal["config/settings/local.py"]:::api
        SettingsProd["config/settings/production.py"]:::api
        SettingsTest["config/settings/test.py"]:::api
        UsersApp["Users App"]:::api
        CirclesApp["Circles App"]:::api
        RidesApp["Rides App"]:::api
        Utils["Shared Utils"]:::api
        EmailTpl["Email Template"]:::api
        CeleryConfig["Celery Config"]:::api
        Tasks["Celery Tasks"]:::api
    end

    click Manage "https://github.com/herchila/cride/blob/master/manage.py"
    click URL "https://github.com/herchila/cride/blob/master/config/urls.py"
    click WSGI "https://github.com/herchila/cride/blob/master/config/wsgi.py"
    click SettingsBase "https://github.com/herchila/cride/blob/master/config/settings/base.py"
    click SettingsLocal "https://github.com/herchila/cride/blob/master/config/settings/local.py"
    click SettingsProd "https://github.com/herchila/cride/blob/master/config/settings/production.py"
    click SettingsTest "https://github.com/herchila/cride/blob/master/config/settings/test.py"
    click UsersApp "https://github.com/herchila/cride/tree/master/cride/users/"
    click CirclesApp "https://github.com/herchila/cride/tree/master/cride/circles/"
    click RidesApp "https://github.com/herchila/cride/tree/master/cride/rides/"
    click Utils "https://github.com/herchila/cride/blob/master/cride/utils/models.py"
    click EmailTpl "https://github.com/herchila/cride/blob/master/cride/templates/emails/users/account_verification.html"
    click CeleryConfig "https://github.com/herchila/cride/blob/master/cride/taskapp/celery.py"
    click Tasks "https://github.com/herchila/cride/blob/master/cride/taskapp/tasks.py"

    DjangoAPI -->|ORM queries| Postgres

    subgraph "Data Layer"
        Postgres["PostgreSQL"]:::db
    end

    DjangoAPI -->|enqueue tasks| Broker["Broker (Redis/RabbitMQ)"]:::async
    DjangoAPI -->|send emails| SMTP["SMTP Server"]:::external

    subgraph "Async Layer"
        WorkerLocal["Worker (local start)"]:::async
        WorkerProd["Worker (prod start)"]:::async
        BeatLocal["Beat (local start)"]:::async
        BeatProd["Beat (prod start)"]:::async
        FlowerLocal["Flower (local start)"]:::async
        FlowerProd["Flower (prod start)"]:::async
    end

    click WorkerLocal "https://github.com/herchila/cride/tree/master/compose/local/django/celery/worker/start"
    click WorkerProd "https://github.com/herchila/cride/tree/master/compose/production/django/celery/worker/start"
    click BeatLocal "https://github.com/herchila/cride/tree/master/compose/local/django/celery/beat/start"
    click BeatProd "https://github.com/herchila/cride/tree/master/compose/production/django/celery/beat/start"
    click FlowerLocal "https://github.com/herchila/cride/tree/master/compose/local/django/celery/flower/start"
    click FlowerProd "https://github.com/herchila/cride/tree/master/compose/production/django/celery/flower/start"

    Broker -->|dequeue| WorkerLocal
    Broker -->|dequeue| WorkerProd
    Broker -->|schedule| BeatLocal
    Broker -->|schedule| BeatProd
    Broker -->|monitor| FlowerLocal
    Broker -->|monitor| FlowerProd

    subgraph "Docker Compose"
        LocalYml["local.yml"]:::infra
        ProdYml["production.yml"]:::infra
        DFLocal["compose/local/django/Dockerfile"]:::infra
        DFProd["compose/production/django/Dockerfile"]:::infra
    end

    click LocalYml "https://github.com/herchila/cride/blob/master/local.yml"
    click ProdYml "https://github.com/herchila/cride/blob/master/production.yml"
    click DFLocal "https://github.com/herchila/cride/tree/master/compose/local/django/Dockerfile"
    click DFProd "https://github.com/herchila/cride/tree/master/compose/production/django/Dockerfile"

    Postgres -->|maintenance scripts| PGBackup["backup"]:::infra
    click PGBackup "https://github.com/herchila/cride/tree/master/compose/production/postgres/maintenance/backup"
    Postgres -->|maintenance scripts| PGRestore["restore"]:::infra
    click PGRestore "https://github.com/herchila/cride/tree/master/compose/production/postgres/maintenance/restore"
```
