# harsh2509/coursesellingwebsite architecture

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

- Interactive diagram: https://gitdiagram.com/harsh2509/coursesellingwebsite
- Repository: https://github.com/harsh2509/coursesellingwebsite

## Overview

##### Project type and purpose
- This is a full-stack course-selling application with two client frontends (an admin dashboard and a user-facing site) and a Node/Express backend.
- The README describes routes for the user site (list courses, purchased courses, view/purchase single course, signup/login, landing page) and mentions an existing admin dashboard front end.

##### File structure
- Top level:
- /.github – CI pipeline for tests/linting
- /client – Vite-powered React user site
- /server – Express backend, with routes, middleware, and a Database folder
- client/src: React components (pages & UI elements), state management under src/store (Jotai atoms & selectors), routing via react-router.
- server: Express entry point (index.js), two Routers (admin.js, users.js), middleware for adminAuth & userAuth, Database/index.js for data persistence.

##### README for additional insights
- Emphasizes boilerplate creation with Vite and the RESTful routes.

a. Main components:
- User Frontend (client) – built with Vite/React, MUI, Jotai state, React Router, Axios calls
- Admin Frontend – (02-medium-course-selling-app-admin-dashboard, similar tech stack)
- Backend API (server) – Node.js, Express, REST endpoints under /users and /admin, authentication middleware
- Database – the persistence layer imported under server/Database/index.js (could be MongoDB, PostgreSQL, etc.)
- External Services (optional) – e.g., payment gateway for purchases
b. Relationships & interactions:
- Browsers ▶ REST calls ▶ API endpoints
- API ▶ reads/writes ▶ Database
- Middleware intercepts ▶ auth checks ▶ route handlers
- Frontends share the same API but use different routes (admin vs. user)
c. Architectural patterns & design principles:
- Separation of concerns: frontends vs. backend vs. DB
- RESTful API layer with stateless endpoints
- Authentication & authorization via middleware (adminAuth, userAuth)
- Component-driven UI on the frontends, atomic state management (Jotai)
d. Key technologies & libraries:
- Frontends – Vite, React, React Router, Axios, MUI, Jotai
- Backend – Node.js, Express, dotenv for config, custom middleware, Database connector

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontends
    subgraph "User Frontend"
        UF["User Frontend"]:::frontend
        UMain["main.jsx"]:::frontend
        App["App.jsx"]:::frontend
        Components["Components/"]:::frontend
        Atoms["store/atoms/"]:::frontend
        Selectors["store/selectors/"]:::frontend
    end

    subgraph "Admin Frontend"
        AF["Admin Frontend"]:::frontend
    end

    %% Backend
    subgraph "Backend API"
        API["Express API"]:::backend
        subgraph "Routes"
            UsersRoute["users.js"]:::backend
            AdminRoute["admin.js"]:::backend
        end
        subgraph "Middleware"
            userAuth["userAuth.js"]:::middleware
            adminAuth["adminAuth.js"]:::middleware
        end
        DB["Database Connector"]:::db
    end

    %% External Services
    Payment["Payment Service"]:::ext

    %% Flows
    UF -->|"GET /courses\nPOST /login"| UsersRoute
    UF -->|"POST /purchase"| UsersRoute
    AF -->|"GET /admin/*"| AdminRoute

    UsersRoute -->|uses| userAuth
    AdminRoute -->|uses| adminAuth

    UsersRoute -->|DB: query/update| DB
    AdminRoute -->|DB: query/update| DB

    UsersRoute -->|calls| Payment

    %% Click Events
    click UF "https://github.com/harsh2509/coursesellingwebsite/tree/main/client/"
    click UMain "https://github.com/harsh2509/coursesellingwebsite/blob/main/client/src/main.jsx"
    click App "https://github.com/harsh2509/coursesellingwebsite/blob/main/client/src/App.jsx"
    click Components "https://github.com/harsh2509/coursesellingwebsite/tree/main/client/src/Components/"
    click Atoms "https://github.com/harsh2509/coursesellingwebsite/tree/main/client/src/store/atoms/"
    click Selectors "https://github.com/harsh2509/coursesellingwebsite/tree/main/client/src/store/selectors/"
    click AF "https://github.com/harsh2509/coursesellingwebsite/tree/main/02-medium-course-selling-app-admin-dashboard"
    click API "https://github.com/harsh2509/coursesellingwebsite/tree/main/server/"
    click ServerIndex "https://github.com/harsh2509/coursesellingwebsite/blob/main/server/index.js"
    click UsersRoute "https://github.com/harsh2509/coursesellingwebsite/blob/main/server/Routes/users.js"
    click AdminRoute "https://github.com/harsh2509/coursesellingwebsite/blob/main/server/Routes/admin.js"
    click userAuth "https://github.com/harsh2509/coursesellingwebsite/blob/main/server/MiddleWares/userAuth.js"
    click adminAuth "https://github.com/harsh2509/coursesellingwebsite/blob/main/server/MiddleWares/adminAuth.js"
    click DB "https://github.com/harsh2509/coursesellingwebsite/blob/main/server/Database/index.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#888
    classDef backend fill:#C8F7C5,stroke:#888
    classDef middleware fill:#FFF3CD,stroke:#888
    classDef db fill:#FFD8A8,stroke:#888
    classDef ext fill:#E1CCE1,stroke:#888
```
