# alhoyani/fbe architecture

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

- Interactive diagram: https://gitdiagram.com/alhoyani/fbe
- Repository: https://github.com/alhoyani/fbe

## Overview

##### Project type and purpose
- This is a full-stack web application for building, customizing, and ordering resumes/CVs.
- The backend is a Django-based REST API (accounts, home, order, payment, resume, templates_app). It uses Celery for background jobs (e.g., PDF generation, emails), Docker/Docker-Compose for local development, and standard Django configurations (ASGI, WSGI, settings).
- The frontend is a React + TypeScript single-page application (SPA) built with Vite, organized by pages, components, feature slices (Redux Toolkit), and context for auth/loading.

##### File structure
- Top-level:
- backend/ (Django entry points, settings, Celery)
- accounts/, home/, order/, payment/, resume/, templates_app/ (Django apps – models, serializers, views, URLs, tests)
- docker-compose.yml / docker-compose-dev.yml, Dockerfile(s)
- manage.py, requirements.txt
- src/ (React SPA – App.tsx, pages/, components/, features/, store, styles, config)
- package.json, tsconfig*.json, vite.config.ts
- Patterns:
- Backend: MVC + Django REST framework + Celery workers + message broker (likely Redis) + relational DB (Postgres/MySQL) + object storage (S3 or local)
- Frontend: component-based UI, Redux for global state, RTK Query/apiSlice for server calls, React Router for routing, Context for cross-cutting concerns

