# londheshubham153/online_shopping_app architecture

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

- Interactive diagram: https://gitdiagram.com/londheshubham153/online_shopping_app
- Repository: https://github.com/londheshubham153/online_shopping_app

## Overview

##### Main Components
a. Frontend Client:
- The "src" directory contains the React-based application components, pages (e.g., Home, Admin, Store), context for state management, and utilities.
- The "public" folder holds static assets like images and the HTML file, which are served to the browser.
b. Containerization & Build Infrastructure:
- Docker-related files (Dockerfile, Dockerfile.dev, .dockerignore) indicate the application is containerized using Docker.
- The presence of docker-compose.yml and supporting shell scripts (start_container.sh, stop_container.sh) shows that multi-container orchestration is supported for local development and possibly production staging.
- The Docker installation script and the Docker Scout report highlight the DevOps focus on secure and efficient deployment.
c. Deployment & Orchestration Layer:
- Kubernetes manifests in the k8s directory (including deployment.yml, service.yml, ingress.yml, HPA, etc.) suggest that the project is configured to run in a Kubernetes cluster for scalability and high availability.
- The appspec.yml and buildspec.yml files are clues that continuous integration/continuous deployment (CI/CD) pipelines (possibly on AWS CodeDeploy/CodeBuild) are used.
- The nginx.conf file indicates that Nginx is used as a reverse proxy or web server, potentially to manage incoming web traffic.
d. Infrastructure & Cloud Deployment:
- README mentions deployment on Amazon EC2.
- Thus, the cloud-hosted environment (EC2) hosts the containerized application (possibly using Kubernetes or Docker Compose) along with proxy/Gateway services like Nginx.

##### Relationships and Interactions
- The Client (user’s browser) accesses the application via the public internet.
- Requests are directed through Nginx, which may act as a reverse proxy.
- Nginx routes requests to the containerized application running as a Docker container.
- The containers are orchestrated via Docker Compose during local development and possibly migrated to a Kubernetes cluster in production.
- The CI/CD pipeline (as configured by appspec.yml and buildspec.yml) drives the build and deployment processes, ensuring that updates are seamlessly deployed to an EC2-hosted environment.
- The DevOps elements (Docker Scout, automated scripts) ensure that security checks and health assessments are continuously performed.

##### Architectural Patterns and Design Principles
- Separation of concerns: Frontend components, configuration, deployment scripts, and infrastructure definitions (Docker, Kubernetes) are clearly separated.
- Containerization: Using Docker’s multi-stage builds and Docker Compose enables faster, more efficient container builds and consistent environments.
- Orchestration and Scalability: Kubernetes manifests show design for scaling, self-healing (using HPA), and service discovery.
- CI/CD Integration: Presence of build and deployment specifications (appspec.yml, buildspec.yml) signals automated and repeatable releases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    WebBrowser["Web Browser"]:::client

    %% Frontend Layer
    subgraph "Frontend Layer"
        AppCode["React Frontend (Application Code)"]:::frontend
        StaticAssets["Static Assets"]:::frontend
    end

    %% Containerization & Build Layer
    subgraph "Containerization & Build"
        Dockerfile["Dockerfile"]:::container
        DockerfileDev["Dockerfile.dev"]:::container
        DockerIgnore[".dockerignore"]:::container
        DockerCompose["docker-compose.yml"]:::container
        StartScript["Start Container Script"]:::container
        StopScript["Stop Container Script"]:::container
        DockerInstall["Docker Installation"]:::container
        DockerScout["Docker Scout Report"]:::container
        DockerContainer["E-commerce App Container"]:::container
    end

    %% Deployment & Orchestration Layer
    subgraph "Deployment & Orchestration"
        ReverseProxy["Nginx Reverse Proxy"]:::deployment
        KubernetesManifests["Kubernetes Manifests"]:::deployment
        AppSpec["AppSpec (CI/CD)"]:::deployment
        BuildSpec["BuildSpec (CI/CD)"]:::deployment
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        AmazonEC2["Amazon EC2 Hosting"]:::infra
    end

    %% Arrows between layers and components
    WebBrowser -->|"HTTP_request"| ReverseProxy
    ReverseProxy -->|"Routes"| DockerContainer

    AppCode -->|"BuildInput"| DockerContainer
    StaticAssets -->|"BuildInput"| DockerContainer

    Dockerfile --> DockerContainer
    DockerfileDev --> DockerContainer
    DockerIgnore --> DockerContainer
    DockerCompose --> DockerContainer
    StartScript --> DockerContainer
    StopScript --> DockerContainer
    DockerInstall --> DockerContainer
    DockerScout --> DockerContainer

    AppSpec -->|"TriggersBuild"| DockerContainer
    BuildSpec -->|"TriggersBuild"| DockerContainer

    DockerContainer -->|"Deployment"| KubernetesManifests
    KubernetesManifests -->|"HostedOn"| AmazonEC2

    %% Click Events for Frontend Layer
    click AppCode "https://github.com/londheshubham153/online_shopping_app/tree/master/src"
    click StaticAssets "https://github.com/londheshubham153/online_shopping_app/tree/master/public"

    %% Click Events for Containerization & Build Layer
    click Dockerfile "https://github.com/londheshubham153/online_shopping_app/tree/master/Dockerfile"
    click DockerfileDev "https://github.com/londheshubham153/online_shopping_app/blob/master/Dockerfile.dev"
    click DockerIgnore "https://github.com/londheshubham153/online_shopping_app/blob/master/.dockerignore"
    click DockerCompose "https://github.com/londheshubham153/online_shopping_app/blob/master/docker-compose.yml"
    click StartScript "https://github.com/londheshubham153/online_shopping_app/blob/master/scripts/start_container.sh"
    click StopScript "https://github.com/londheshubham153/online_shopping_app/blob/master/scripts/stop_container.sh"
    click DockerInstall "https://github.com/londheshubham153/online_shopping_app/blob/master/docker_installation.sh"
    click DockerScout "https://github.com/londheshubham153/online_shopping_app/blob/master/image_report.md"

    %% Click Events for Deployment & Orchestration Layer
    click ReverseProxy "https://github.com/londheshubham153/online_shopping_app/blob/master/nginx.conf"
    click KubernetesManifests "https://github.com/londheshubham153/online_shopping_app/tree/master/k8s"
    click AppSpec "https://github.com/londheshubham153/online_shopping_app/blob/master/appspec.yml"
    click BuildSpec "https://github.com/londheshubham153/online_shopping_app/blob/master/buildspec.yml"

    %% Click Event for Infrastructure Layer
    click AmazonEC2 "https://github.com/londheshubham153/online_shopping_app/blob/master/README.md"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef frontend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef container fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef deployment fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef infra fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
