# hasanulhasan/teaching-torch architecture

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

- Interactive diagram: https://gitdiagram.com/hasanulhasan/teaching-torch
- Repository: https://github.com/hasanulhasan/teaching-torch

## Overview

##### Main Components

A. Frontend Layer:
- Next.js Application (Client-Side)
- Public Routes (/courses, /login, /signup, /feedback)
- Protected Routes ((withlayout) for admin and user profiles)
- Components Structure (Home, Course, Auth, UI components)
- State Management (Redux Store)
- Features (user, products, orders, feedback)
- API Slices
- Filter Management

B. Backend Layer:
- Node.js/Express.js Server
- MongoDB Database
- Authentication System (Firebase)

**[Client Layer]**
- ↕
**[API/Backend Layer]**
- ↕
**[Data Layer]**

##### Detailed Component Breakdown

Client Layer (Top):
**┌─────────────────────────────────────────────┐**
- Next.js Frontend                            │
- ┬──────────────┬───────────┤
- Public Routes   │ Auth Routes  │ Protected  │
- Home         │ - Login      │ - Admin    │
- Courses      │ - Signup     │ - Profile  │
- ┴──────────────┴───────────┘

State Management (Middle):
**┌─────────────────────────────────────────────┐**
- Redux Store                                 │
- ┬────────────────┬────────────┤
- User Slice   │ Product API    │ Order API  │
- Filter Slice │ Feedback API   │ User API   │
- ┴────────────────┴────────────┘

Backend Services (Bottom):
**┌─────────────────────────────────────────────┐**
- Backend Services                            │
- ┬────────────────┬────────────┤
- Firebase     │ Express.js     │ MongoDB    │
- Auth         │ API Server     │ Database   │
- ┴────────────────┴────────────┘

##### Important Flows to Highlight

- User Authentication Flow
- Course Management Flow
- Order Processing Flow
- Feedback System Flow

##### Additional Elements

- Separation between public and protected routes
- Integration points with Firebase
- API endpoints and their relationships

##### Technical Details to Note

- TypeScript implementation across both frontend and backend
- RTK Query for API management
- Ant Design and Tailwind CSS for UI
- MongoDB with Mongoose for data modeling
- Firebase for authentication

Remember to indicate the responsive nature of the application and how the different user roles (admin/user) interact with the system differently.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        PublicRoute[Public Route]:::public
        ProtectedRoute[Protected Route]:::protected
        DynamicRoute[Dynamic Route]:::dynamic
    end

    Root["/"]:::public --> Courses["/courses"]:::public
    Root --> DynamicId["/[id]"]:::dynamic
    Root --> Feedback["/feedback"]:::public
    Root --> Orders["/orders"]:::public
    Root --> Login["/login"]:::public
    Root --> Signup["/signup"]:::public
    Root --> AddCourse["/add-course"]:::public
    
    subgraph Protected["Protected Routes (with layout)"]
        subgraph Admin["Admin Routes"]
            ManageCourses["/admin/manage-courses"]:::protected
            ManageFeedbacks["/admin/manage-feedbacks"]:::protected
            ManageOrders["/admin/manage-orders"]:::protected
            ManageUsers["/admin/manage-users"]:::protected
        end

        subgraph Profile["User Profile Routes"]
            ProfileRoot["/profile"]:::protected
            ProfileFeedback["/profile/manage-feedback"]:::protected
            ProfileOrders["/profile/manage-orders"]:::protected
        end
    end

    classDef public fill:#90EE90
    classDef protected fill:#FFB6C1
    classDef dynamic fill:#87CEEB

    click Root "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/page.tsx"
    click Courses "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/courses/page.tsx"
    click DynamicId "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/[id]/page.tsx"
    click Feedback "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/feedback/page.tsx"
    click Orders "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/orders/page.tsx"
    click Login "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/login/page.tsx"
    click Signup "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/signup/page.tsx"
    click AddCourse "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/add-course/page.tsx"
    click ManageCourses "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/admin/manage-courses/page.tsx"
    click ManageFeedbacks "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/admin/manage-feedbacks/page.tsx"
    click ManageOrders "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/admin/manage-orders/page.tsx"
    click ManageUsers "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/admin/manage-users/page.tsx"
    click ProfileRoot "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/profile/page.tsx"
    click ProfileFeedback "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/profile/manage-feedback/page.tsx"
    click ProfileOrders "https://github.com/hasanulhasan/teaching-torch/blob/main/src/app/(withlayout)/profile/manage-orders/page.tsx"
```
