# josiahcameron/stride architecture

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

- Interactive diagram: https://gitdiagram.com/josiahcameron/stride
- Repository: https://github.com/josiahcameron/stride

## Overview

##### Project type and purpose
- This is a full-stack habit-tracking web application (“Stride”) with a Django + Django REST Framework (DRF) backend, a React single-page frontend, asynchronous task processing via Celery, and integrations with external services (motivation quotes API, Twilio).

##### File structure
- Top-level Django project “conf” contains settings, URL routing, ASGI/WSGI and Celery configuration.
- Django apps:
- accounts (custom user, profiles, journaling)
- habits (habit definitions, metadata, completion logic)
- api (DRF-exposed endpoints for CRUD)
- frontend (Django app whose static folder holds the React build)
- celery_tasks (models + tasks, beat schedule)
- Static files:
- frontend/static/src → React source code
- frontend/static/build and staticfiles/build → production React bundles
- Deployment / orchestration:
- Procfile (for Heroku/Gunicorn dyno)
- Pipfile/Pipfile.lock (Python dependencies)

##### Additional insights from README
- Users have tiered limits, daily streak logic stored in RDBMS.
- DRF CRUD for habits & journal entries.
- Axios in React to consume the API.
- Twilio used to text upon goal completion; motivational quotes pulled from a public REST API.

1. User’s Browser (React SPA + Axios)
2. Django Backend (Gunicorn → conf ASGI/WSGI)
3. PostgreSQL (or configured RDBMS)
4. Message Broker (e.g. Redis or RabbitMQ)
5. Celery Worker & Beat Scheduler
6. External REST API (Quotes API)
7. External SMS Service (Twilio)
- Browser →[HTTP/HTTPS]→ Django REST endpoints
- Django →[SQL]→ Database
- Django →[broker enqueue]→ Celery tasks
- Celery Worker →[HTTP]→ Quotes API
- Celery Worker →[HTTP]→ Twilio API
- Browser ←[static files]← Django (serves React build)
c. Architectural patterns & principles:
- MVC (Django models-views-templates, though templates here are minimal)
- RESTful API layer (DRF)
- Single-Page Application (React)
- Asynchronous task queue (Celery + broker)
- Separation of concerns: authentication, data, background jobs, UI
d. Key technologies & frameworks:
- Django, Django REST Framework
- React, Axios
- Celery, Redis/RabbitMQ
- Gunicorn, Heroku (Procfile)
- PostgreSQL

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["User's Browser\n(React SPA)"]:::frontend
        FrontendStatic["Django Serves React Build"]:::backend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Gunicorn["Gunicorn / ASGI"]:::backend
        subgraph "Django Apps"
            direction TB
            AccountsApp["Accounts App"]:::backend
            HabitsApp["Habits App"]:::backend
            APIApp["API App"]:::backend
            FrontendDjango["Frontend Django App"]:::backend
            CeleryTasksApp["Celery Tasks App"]:::backend
        end
        PostgreSQL["PostgreSQL DB"]:::db
    end

    %% Background Jobs
    subgraph "Background Jobs"
        direction TB
        Broker["Message Broker\n(Redis/RabbitMQ)"]:::broker
        Beat["Celery Beat Scheduler"]:::broker
        CeleryWorker["Celery Worker"]:::broker
    end

    %% External Services
    QuotesAPI["External Quotes API"]:::external
    TwilioAPI["External SMS Service\n(Twilio)"]:::external

    %% Connections
    Browser -->|HTTP/JSON| Gunicorn
    FrontendStatic -.->|static files| Browser

    Gunicorn --> AccountsApp
    Gunicorn --> HabitsApp
    Gunicorn --> APIApp
    Gunicorn --> FrontendDjango
    Gunicorn --> CeleryTasksApp
    AccountsApp -->|SQL/ORM| PostgreSQL
    HabitsApp -->|SQL/ORM| PostgreSQL
    APIApp -->|SQL/ORM| PostgreSQL
    FrontendDjango -->|serves build| FrontendStatic
    CeleryTasksApp -->|SQL/ORM| PostgreSQL

    APIApp -->|AMQP/RPC| Broker
    AccountsApp -->|AMQP/RPC| Broker
    HabitsApp -->|AMQP/RPC| Broker
    CeleryTasksApp -->|AMQP/RPC| Broker

    Beat -->|schedule tasks| CeleryWorker
    Broker -->|enqueue tasks| CeleryWorker

    CeleryWorker -->|HTTP/JSON| QuotesAPI
    CeleryWorker -->|HTTP/JSON| TwilioAPI

    %% Click Events
    click Gunicorn "https://github.com/josiahcameron/stride/blob/main/conf/asgi.py"
    click AccountsApp "https://github.com/josiahcameron/stride/blob/main/accounts/models.py"
    click HabitsApp "https://github.com/josiahcameron/stride/blob/main/habits/models.py"
    click APIApp "https://github.com/josiahcameron/stride/blob/main/api/models.py"
    click FrontendDjango "https://github.com/josiahcameron/stride/blob/main/frontend/views.py"
    click CeleryTasksApp "https://github.com/josiahcameron/stride/blob/main/celery_tasks/tasks.py"
    click Beat "https://github.com/josiahcameron/stride/blob/main/celery_tasks/beat_schedule.py"
    click Browser "https://github.com/josiahcameron/stride/blob/main/frontend/static/src/index.js"
    click FrontendStatic "https://github.com/josiahcameron/stride/tree/main/frontend/static/build/"

    %% Styles
    classDef frontend fill:#c8e6c9,stroke:#2e7d32,color:#1b5e20
    classDef backend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef db fill:#b3e5fc,stroke:#0277bd,color:#01579b
    classDef broker fill:#ffe0b2,stroke:#e65100,color:#e65100
    classDef external fill:#e0e0e0,stroke:#424242,color:#424242
```
