# caonguyen-tran/e-commerce architecture

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

- Interactive diagram: https://gitdiagram.com/caonguyen-tran/e-commerce
- Repository: https://github.com/caonguyen-tran/e-commerce

## Overview

##### Main Components
- Frontend (Mobile Client):
- Located in ecommerce/ECommerceNative with subdirectories for Android, iOS, Expo configuration, and components (Home, Products, User).
- Built with React Native (using Expo and standard React Native tooling).
- Backend (Server):
- Comprised of the Django application found in ecommerce/eCommerceApp and ecommerce/eCommerceProject.
- Includes Django core components (views, models, serializers, migrations, URL routing) and a manage.py file.
- Database:
- Represented by db.sqlite3, serving as the datastore for the Django backend.
- Additional Supporting Elements:
- Configuration files, such as package.json for Node/React Native dependencies and requirement.txt for Python dependencies.
- Build and deployment settings (Android and iOS project configurations, Gradle files, Xcode projects).

##### Interactions and Relationships
- The mobile client (React Native) interacts with the Django backend via API calls.
- The API endpoints (defined likely via eCommerceApp/urls.py and views.py) allow the frontend to perform operations such as user login, product fetching, and ordering.
- The Django backend communicates with the SQLite database (db.sqlite3) to store and retrieve e-commerce data.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Mobile client (presentation layer) is kept separate from the backend logic (business logic).
- The Django backend follows common MVC/MVT (Model-View-Template) patterns.
- Modular Design:
- Components and screens in the React Native app are organized into distinct directories.
- Django has separate apps (e.g., eCommerceApp) for handling business logic.
- Connectivity via API:

##### Relevant Technologies and Frameworks
- React Native (with Expo) for the frontend.
- Django for the backend.
- SQLite for the database.
- Gradle (Android) and Xcode (iOS) for native build environments.
- Node modules (Node.js) for managing frontend dependencies.
- Additional libraries that might be visible in package.json and requirement.txt.

- Optionally, include a “Configuration & Build” section that shows how environment setup files (Gradle, Xcode, package.json) relate to the corresponding components.
- Separation: clearly separate the concerns between the frontend (presentational layer) and backend (logic/data layer).

- The React Native mobile app (with its submodules and Expo configurations).
- The Django backend handling business logic and RESTful APIs.
- The SQLite database supporting the backend.
- The integration paths among these components.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend - Mobile Client (React Native)
    subgraph "Mobile Client (React Native)"
        RN_Main["React Native Mobile App"]:::frontend
        RN_Components["Mobile App Components"]:::frontend
        Expo_App["Expo Config (app.json)"]:::frontend
        Babel["Babel Config (babel.config.js)"]:::frontend
        Expo_Folder["Expo Folder (.expo)"]:::frontend
        Android["Android Build Config"]:::native
        iOS["iOS Build Config"]:::native
        RN_Pkg["React Native Dependencies (package.json)"]:::config
    end

    %% Backend - Django Server
    subgraph "Backend Server (Django)"
        DjangoApp["Django Backend Application"]:::backend
        DjangoProject["Django Project Settings & URL Routing"]:::backend
        PythonReq["Python Dependencies (requirement.txt)"]:::config
    end

    %% Database
    DB["SQLite Database"]:::database

    %% Global Dependencies & Configurations
    Global_Pkg["Global Configurations (package.json, package-lock.json)"]:::config

    %% Relationships among components
    RN_Main -->|"REST_API"| DjangoApp
    DjangoProject -->|"configures"| DjangoApp
    DjangoApp -->|"data_persistence"| DB

    %% Internal relationships within Mobile Client
    RN_Components --> RN_Main
    Expo_App --> RN_Main
    Babel --> RN_Main
    Expo_Folder --> RN_Main
    Android --> RN_Main
    iOS --> RN_Main
    RN_Pkg --> RN_Main

    %% Configuration associations in Backend and Global
    PythonReq --> DjangoApp
    Global_Pkg --- RN_Main
    Global_Pkg --- DjangoProject

    %% Click Events
    click RN_Main "https://github.com/caonguyen-tran/e-commerce/tree/main/ecommerce/ECommerceNative"
    click RN_Components "https://github.com/caonguyen-tran/e-commerce/tree/main/ecommerce/ECommerceNative/components"
    click Expo_App "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/ECommerceNative/app.json"
    click Babel "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/ECommerceNative/babel.config.js"
    click Expo_Folder "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/.expo"
    click Android "https://github.com/caonguyen-tran/e-commerce/tree/main/ecommerce/ECommerceNative/android"
    click iOS "https://github.com/caonguyen-tran/e-commerce/tree/main/ecommerce/ECommerceNative/ios"
    click RN_Pkg "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/ECommerceNative/package.json"
    click DjangoApp "https://github.com/caonguyen-tran/e-commerce/tree/main/ecommerce/eCommerceApp"
    click DjangoProject "https://github.com/caonguyen-tran/e-commerce/tree/main/ecommerce/eCommerceProject"
    click PythonReq "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/requirement.txt"
    click Global_Pkg "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/package.json"
    click DB "https://github.com/caonguyen-tran/e-commerce/blob/main/ecommerce/db.sqlite3"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef database fill:#ffa500,stroke:#000,stroke-width:1px;
    classDef config fill:#f0e68c,stroke:#000,stroke-width:1px;
    classDef native fill:#d3d3d3,stroke:#000,stroke-width:1px;
```