##### README
- Minimal (“# to-be-expert”) – lean on file structure for domain understanding.

##### Main components & interactions
a. User’s browser (React SPA)
b. CDN or Static-file host (serves index.html + bundle)
c. Frontend application (API client, UI components, routing)
d. API Gateway / Load balancer (NGINX or cloud LB)
e. Django REST API (Gunicorn/ASGI)
f. Relational Database (PostgreSQL/MySQL)
g. Message broker (Redis/RabbitMQ)
h. Celery workers (background tasks: PDF generation, email notifications)
i. Object storage (S3 or equivalent, for generated resumes and assets)
j. External payment gateway (Stripe/PayPal)
k. Email/SMS provider (SMTP, SendGrid, Twilio)

##### Relationships & data flows
- The browser loads the SPA → makes REST/JSON calls to /api/* endpoints.
- NGINX/Load Balancer routes requests to Django (Gunicorn or Uvicorn).
- Django handles auth (accounts service), resume CRUD, order placement, payment validation.
- DB persists users, resumes, orders.
- On order placement, Django enqueues tasks on the broker for Celery (e.g., resume PDF generation, sending confirmation emails).
- Celery workers consume tasks → read/write DB and object storage → notify users via email/SMS.
- The frontend polls or listens for task status via API or WebSocket (if implemented).

##### Architectural patterns & design principles
- Separation of concerns: UI vs. API vs. background processing
- MVC in Django, component hierarchy in React
- Redux Toolkit + RTK Query for global state & data fetching
- Docker Compose for local multi-container orchestration
- Twelve-factor app principles (config in env vars, stateless processes)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        Browser["User Browser"]:::frontend
        CDN["CDN / Static Host"]:::frontend
        App["React SPA (Vite)"]:::frontend
        Store["Redux Store"]:::frontend
        ApiSlice["RTK Query API Slice"]:::frontend
        Pages["React Pages (Routing)"]:::frontend
        Components["UI Components"]:::frontend
        AuthCtx["Auth Context"]:::frontend
        LoadCtx["Loading Context"]:::frontend
        Routing["Routing Config"]:::frontend
        BBB["Vite Config"]:::frontend
        TSConfigs["TypeScript Configs"]:::frontend

        Browser -->|loads| CDN -->|serves| App
        App --> Store --> ApiSlice -->|HTTP/REST| NGINX
        App --> Pages
        App --> Components
        App --> AuthCtx
        App --> LoadCtx
        App --> Routing

    end

    %% Backend Layer
    subgraph "Backend/API" 
        direction TB
        NGINX["NGINX / Load Balancer"]:::backend
        DjangoAPI["Django REST API"]:::backend
        subgraph "Django Apps"
            direction TB
            Accounts["Accounts Service"]:::backend
            Home["Home Service"]:::backend
            Order["Order Service"]:::backend
            PaymentApp["Payment Service"]:::backend
            ResumeApp["Resume Service"]:::backend
            TemplatesApp["Templates Service"]:::backend
        end
        NGINX -->|routes HTTP| DjangoAPI
        DjangoAPI --> Accounts
        DjangoAPI --> Home
        DjangoAPI --> Order
        DjangoAPI --> PaymentApp
        DjangoAPI --> ResumeApp
        DjangoAPI --> TemplatesApp
        DjangoAPI -->|SQL| DB
        DjangoAPI -->|AMQP/Redis| CACHE
    end

    %% Background Workers
    subgraph "Background Processing"
        direction TB
        Celery["Celery Workers"]:::backend
        Celery -->|consume tasks| CACHE
        Celery -->|read/write| DB
        Celery -->|store PDFs| S3
        Celery -->|send emails/SMS| EmailService
        Order -->|enqueue tasks| Celery
    end

    %% Data Stores
    DB[(PostgreSQL)]:::datastore
    CACHE[(Redis Broker)]:::datastore
    S3[(Object Storage S3)]:::datastore

    %% External Services
    PaymentExt("Stripe/PayPal"):::external
    EmailService("Email/SMS Provider"):::external

    PaymentApp -->|HTTP| PaymentExt

    %% Click Events
    click App "https://github.com/alhoyani/fbe/blob/main/src/App.tsx"
    click Store "https://github.com/alhoyani/fbe/blob/main/src/app/store.ts"
    click ApiSlice "https://github.com/alhoyani/fbe/blob/main/src/app/api/apiSlice.ts"
    click Pages "https://github.com/alhoyani/fbe/tree/main/src/pages/"
    click Components "https://github.com/alhoyani/fbe/tree/main/src/components/"
    click AuthCtx "https://github.com/alhoyani/fbe/blob/main/src/context/AuthContext.tsx"
    click LoadCtx "https://github.com/alhoyani/fbe/blob/main/src/context/LoadingContext.tsx"
    click Routing "https://github.com/alhoyani/fbe/blob/main/src/routes/Routing.tsx"
    click BBB "https://github.com/alhoyani/fbe/blob/main/vite.config.ts"
    click TSConfigs "https://github.com/alhoyani/fbe/blob/main/tsconfig.json"
    click TSConfigs "https://github.com/alhoyani/fbe/blob/main/tsconfig.app.json"
    click TSConfigs "https://github.com/alhoyani/fbe/blob/main/tsconfig.node.json"
    click DockerCompose "https://github.com/alhoyani/fbe/blob/main/docker-compose.yml"
    click DockerCompose "https://github.com/alhoyani/fbe/blob/main/docker-compose-dev.yml"
    click Dockerfile "https://github.com/alhoyani/fbe/tree/main/Dockerfile"
    click Dockerfile2 "https://github.com/alhoyani/fbe/tree/main/Dockerfile 2"
    click Manage "https://github.com/alhoyani/fbe/blob/main/manage.py"
    click Settings "https://github.com/alhoyani/fbe/blob/main/backend/settings.py"
    click ASGI "https://github.com/alhoyani/fbe/blob/main/backend/asgi.py"
    click WSGI "https://github.com/alhoyani/fbe/blob/main/backend/wsgi.py"
    click Celery "https://github.com/alhoyani/fbe/blob/main/backend/celery.py"
    click URLs "https://github.com/alhoyani/fbe/blob/main/backend/urls.py"
    click Requirements "https://github.com/alhoyani/fbe/blob/main/requirements.txt"
    click Accounts "https://github.com/alhoyani/fbe/tree/main/accounts/"
    click Home "https://github.com/alhoyani/fbe/tree/main/home/"
    click Order "https://github.com/alhoyani/fbe/tree/main/order/"
    click PaymentApp "https://github.com/alhoyani/fbe/tree/main/payment/"
    click ResumeApp "https://github.com/alhoyani/fbe/tree/main/resume/"
    click TemplatesApp "https://github.com/alhoyani/fbe/tree/main/templates_app/"
    click EmailService "https://github.com/alhoyani/fbe/tree/main/templates/email/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#000;
    classDef backend fill:#D0FFD0,stroke:#228B22,color:#000;
    classDef datastore fill:#FFE0B2,stroke:#E65100,color:#000;
    classDef external fill:#E1BEE7,stroke:#8E24AA,color:#000;
```
