# key-runnnnnnn/studynotion architecture

> Architecture diagram of the GitHub repository key-runnnnnnn/studynotion, 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/key-runnnnnnn/studynotion
- Repository: https://github.com/key-runnnnnnn/studynotion

## Overview

##### Project type and purpose
- From the folder names and README (“Study Notion”), this is a full-stack e-learning / course platform.
- The client directory is a React (with Redux) Progressive Web App (PWA) using Tailwind CSS and service workers.
- The server directory is an Express.js REST API with controllers, middleware, models (likely MongoDB via Mongoose), payment integration (Razorpay), image hosting (Cloudinary), and e-mail notifications.

##### File structure
- Top-level: two main services—client/ (React front end) and server/ (Node.js back end).
- client/src: organized into Components (common UI, core pages, Dashboard flows), pages (React Router entry points), Redux slices, services for API calls, hooks, assets, config (tailwind), and PWA setup (service worker).
- server/: config (database, Cloudinary, Razorpay), controllers (business logic), routes (API endpoints), models (data schemas), middlewares (auth & demo stubs), utilities (imageUploader, mailSender, helpers), mail templates, and env example.

##### README for additional insights
- The README only gives the project name. We infer architecture and responsibilities from the file layout and dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (React PWA)"
        direction TB
        UIComp["UI Components"]:::frontend
        Redux["Redux Slices"]:::frontend
        APIConn["API Connector"]:::frontend
        SW["Service Worker"]:::frontend
        Tailwind["Tailwind Config"]:::frontend
    end

    %% Server Side
    subgraph "Server (Express API)"
        direction TB
        ServerEntry["server/index.js"]:::backend
        subgraph "API Gateway (Routes)"
            direction TB
            Routes["Express Routes"]:::backend
        end
        subgraph "Middleware"
            direction TB
            AuthMW["Auth Middleware (JWT)"]:::backend
            DemoMW["Demo Middleware"]:::backend
        end
        subgraph "Controllers"
            direction TB
            PaymentsController["Payments Controller"]:::backend
            ProfileController["Profile Controller"]:::backend
            CourseController["Course Controller"]:::backend
            RatingController["Rating & Reviews Controller"]:::backend
            ResetController["Password Reset Controller"]:::backend
            ContactController["Contact Us Controller"]:::backend
        end
        Models["Models (Mongoose Schemas)"]:::backend
        subgraph "Config"
            direction TB
            DBConfig["Database Config"]:::backend
            CloudConfig["Cloudinary Config"]:::backend
            RazorConfig["Razorpay Config"]:::backend
            EnvExample[".env.example"]:::backend
        end
        subgraph "Utilities"
            direction TB
            ImageUtil["Image Uploader Utility"]:::backend
            MailUtil["Mail Sender Utility"]:::backend
            MailTemplates["Email Templates"]:::backend
        end
    end

    %% External Services & Database
    subgraph "External Services"
        direction TB
        MongoDB["MongoDB Atlas"]:::database
        Cloudinary["Cloudinary"]:::external
        Razorpay["Razorpay"]:::external
        SMTP["SMTP / Email Service"]:::external
    end

    %% Client Flow
    Browser["User Browser"]:::frontend
    Browser -->|interacts| UIComp
    UIComp -->|dispatches actions| Redux
    Redux -->|API calls| APIConn
    APIConn -->|HTTP requests| ServerEntry
    Browser -->|offline caching| SW
    Tailwind -->|styles| UIComp

    %% Server Flow
    ServerEntry -->|routes to| Routes
    Routes -->|executes| AuthMW
    Routes -->|executes| DemoMW
    AuthMW -->|calls| Controllers
    DemoMW -->|calls| Controllers
    Routes -->|invokes| Controllers
    Controllers -->|uses| Models
    Models -->|reads/writes| MongoDB
    Controllers -->|loads config| DBConfig
    Controllers -->|loads config| CloudConfig
    Controllers -->|loads config| RazorConfig
    Controllers -->|sends emails via| MailUtil
    Controllers -->|uploads images via| ImageUtil
    Controllers -->|uses templates| MailTemplates
    Controllers -->|processes payments via| Razorpay
    Controllers -->|stores media via| Cloudinary
    MailUtil -->|uses SMTP| SMTP

    %% Click Events
    click UIComp "https://github.com/key-runnnnnnn/studynotion/tree/master/client/src/Components/"
    click Redux "https://github.com/key-runnnnnnn/studynotion/tree/master/client/src/slices/"
    click APIConn "https://github.com/key-runnnnnnn/studynotion/blob/master/client/src/services/apiConnector.js"
    click SW "https://github.com/key-runnnnnnn/studynotion/blob/master/client/public/service-worker.js"
    click Tailwind "https://github.com/key-runnnnnnn/studynotion/blob/master/client/tailwind.config.js"
    click ServerEntry "https://github.com/key-runnnnnnn/studynotion/blob/master/server/index.js"
    click Routes "https://github.com/key-runnnnnnn/studynotion/tree/master/server/routes/"
    click AuthMW "https://github.com/key-runnnnnnn/studynotion/blob/master/server/middlewares/auth.js"
    click DemoMW "https://github.com/key-runnnnnnn/studynotion/blob/master/server/middlewares/demo.js"
    click PaymentsController "https://github.com/key-runnnnnnn/studynotion/blob/master/server/controllers/Payments.js"
    click ProfileController "https://github.com/key-runnnnnnn/studynotion/blob/master/server/controllers/Profile.js"
    click CourseController "https://github.com/key-runnnnnnn/studynotion/blob/master/server/controllers/Course.js"
    click RatingController "https://github.com/key-runnnnnnn/studynotion/blob/master/server/controllers/RatingAndReviews.js"
    click ResetController "https://github.com/key-runnnnnnn/studynotion/blob/master/server/controllers/ResetPassword.js"
    click ContactController "https://github.com/key-runnnnnnn/studynotion/blob/master/server/controllers/ContactUs.js"
    click Models "https://github.com/key-runnnnnnn/studynotion/tree/master/server/models/"
    click DBConfig "https://github.com/key-runnnnnnn/studynotion/blob/master/server/config/database.js"
    click CloudConfig "https://github.com/key-runnnnnnn/studynotion/blob/master/server/config/cloudinary.js"
    click RazorConfig "https://github.com/key-runnnnnnn/studynotion/blob/master/server/config/razorpay.js"
    click ImageUtil "https://github.com/key-runnnnnnn/studynotion/blob/master/server/utils/imageUploader.js"
    click MailUtil "https://github.com/key-runnnnnnn/studynotion/blob/master/server/utils/mailSender.js"
    click MailTemplates "https://github.com/key-runnnnnnn/studynotion/tree/master/server/mail/templates/"
    click EnvExample "https://github.com/key-runnnnnnn/studynotion/blob/master/server/.env.example"

    %% Styles
    classDef frontend fill:#89CFF0,stroke:#333,stroke-width:1px;
    classDef backend fill:#7CFC00,stroke:#333,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef database fill:#CCCCCC,stroke:#333,stroke-width:1px;
```
