# marcelovicentegc/django-react-typescript architecture

> Architecture diagram of the GitHub repository marcelovicentegc/django-react-typescript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marcelovicentegc/django-react-typescript
- Repository: https://github.com/marcelovicentegc/django-react-typescript

## Overview

##### Main Components
- Frontend: Represent the React application. Show that it includes components, pages, API consumers, and uses environment variables for configuration.
- Backend: Represent the Django application which is split between:
- API endpoints provided via Django Rest Framework (DRF) — located in folders like api/ and backend views.
- Traditional Django components (views, templates, models, admin, migrations, signals) in the backend/ and core/ directories.
- Database: A Postgres instance, referencing both local development (Docker Compose configurations) and production storage.
- CDN: Cloudinary integration used for storing media files.

##### Relationships and Interactions
- A clear data flow between React on the frontend and the Django backend.
- That Django’s view functions serve both API data and render templates that include the React app (especially in production where the frontend is served by Django).
- That models in Django interact with both the REST API layer (via serializers) and are ultimately stored in Postgres.
- That static assets and media files are handled by the CDN, and that NGINX acts as a reverse proxy or static asset server in the deployment layer.
- CI/CD pipelines as external systems that trigger builds, tests, and deployment operations using either virtualized (via VM SSH) or bare-metal deployment workflows.

##### Architectural Patterns & Design Principles
- Separation of concerns: route the business logic in Django (views, models, serializers) from the client-side rendering in React.
- Demonstrate integration patterns between server-rendered pages (using Django templates) and client-side routed React components.
- Use of containerization (Docker) and automation (GitHub Actions) for a smooth development-to-production pipeline.
- That environment variables drive configuration for both frontend and backend, and denote CI/CD integration for automated deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configurations
    subgraph "Configurations"
        Env[".env.example"]:::config
        Prod["Prod Settings (Cloudinary)"]:::config
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        F["React Frontend\n(React, Typescript, Webpack, Tailwind)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B1["DRF API Endpoints"]:::backend
        B2["Traditional Django Backend\n(views, templates, models, admin)"]:::backend
        Core["Core Django Configuration"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["Postgres Database"]:::db
        CDN["Cloudinary CDN"]:::cdn
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        D1["Docker Compose (Prod)"]:::infrastructure
        D1a["Docker Compose Dev-DB"]:::infrastructure
        D2["Dockerfile"]:::infrastructure
        Nginx["NGINX"]:::infrastructure
        Gun["Gunicorn/Supervisord"]:::infrastructure
        CI["GitHub Actions CI/CD Pipelines"]:::infrastructure
    end

    %% Connections from Configurations to Core
    Env -->|"sets env"| Core
    Prod -->|"configures"| Core

    %% Frontend to Backend
    F -->|"APIcalls"| B1

    %% Core configures API and Traditional backend
    Core -->|"configures"| B1
    Core -->|"configures"| B2

    %% Backend interactions with Data Layer
    B1 -->|"persist data"| DB
    B2 -->|"persist data"| DB
    B2 -->|"media storage"| CDN

    %% Traditional Django serves Frontend in production
    B2 -->|"renders app"| F

    %% Deployment & Infrastructure flows
    CI -->|"triggers"| D1
    CI -->|"triggers"| D2
    CI -->|"triggers"| Nginx
    CI -->|"triggers"| Gun
    D1a -->|"configures dev DB"| DB

    %% Styling and Class Definitions
    classDef frontend fill:#C3FDB8,stroke:#333,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef db fill:#FADBD8,stroke:#333,stroke-width:2px;
    classDef cdn fill:#D6EAF8,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#E8DAEF,stroke:#333,stroke-width:2px;
    classDef config fill:#D5F5E3,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click F "https://github.com/marcelovicentegc/django-react-typescript/tree/main/frontend/"
    click B1 "https://github.com/marcelovicentegc/django-react-typescript/tree/main/api/"
    click B2 "https://github.com/marcelovicentegc/django-react-typescript/tree/main/backend/"
    click Core "https://github.com/marcelovicentegc/django-react-typescript/tree/main/core/"
    click D1 "https://github.com/marcelovicentegc/django-react-typescript/blob/main/docker-compose.yml"
    click D1a "https://github.com/marcelovicentegc/django-react-typescript/blob/main/docker-compose-dev-db.yml"
    click D2 "https://github.com/marcelovicentegc/django-react-typescript/tree/main/Dockerfile"
    click Nginx "https://github.com/marcelovicentegc/django-react-typescript/tree/main/config/nginx/"
    click Gun "https://github.com/marcelovicentegc/django-react-typescript/tree/main/config/supervisor/"
    click CI "https://github.com/marcelovicentegc/django-react-typescript/tree/main/.github/workflows/"
    click Prod "https://github.com/marcelovicentegc/django-react-typescript/blob/main/core/settings/prod.py"
    click Env "https://github.com/marcelovicentegc/django-react-typescript/blob/main/.env.example"
```
