# chinmaykhamkar/lor architecture

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

- Interactive diagram: https://gitdiagram.com/chinmaykhamkar/lor
- Repository: https://github.com/chinmaykhamkar/lor

## Overview

##### Main Components

A. Frontend (React.js):
- Sub-components:
- Public Components (Navigation, Common Elements)
- Student Module (Screens, Routes)
- Teacher Module (Screens, Routes)
- Authentication Views (Login/Register/Reset)

B. Backend (Node.js):
- Sub-components:
- API Routes Layer
- Controllers Layer
- Middleware Layer
- Models Layer

C. External Services:
- Database (MongoDB)
- Email Service (SendGrid)
- Hosting Services (Heroku for backend, Vercel for frontend)

##### Component Relationships

- Frontend → Backend (REST API calls)
- Backend → MongoDB (Data persistence)
- Backend → SendGrid (Email notifications)
- User → Frontend (Client interactions)

##### Detailed Component Breakdown

A. Frontend Architecture:
**Client**
- Public Components
- Navigation
- Common UI Elements
- Student Module
- Routes (Home, Profile, Teachers, University)
- Screens (Login, Register, Dashboard)
- Teacher Module
- Routes (Home, Profile, Students, Requests)
- Screens (Login, Register, Dashboard)

B. Backend Architecture:
**Server**
- Routes Layer (API Endpoints)
- Student Routes
- Teacher Routes
- Controllers
- Student Controllers
- Teacher Controllers
- Middleware
- Authentication
- Error Handling
- Models
- Student Schema
- Teacher Schema

##### Additional Elements

- Data flow indicators
- API endpoint groupings
- Security middleware placement
- Error handling flow

##### Key Architectural Patterns to Highlight

- MVC pattern in backend
- Component-based architecture in React
- RESTful API structure
- JWT authentication flow
- Middleware pipeline

**[User/Browser] → [Frontend (Vercel)]**
- ↓
**[Authentication Layer] ← → [Backend (Heroku)] ← → [MongoDB]**
- ↓
- [SendGrid Email]

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Side (React.js)"]
        direction TB
        PublicComp["Public Components"]:::frontend
        click PublicComp "https://github.com/chinmaykhamkar/LoR/tree/master/client/src/components/common"
        
        Navigation["Navigation"]:::frontend
        click Navigation "https://github.com/chinmaykhamkar/LoR/blob/master/client/src/components/common/publicNav.js"
        
        CommonUI["Common UI Elements"]:::frontend
        click CommonUI "https://github.com/chinmaykhamkar/LoR/blob/master/client/src/components/common/mainCard.js"
        
        PublicComp --> Navigation
        PublicComp --> CommonUI
        
        subgraph StudentModule["Student Module"]
            direction TB
            StudentRoutes["Routes"]:::frontend
            click StudentRoutes "https://github.com/chinmaykhamkar/LoR/tree/master/client/src/components/student/routing"
            
            StudentScreens["Screens"]:::frontend
            click StudentScreens "https://github.com/chinmaykhamkar/LoR/tree/master/client/src/components/student/screens/js"
            
            StudentAuth["Authentication"]:::auth
            click StudentAuth "https://github.com/chinmaykhamkar/LoR/blob/master/client/src/components/student/screens/js/LoginScreen.js"
        end
        
        subgraph TeacherModule["Teacher Module"]
            direction TB
            TeacherRoutes["Routes"]:::frontend
            click TeacherRoutes "https://github.com/chinmaykhamkar/LoR/tree/master/client/src/components/teacher/routing"
            
            TeacherScreens["Screens"]:::frontend
            click TeacherScreens "https://github.com/chinmaykhamkar/LoR/tree/master/client/src/components/teacher/screens/js"
            
            TeacherAuth["Authentication"]:::auth
            click TeacherAuth "https://github.com/chinmaykhamkar/LoR/blob/master/client/src/components/teacher/screens/js/LoginScreen.js"
        end
    end
    
    subgraph Server["Server Side (Node.js)"]
        direction TB
        subgraph Routes["API Routes Layer"]
            direction TB
            StudentAPIRoutes["Student Routes"]:::backend
            click StudentAPIRoutes "https://github.com/chinmaykhamkar/LoR/blob/master/routes/student/student.route.js"
            
            TeacherAPIRoutes["Teacher Routes"]:::backend
            click TeacherAPIRoutes "https://github.com/chinmaykhamkar/LoR/blob/master/routes/teacher/teacher.route.js"
            
            AuthRoutes["Auth Routes"]:::auth
            click AuthRoutes "https://github.com/chinmaykhamkar/LoR/blob/master/routes/student/auth.route.js"
        end
        
        subgraph Controllers["Controllers Layer"]
            direction TB
            StudentControllers["Student Controllers"]:::backend
            click StudentControllers "https://github.com/chinmaykhamkar/LoR/blob/master/controllers/student/student.controller.js"
            
            TeacherControllers["Teacher Controllers"]:::backend
            click TeacherControllers "https://github.com/chinmaykhamkar/LoR/blob/master/controllers/teacher/teacher.controller.js"
            
            AuthControllers["Auth Controllers"]:::auth
            click AuthControllers "https://github.com/chinmaykhamkar/LoR/blob/master/controllers/student/auth.controller.js"
        end
        
        subgraph Middleware["Middleware Layer"]
            direction TB
            AuthMiddleware["Authentication"]:::auth
            click AuthMiddleware "https://github.com/chinmaykhamkar/LoR/blob/master/middleware/student/student.auth.js"
            
            ErrorHandling["Error Handling"]:::backend
            click ErrorHandling "https://github.com/chinmaykhamkar/LoR/blob/master/middleware/error.js"
        end
        
        subgraph Models["Models Layer"]
            direction TB
            StudentModel["Student Schema"]:::backend
            click StudentModel "https://github.com/chinmaykhamkar/LoR/blob/master/models/student/Student.js"
            
            TeacherModel["Teacher Schema"]:::backend
            click TeacherModel "https://github.com/chinmaykhamkar/LoR/blob/master/models/teacher/Teacher.js"
        end
    end
    
    ExternalDB[("MongoDB")]:::external
    EmailService["SendGrid Email Service"]:::external
    click EmailService "https://github.com/chinmaykhamkar/LoR/blob/master/utils/sendEmail.js"
    
    User((User/Browser)):::user
    
    %% Connections
    User --> Client
    Client --> Server
    Server --> ExternalDB
    Server --> EmailService
    
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef user fill:#95a5a6,stroke:#7f8c8d,color:white
    
    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Auth["Auth Component"]:::auth
        External["External Service"]:::external
    end
```
