# meruemvn/ocop_fe architecture

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

- Interactive diagram: https://gitdiagram.com/meruemvn/ocop_fe
- Repository: https://github.com/meruemvn/ocop_fe

## Overview

##### Project type and purpose
- This is a Vue.js single-page application (SPA) serving as the front-end for an e-commerce “store” (“OCOP_FE”).
- It provides user flows for browsing products, viewing details, searching, cart management, checkout, user profile, admin/distributor dashboards, and recommendations.
- It communicates with back-end REST services for products, orders, authentication, and recommendations.

##### File structure
- Top-level config files: .env(.production), babel.config.js, jsconfig.json, vue.config.js, package.json, package-lock.json – indicate Node/NPM + Vue CLI + Babel build pipeline.
- public/: static assets (index.html, images).
- src/main.js: application entry point bootstrapping Vue, router, store.
- src/router/index.js: Vue Router for SPA navigation (views and nested routes).
- src/store/index.js + src/store/modules/: Vuex state management, split by domain (admin, auth, cart, distributor, order, product, recommendation, user).
- src/services/: abstraction over HTTP interactions (api.js generic Axios wrapper; auth.service.js; recommendation.service.js; other domain services via api.js).
- src/components/ & src/views/: UI layer—reusable components and page-level views organized by feature.
- src/directives/: custom Vue directives.

##### README
- Standard Vue CLI commands (serve, build, lint).
- No additional architecture details provided.

