# belghalimohammed/dynamic-portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/belghalimohammed/dynamic-portfolio
- Repository: https://github.com/belghalimohammed/dynamic-portfolio

## Overview

##### Project Type and Purpose
- This is a full-stack personal portfolio management application.
- Frontend: a React/TypeScript SPA (create-react-app + CRACO + Tailwind) that serves both a public portfolio site and an authenticated admin console.
- Backend: a Python/Flask REST API providing authentication, CRUD endpoints for portfolio data (hero, about, projects, etc.), file-upload handling, and persistence via a relational database (SQLAlchemy models).

##### File Structure
- Top-level “frontend” and “backend” directories clearly separate client and server.
- Frontend:
- public/ (static HTML, assets)
- src/ (App.js, React components: portfolio UI, admin UI, shared UI primitives, contexts, hooks, services/api.js)
- configuration: craco.config.js, postcss.config.js, tailwind.config.js
- Backend:
- server.py (Flask app entrypoint)
- auth.py, database.py, models.py, file_upload.py
- .env + requirements.txt
- uploads/ (stored images for hero, projects, etc.)
- tests/ and backend_test.py cover automated backend tests.
- contracts.md likely lists API contracts.

##### README
- (Assuming it documents overall architecture, setup steps, dependencies, and intended use: public portfolio display + admin management.)

a. Main Components
- Public SPA (React) – fetches portfolio JSON, displays pages.
- Admin SPA (React) – authenticated UI for CRUD operations.
- API Gateway (Flask server) – routes requests to auth, data, file-upload modules.
- Relational Database – stores user, portfolio entities.
- File Storage – local “uploads” directory (or cloud bucket in prod).
- Authentication Service – JWT/Session management within Flask.
- (Optional) Reverse Proxy / Load Balancer – Nginx or similar in front of Flask.
b. Relationships & Interactions
- Frontend → HTTP(S) → Flask API (REST endpoints).
- Flask API → ORM → Database.
- Flask API → File I/O → Uploads directory.
- Admin SPA includes a ProtectedRoute component that checks AuthContext before invoking API.
- Public SPA reads portfolio data, no auth required.
c. Architectural Patterns & Principles
- Client-Server separation (clear frontend vs backend).
- Layered backend: routing → service modules (auth, file_upload, database) → data layer (models).
- Single-Page Application pattern on the client.
- MVC-style partition on the backend (Flask views/controllers, SQLAlchemy models).
- Separation of concerns: UI components vs shared UI library vs data service layer.
d. Key Technologies & Frameworks
- Frontend: React, CRACO, Tailwind CSS, React Router, custom UI primitives.
- Backend: Flask, SQLAlchemy, JWT (or Flask-Login), Werkzeug for file upload.
- Dev toolchain: npm/Yarn, Python pip, dotenv.

##### Be Detailed and Comprehensive
- Distinct React route/component group (portfolio vs admin) if needed.
- Environment config (dotenv) to show where secrets and URLs are injected.
- Third-party integrations (e.g., CDN for static assets, analytics).
- Document internal module relationships (auth.py ↔ database.py ↔ models.py).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraphs
    subgraph "Client Side"
        subgraph "Public SPA"
            Public["React SPA (Public)"]:::frontend
        end
        subgraph "Admin SPA"
            Admin["React SPA (Admin)"]:::frontend
            ProtectedRoute["ProtectedRoute"]:::frontend
            AuthContext["AuthContext"]:::frontend
        end
        UIPrimitives["UI Primitives"]:::frontend
        APIService["API Service Layer"]:::frontend
        MockData["Mock Data"]:::frontend
        Hooks1["usePortfolioData"]:::frontend
        Hooks2["use-toast"]:::frontend
        AppEntry["App Entrypoint & Styles"]:::frontend
        Craco["CRACO Config"]:::frontend
        Tailwind1["Tailwind Config"]:::frontend
        PostCSS["PostCSS Config"]:::frontend
        EnvFE[".env"]:::frontend
    end

    subgraph "Server Side"
        API["Flask API Server"]:::backend
        AuthModule["Authentication Module"]:::backend
        DBConn["Database Connection & Setup"]:::backend
        Models["ORM Models"]:::backend
        FileUpload["File Upload Handler"]:::backend
        Tests["Backend Tests"]:::backend
        EnvBE[".env"]:::backend
        Requirements["requirements.txt"]:::backend
        Contracts["API Contract Documentation"]:::backend
    end

    subgraph "Persistence Layer"
        DB["Relational DB"]:::datastore
        Storage["Uploads Storage"]:::datastore
    end

    %% Connections
    Public -->|"HTTP Requests"| API
    Admin -->|"HTTP Requests (Auth)"| API
    ProtectedRoute -->|"enforces Auth via"| AuthContext
    AuthContext -->|"provides Token to"| Admin
    APIService -->|"AJAX to API"| API
    Hooks1 -->|"uses"| APIService
    Hooks2 -->|"uses"| APIService
    Public -->|"optional mocks"| MockData
    UIPrimitives -->|"used by"| Public
    UIPrimitives -->|"used by"| Admin
    AppEntry -->|"bootstraps"| Public
    AppEntry -->|"bootstraps"| Admin

    API -->|"routes to"| AuthModule
    API -->|"routes to"| DBConn
    DBConn -->|"imports"| Models
    API -->|"routes to"| FileUpload
    API -->|"queries"| DB
    FileUpload -->|"writes to"| Storage
    API -->|"defined by"| Contracts
    Tests -->|"validate"| API

    %% Click Events - Frontend
    click Public "https://github.com/belghalimohammed/dynamic-portfolio/tree/main/frontend/src/components/portfolio"
    click Admin "https://github.com/belghalimohammed/dynamic-portfolio/tree/main/frontend/src/components/admin"
    click ProtectedRoute "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/components/admin/ProtectedRoute.jsx"
    click AuthContext "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/contexts/AuthContext.jsx"
    click APIService "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/services/api.js"
    click UIPrimitives "https://github.com/belghalimohammed/dynamic-portfolio/tree/main/frontend/src/components/ui"
    click MockData "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/data/mock.js"
    click Hooks1 "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/hooks/usePortfolioData.js"
    click Hooks2 "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/hooks/use-toast.js"
    click AppEntry "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/src/index.js"
    click Craco "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/craco.config.js"
    click Tailwind1 "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/tailwind.config.js"
    click PostCSS "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/postcss.config.js"
    click EnvFE "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/frontend/.env"

    %% Click Events - Backend
    click API "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/server.py"
    click AuthModule "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/auth.py"
    click DBConn "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/database.py"
    click Models "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/models.py"
    click FileUpload "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/file_upload.py"
    click Storage "https://github.com/belghalimohammed/dynamic-portfolio/tree/main/backend/uploads"
    click EnvBE "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/.env"
    click Requirements "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend/requirements.txt"
    click Tests "https://github.com/belghalimohammed/dynamic-portfolio/tree/main/tests/"
    click Tests "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/backend_test.py"
    click Contracts "https://github.com/belghalimohammed/dynamic-portfolio/blob/main/contracts.md"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:1px;
    classDef backend fill:#E8F5E9,stroke:#388E3C,stroke-width:1px;
    classDef datastore fill:#FFF3E0,stroke:#F57C00,stroke-width:1px;
```
