# focus1102/cake-selling-website architecture

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

- Interactive diagram: https://gitdiagram.com/focus1102/cake-selling-website
- Repository: https://github.com/focus1102/cake-selling-website

## Overview

##### Project Type and Purpose
- This is a full-stack e-commerce web application (“Cake Selling Website”) with a Vue-based SPA frontend and a Node/Express/MongoDB backend.
- It serves two user groups: customers (browse cakes, manage cart, place orders) and administrators (product, order, and user management + analytics dashboard).

##### File Structure Analysis
- Top-level directories:
- frontend code in `src` + `public` + root Vue config files (`babel.config.js`, `vue.config.js`, `jsconfig.json`).
- backend API in `backend` (controllers, models, middleware, routes, `server.js`).
- There is also a `server` folder (with its own package.json) which appears to be a duplicate or alternate backend entry point—assess whether one can be removed or consolidated.
- Backend follows an MVC-inspired pattern:
- models/ (Mongoose schemas)
- controllers/ (business logic)
- routes/ (HTTP endpoints)
- middleware/ (auth, admin guard, error handling)
- Frontend uses Vue 3 with:
- `src/router` (Vue Router setup)
- `src/store` (Vuex modules: auth, cart, products, paymentHistory)
- `src/components` & `src/admin/components` + `src/admin/views` for UI
- Configuration & deployment files: `.env` (Mongo URI, JWT secret, email creds), `package.json` files in each subproject.

##### README Insights
- Tech stack: Vue 3, Vuex, Vue Router, Axios, Node.js, Express, MongoDB, JWT, Nodemailer.
- API runs on port 5001, frontend on 8080.
- Key features map neatly to frontend views/components and backend controllers/routes.

##### Elements
- Clear labels: “Vue SPA”, “Express API”, “MongoDB”, “SMTP Email”
- HTTP calls from SPA to API (label: Axios/REST)
- DB queries from API to MongoDB (label: Mongoose)
- Email requests from API to SMTP (label: Nodemailer)
- Blue rectangles for services you host (SPA, API)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Zone
    subgraph "Frontend (Vue 3 SPA)"
        style Frontend fill:#D6EAF8,stroke:#000
        Browser["User Browser"]:::external
        VueApp["Vue SPA"]:::frontend
        Router["Vue Router"]:::frontend
        Store["Vuex Store"]:::frontend
        UIComponents["UI Components"]:::frontend
        App["App.vue"]:::frontend
        Main["main.js"]:::frontend
        IndexHTML["index.html"]:::frontend
    end

    %% Backend Zone
    subgraph "Backend (Node/Express API)"
        style Backend fill:#AED6F1,stroke:#000
        Routes["Routes"]:::backend
        Middleware["Middleware"]:::backend
        Controllers["Controllers"]:::backend
        Models["Models"]:::backend
    end

    %% Database and External Service
    MongoDB["MongoDB"]:::db
    SMTP["SMTP Email Service"]:::external

    %% Connections
    Browser <-->|"interacts"| VueApp
    VueApp -->|"Axios/REST"| Routes
    Routes -->|"uses"| Middleware
    Middleware -->|"guards & logs"| Controllers
    Controllers -->|"CRUD via Mongoose"| Models
    Models -->|"queries"| MongoDB
    Controllers -->|"send email via Nodemailer"| SMTP
    MongoDB --- SMTP

    %% Click Events - Frontend
    click Router "https://github.com/focus1102/cake-selling-website/blob/main/src/router/index.js"
    click Store "https://github.com/focus1102/cake-selling-website/blob/main/src/store/index.js"
    click App "https://github.com/focus1102/cake-selling-website/blob/main/src/App.vue"
    click Main "https://github.com/focus1102/cake-selling-website/blob/main/src/main.js"
    click IndexHTML "https://github.com/focus1102/cake-selling-website/blob/main/public/index.html"

    %% Click Events - Backend
    click Routes "https://github.com/focus1102/cake-selling-website/blob/main/backend/routes/authRoutes.js"
    click Controllers "https://github.com/focus1102/cake-selling-website/blob/main/backend/controllers/userController.js"
    click Models "https://github.com/focus1102/cake-selling-website/blob/main/backend/models/User.js"
    click Middleware "https://github.com/focus1102/cake-selling-website/blob/main/backend/middleware/auth.js"
    click MongoDB "https://github.com/focus1102/cake-selling-website/blob/main/backend/config/db.js"
    click SMTP "https://github.com/focus1102/cake-selling-website/blob/main/backend/.env"

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0298C3,color:#000
    classDef backend fill:#B2EBF2,stroke:#00796B,color:#000
    classDef db fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef external fill:#ECEFF1,stroke:#90A4AE,color:#000
```