a. Main components
- Browser client (user’s browser)
- Vue SPA:
- Router
- Vuex store (modules: auth, cart, product, order, recommendation, user, distributor, admin)
- Components & Views (UI layer)
- Services layer (API client)
- Build pipeline (Node/NPM, webpack, Babel)
- External APIs (back-end microservices or monolith exposing REST endpoints for auth, products, orders, recommendations)
- Static asset host (CDN or public folder)
b. Relationships & interactions
- Browser <--> Vue SPA via HTTP/Webpack dev server (dev) or static assets + bundle (prod)
- Within SPA, Views dispatch Vuex actions → Services make HTTP calls → Backend APIs
- Responses update Vuex store → Views/components re-render
- Router defines navigational flows between Views
- Build tools (Vue CLI/webpack) take src/ and assets → produce dist/ bundle
c. Architectural patterns
- Modular Vuex store (domain-driven modules)
- Service layer abstracting HTTP (single Axios instance + domain services)
- Component-based UI (atomic/common, feature-specific, view-level)
- SPA with client-side routing
d. Relevant technologies
- Vue.js, Vue Router, Vuex
- Axios (in api.js)
- Babel, webpack (via Vue CLI)
- Node.js / NPM
- CSS assets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Deploy Pipeline
    subgraph "Build & Deploy" 
        direction TB
        Env[".env / .env.production"]:::build
        Babel["babel.config.js"]:::build
        VueCLI["vue.config.js"]:::build
        NPM["package.json / package-lock.json"]:::build
        Env --> Babel --> VueCLI --> NPM -->|"bundles"| Bundle["dist/"]:::build
    end

    %% Static Assets
    subgraph "Static Assets" 
        direction TB
        PublicHTML["public/index.html"]:::front
        PublicImgs["public/images/"]:::front
        Assets["src/assets/"]:::front
    end

    %% Browser Client
    Browser["User Browser"]:::external

    Browser -->|"loads"| PublicHTML
    PublicHTML -->|"serves bundle"| Bundle
    Browser -->|"serves assets"| PublicImgs
    Browser -->|"serves assets"| Assets

    %% Vue SPA
    subgraph "Vue SPA" 
        direction TB
        Entry["src/main.js"]:::front
        Router["Vue Router"]:::front
        StoreRoot["Vuex Store (root)"]:::state
        subgraph "Vuex Modules"
            direction TB
            AuthMod["Auth Module"]:::state
            CartMod["Cart Module"]:::state
            ProductMod["Product Module"]:::state
            OrderMod["Order Module"]:::state
            RecMod["Recommendation Module"]:::state
            UserMod["User Module"]:::state
            DistMod["Distributor Module"]:::state
            AdminMod["Admin Module"]:::state
        end
        subgraph "Services Layer"
            direction TB
            API["api.js (Axios Wrapper)"]:::data
            AuthSvc["auth.service.js"]:::data
            RecSvc["recommendation.service.js"]:::data
        end
        subgraph "UI Layer"
            direction TB
            subgraph "Components"
                direction TB
                CommonComps["src/components/common/"]:::front
                HomeWidgets["src/components/home/"]:::front
                ProdCard["ProductCard.vue"]:::front
                SearchBar["SearchBar.vue"]:::front
                UserDropdown["UserDropdown.vue"]:::front
                NotFoundComp["NotFound.vue"]:::front
            end
            subgraph "Views"
                direction TB
                HomeView["Home.vue"]:::front
                ProdListView["ProductList.vue"]:::front
                ProdDetailView["ProductDetail.vue"]:::front
                CartView["Cart.vue"]:::front
                CheckoutView["Checkout.vue"]:::front
                LoginView["Login.vue"]:::front
                RegisterView["Register.vue"]:::front
                OrderListView["MyOrders.vue"]:::front
                OrderDetailView["OrderDetail.vue"]:::front
                ProfileView["UserProfile.vue"]:::front
                NotFoundView["NotFound.vue"]:::front
                AdminDash["Admin/Dashboard.vue"]:::front
                AdminProdList["Admin/ProductList.vue"]:::front
                AdminUserList["Admin/UserList.vue"]:::front
                DistChannel["distributor/Channel.vue"]:::front
                DistProducts["distributor/Products.vue"]:::front
            end
        end

        Entry --> Router
        Router -->|navigates| HomeView
        HomeView -->|dispatches| AuthMod
        HomeView -->|dispatches| ProductMod
        HomeView -->|dispatches| RecMod
        HomeView -->|renders| HomeWidgets

        Router --> ProdListView
        ProdListView -->|dispatches| ProductMod
        ProdListView -->|uses| ProdCard

        ProdDetailView -->|dispatches| ProductMod

        CartView -->|dispatches| CartMod
        CheckoutView -->|dispatches| OrderMod

        LoginView -->|dispatches| AuthMod
        RegisterView -->|dispatches| AuthMod

        OrderListView -->|dispatches| OrderMod
        OrderDetailView -->|dispatches| OrderMod

        ProfileView -->|dispatches| UserMod

        AdminDash -->|dispatches| AdminMod
        AdminProdList -->|dispatches| AdminMod
        AdminUserList -->|dispatches| AdminMod

        DistChannel -->|dispatches| DistMod
        DistProducts -->|dispatches| DistMod

        AnyView["*"] --> NotFoundView

        %% Vuex to Services
        AuthMod -->|calls| AuthSvc
        CartMod -->|calls| API
        ProductMod -->|calls| API
        OrderMod -->|calls| API
        RecMod -->|calls| RecSvc
        UserMod -->|calls| API
        DistMod -->|calls| API
        AdminMod -->|calls| API

        %% Services to External APIs
        subgraph "External Backend APIs"
            direction TB
            AuthAPI["Auth Service REST"]:::external
            ProdAPI["Product Service REST"]:::external
            OrderAPI["Order Service REST"]:::external
            RecAPI["Recommendation Service REST"]:::external
        end

        AuthSvc -->|HTTP| AuthAPI
        API -->|HTTP| ProdAPI
        API -->|HTTP| OrderAPI
        RecSvc -->|HTTP| RecAPI

        Bundle --> Entry
    end

    %% Legend
    subgraph "Legend"
        direction LR
        F["Front-end"]:::front
        S["State"]:::state
        D["Data/API"]:::data
        B["Build"]:::build
        E["External"]:::external
    end

    classDef front fill:#D0E8FF,stroke:#90C8FF;
    classDef state fill:#E0F3D8,stroke:#A8DBA8;
    classDef data fill:#FFE0B2,stroke:#FFC070;
    classDef build fill:#EEEEEE,stroke:#CCCCCC;
    classDef external fill:#F8D7DA,stroke:#F5A3A8;

    %% Click Events
    click Router "https://github.com/meruemvn/ocop_fe/blob/main/src/router/index.js"
    click StoreRoot "https://github.com/meruemvn/ocop_fe/blob/main/src/store/index.js"
    click AuthMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/auth.js"
    click CartMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/cart.js"
    click ProductMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/product.js"
    click OrderMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/order.js"
    click RecMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/recommendation.js"
    click UserMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/user.js"
    click DistMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/distributor.js"
    click AdminMod "https://github.com/meruemvn/ocop_fe/blob/main/src/store/modules/admin.js"
    click API "https://github.com/meruemvn/ocop_fe/blob/main/src/services/api.js"
    click AuthSvc "https://github.com/meruemvn/ocop_fe/blob/main/src/services/auth.service.js"
    click RecSvc "https://github.com/meruemvn/ocop_fe/blob/main/src/services/recommendation.service.js"
    click CommonComps "https://github.com/meruemvn/ocop_fe/tree/main/src/components/common"
    click HomeWidgets "https://github.com/meruemvn/ocop_fe/tree/main/src/components/home"
    click ProdCard "https://github.com/meruemvn/ocop_fe/blob/main/src/components/products/ProductCard.vue"
    click SearchBar "https://github.com/meruemvn/ocop_fe/blob/main/src/components/SearchBar.vue"
    click UserDropdown "https://github.com/meruemvn/ocop_fe/blob/main/src/components/UserDropdown.vue"
    click NotFoundComp "https://github.com/meruemvn/ocop_fe/blob/main/src/components/NotFound.vue"
    click Entry "https://github.com/meruemvn/ocop_fe/blob/main/src/main.js"
    click PublicHTML "https://github.com/meruemvn/ocop_fe/blob/main/public/index.html"
    click PublicImgs "https://github.com/meruemvn/ocop_fe/tree/main/public/images/"
    click Assets "https://github.com/meruemvn/ocop_fe/tree/main/src/assets"
    click Babel "https://github.com/meruemvn/ocop_fe/blob/main/babel.config.js"
    click VueCLI "https://github.com/meruemvn/ocop_fe/blob/main/vue.config.js"
    click Env "https://github.com/meruemvn/ocop_fe/blob/main/.env"
    click NPM "https://github.com/meruemvn/ocop_fe/blob/main/package.json"
```
