# takilu/edi-working architecture

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

- Interactive diagram: https://gitdiagram.com/takilu/edi-working
- Repository: https://github.com/takilu/edi-working

## Overview

##### Project Type and Purpose
- Full-stack web application for EDI-Community.
- Backend: Django REST framework with modular apps (accounts, contracts, training).
- Frontend: React/Vite single-page application (“frapp”).
- Deployment: Docker Compose with Nginx reverse proxy, media storage, static files.

##### File Structure
- Top level:
– Dockerfile, docker-compose.yml → defines container builds and orchestration.
– manage.py, edi/ → Django project entry point, settings, ASGI/WSGI.
– accounts/, contracts/, training/ → Django apps (models, views, serializers, URLs).
– frontend/frapp/ → React app (components, contexts, lib, assets).
– nginx/ → Nginx config for routing and SSL.
– media/, staticfiles/ → uploaded files and collected Django static assets.
– requirements.txt → Python dependencies; edi/requirements.txt for Django.
- Patterns:
– MVC (Django apps: Models → Views (REST endpoints) → Templates [n/a]).
– REST API layer between backend and frontend.
– Containerized micro-services style via Docker Compose.

##### README
- Minimal description: "This System created for EDI-Community".
- Implies core EDI features implemented across contracts, training, and account management.

##### Main Components
a. Client Layer
– Web Browser / SPA (React)
– Mobile clients (if any REST consumers)
b. Edge/Proxy Layer
– Nginx container:
- Serves React build (static files)
- Proxies API calls to Django backend
c. Frontend Layer
– React application (Vite dev server or built assets)
– Context/API module for authentication, data fetching
d. Backend Layer
– Django app container (ASGI/WSGI):
- Apps: accounts, contracts, training
- REST endpoints (Django REST framework)
- Business logic and serializers
e. Data Layer
– Database service (e.g., PostgreSQL container)
– media storage (mounted volume/container)
– staticfiles volume (collected static assets)
f. Orchestration Layer
– Docker Compose: defines services and networks
g. External Services (if applicable)
– Email/SMS gateway, third-party auth, payment gateway

##### Relationships and Data Flows
- User → HTTP(S) → Nginx
– GET “/” → React SPA served
– GET/POST “/api/…” → proxied to Django
- React → REST API → Django
– Auth flow (login/register → accounts)
– Data fetch/update (contracts, training)
- Django → Database
– ORM CRUD operations
- Django → Media/Static volumes
– File upload/download
- Docker Compose network connects all containers

##### Architectural Patterns
- Separation of concerns: UI vs API vs Data
- RESTful services in backend
- Containerization for environment consistency
- MVC (in Django)
- SPA pattern in frontend
- Volume mounting for persistent media/static storage

##### Relevant Technologies and Frameworks
- Frontend: React, Vite, JSX, Tailwind/UI components
- Backend: Python, Django, Django REST framework
- Infrastructure: Docker, Docker Compose, Nginx
- Database: PostgreSQL (or specified in compose)
- Authentication: JWT or session (AuthContext.jsx)
- CI/CD (optional): add if present

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web Browser (SPA)"]:::ui
    end

    %% Edge/Proxy Layer
    subgraph "Edge/Proxy Layer"
        Nginx["Nginx Reverse Proxy"]:::infra
    end

    Browser -->|"HTTP GET /, API calls"| Nginx

    %% Frontend Layer
    subgraph "Frontend Layer"
        ReactApp["React SPA"]:::ui
        Components["React Components"]:::ui
        AuthContext["Auth Context"]:::ui
        APIUtils["API Utilities"]:::ui
        EntryPoint["Vite Config & Entry"]:::ui

        ReactApp --> Components
        ReactApp --> AuthContext
        ReactApp --> APIUtils
        ReactApp --> EntryPoint
    end

    Nginx -->|"Serves static files"| ReactApp

    %% Backend Layer
    subgraph "Backend Layer"
        DjangoApp["Django App Container"]:::api

        subgraph "Django Project"
            Manage["manage.py & Settings & URLs & ASGI & WSGI"]:::api
            DockerfileBE["Backend Dockerfile"]:::infra
            Manage --> DockerfileBE
        end

        subgraph "Django Apps"
            Accounts["Accounts App"]:::api
            Contracts["Contracts App"]:::api
            Training["Training App"]:::api
        end

        DjangoApp --> Manage
        DjangoApp --> Accounts
        DjangoApp --> Contracts
        DjangoApp --> Training
    end

    Nginx -->|"Proxies /api/*"| DjangoApp

    %% Data Layer
    subgraph "Data Layer"
        DB["PostgreSQL Database"]:::data
        Media["Media Storage Volume"]:::data
        StaticVol["Collected Staticfiles Volume"]:::data

        DjangoApp -->|"ORM CRUD"| DB
        DjangoApp -->|"File Upload/Download"| Media
        Nginx -->|"Serves collected static"| StaticVol
    end

    %% Orchestration Layer
    subgraph "Orchestration"
        Compose["Docker Compose Orchestration"]:::infra
        Compose --> Nginx
        Compose --> ReactApp
        Compose --> DjangoApp
        Compose --> DB
    end

    %% Click Events
    click ReactApp "https://github.com/takilu/edi-working/tree/master/frontend/frapp/"
    click Components "https://github.com/takilu/edi-working/tree/master/frontend/frapp/src/components/"
    click AuthContext "https://github.com/takilu/edi-working/blob/master/frontend/frapp/src/contexts/AuthContext.jsx"
    click APIUtils "https://github.com/takilu/edi-working/blob/master/frontend/frapp/src/lib/api.js"
    click EntryPoint "https://github.com/takilu/edi-working/blob/master/frontend/frapp/vite.config.js"
    click EntryPoint "https://github.com/takilu/edi-working/blob/master/frontend/frapp/src/main.jsx"
    click Nginx "https://github.com/takilu/edi-working/blob/master/nginx/nginx-setup.conf"
    click Compose "https://github.com/takilu/edi-working/blob/master/docker-compose.yml"
    click DjangoApp "https://github.com/takilu/edi-working/tree/master/edi/Dockerfile"
    click Manage "https://github.com/takilu/edi-working/blob/master/manage.py"
    click Manage "https://github.com/takilu/edi-working/blob/master/edi/settings.py"
    click Manage "https://github.com/takilu/edi-working/blob/master/edi/urls.py"
    click Manage "https://github.com/takilu/edi-working/blob/master/edi/asgi.py"
    click Manage "https://github.com/takilu/edi-working/blob/master/edi/wsgi.py"
    click Accounts "https://github.com/takilu/edi-working/tree/master/accounts/"
    click Contracts "https://github.com/takilu/edi-working/tree/master/contracts/"
    click Training "https://github.com/takilu/edi-working/tree/master/training/"
    click PythonDeps1 "https://github.com/takilu/edi-working/blob/master/requirements.txt"
    click PythonDeps2 "https://github.com/takilu/edi-working/blob/master/edi/requirements.txt"
    click Media "https://github.com/takilu/edi-working/tree/master/media/"
    click StaticVol "https://github.com/takilu/edi-working/tree/master/staticfiles/"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef api fill:#DFF7DF,stroke:#28a745,color:#28a745;
    classDef data fill:#FFF4D6,stroke:#DAA520,color:#DAA520;
    classDef infra fill:#E2E2E2,stroke:#6a737d,color:#6a737d;
```
