# codebytarun08/studycart architecture

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

- Interactive diagram: https://gitdiagram.com/codebytarun08/studycart
- Repository: https://github.com/codebytarun08/studycart

## Overview

##### Project type and purpose
- StudyCart is a full-stack, monolithic MERN (MongoDB, Express.js, React.js, Node.js) education platform.
- Purpose: allow instructors to create/manage courses and students to browse, enroll, consume, and rate content.

##### File structure
- Top-level “public” and “src” directories indicate a React front-end.
- “Server” directory holds the Node/Express back-end (REST API, controllers, models).
- “src/components”, “src/pages”, “src/services”, “src/slices”, “src/hooks”, “src/reducer” reveal a client-side architecture using React Router, Redux Toolkit (slices + store), hooks, and service modules for API calls.
- Configuration files: package.json, tailwind.config.js.
- Assets and images under “public” and “src/assets” for UI media.
- Data files (countrycode.json, navbar-links.js) for static lookups.

##### README for additional insights
- Confirms a client-server architecture: front-end (React + Redux + Tailwind CSS), back-end (Node + Express + Mongoose + JWT + Bcrypt), database (MongoDB).
- External integrations: Cloudinary for media, Razorpay for payments, email/OTP service.
- Describes REST endpoints, data models (Student, Instructor, Course).
- Includes a high-level image (images/architecture.png) showing front-end ↔ back-end ↔ database.

##### Main components and their relationships
a. Front-end (React App)
- Sub­components: pages (Home, Catalog, CoursePage, Dashboard, Auth pages), shared UI (Navbar, Footer, Modals), feature components (CourseCard, VideoPlayer, Forms).
- State layer: Redux slices (authSlice, cartSlice, courseSlice, profileSlice, viewCourseSlice), async thunks in services/operations calling REST APIs.
- Routing: React Router with public and PrivateRoute wrappers.

b. Back-end (Node/Express server)
- Controllers/routers for auth, courses, payments, profile, settings.
- Middleware: JWT authentication, error handling.
- Business logic modules: services/operations/*.js, db connection, Cloudinary integration, Razorpay webhook handler.

c. Database (MongoDB)
- Collections: Users (students/instructors), Courses, Orders/Payments, etc.
- Schemas defined via Mongoose models inside “Server”.

d. External services
- Cloudinary for media storage.
- Razorpay for payment processing.
- Email/OTP service (SMTP or third-party).

##### Architectural patterns and design principles
- Client-server via RESTful API.
- Modular React with feature folders and centralized Redux state.
- MVC-style organization on server (routes → controllers → services → models).
- Secure JWT auth, protected routes both client-side and server-side.
- Separation of concerns: UI vs. state vs. API logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["End User\n(Browser)"]:::user

    %% Client Layer
    subgraph "Client (React)" 
        direction TB
        ReactClient["React Client\n(src/)"]:::frontend
        ReduxStore["Redux Store\n(src/reducer/index.js)"]:::frontend
        Slices["Redux Slices\n(src/slices)"]:::frontend
        APILayer["API Connector\n(src/services/apiConnector.js)"]:::frontend
        APIs["Endpoints Definitions\n(src/services/apis.js)"]:::frontend
        Operations["Async Thunks\n(src/services/operations)"]:::frontend
        Hooks["Custom Hooks\n(src/hooks/)"]:::frontend
        UICommon["Shared UI\n(src/components/core/common/)"]:::frontend
    end

    User -->|Interacts via UI| ReactClient
    ReactClient -->|Dispatch Actions| ReduxStore
    ReduxStore -->|Uses| Slices
    ReduxStore -->|Calls| APILayer
    APILayer -->|Requests| APIs
    APIs -->|Executes| Operations
    ReactClient -->|Uses Hooks| Hooks
    ReactClient -->|Renders Components| UICommon

    %% Server Layer
    subgraph "Server (Node/Express)" 
        direction TB
        ServerApp["Express App\n(Server/)"]:::backend
        Routes["Routers/Routes"]:::backend
        Controllers["Controllers"]:::backend
        Services["Business Services"]:::backend
        Models["Mongoose Models"]:::backend
        Middleware["JWT Auth & Error\nMiddleware"]:::backend
    end

    APILayer -->|HTTP Requests| ServerApp
    ServerApp -->|Defines| Routes
    Routes -->|Invoke| Controllers
    Controllers -->|Use| Services
    Services -->|CRUD| Models
    ServerApp -->|Apply| Middleware

    %% Database Layer
    subgraph "Database"
        direction TB
        MongoDB["MongoDB Atlas"]:::database
    end

    Models -->|Queries| MongoDB

    %% External Services
    Cloudinary["Cloudinary"]:::external
    Razorpay["Razorpay"]:::external
    EmailService["Email/OTP Service"]:::external

    Services -->|Media Upload| Cloudinary
    Services -->|Payment Requests| Razorpay
    Services -->|Send Emails/OTP| EmailService

    %% Click Events
    click ReactClient "https://github.com/codebytarun08/studycart/tree/main/src/"
    click ReduxStore "https://github.com/codebytarun08/studycart/blob/main/src/reducer/index.js"
    click Slices "https://github.com/codebytarun08/studycart/blob/main/src/slices/*.js"
    click APILayer "https://github.com/codebytarun08/studycart/blob/main/src/services/apiConnector.js"
    click APIs "https://github.com/codebytarun08/studycart/blob/main/src/services/apis.js"
    click Operations "https://github.com/codebytarun08/studycart/blob/main/src/services/operations/*.js"
    click Hooks "https://github.com/codebytarun08/studycart/tree/main/src/hooks/"
    click UICommon "https://github.com/codebytarun08/studycart/tree/main/src/components/core/common/"
    click ServerApp "https://github.com/codebytarun08/studycart/tree/main/Server/"
    click README "https://github.com/codebytarun08/studycart/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#DFF2DB,stroke:#2f8f2f,color:#2f8f2f;
    classDef database fill:#FFE5B4,stroke:#d78b00,color:#d78b00;
    classDef external fill:#E2E2E2,stroke:#666666,color:#666666;
    classDef user fill:#F0F0F0,stroke:#999999,color:#333333;
```
