# bhargava1424/sat architecture

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

- Interactive diagram: https://gitdiagram.com/bhargava1424/sat
- Repository: https://github.com/bhargava1424/sat

## Overview

##### Project Type and Purpose
- Full‑stack Student Assessment Tracking (SAT) system
- Frontend: React SPA for managing students, teachers, sessions, assessments, ECAs, and feedback
- Backend: Node.js/Express API with MongoDB for data persistence and business logic

##### Main System Components
A. Frontend (React)
- Components: Dashboard, Authentication (AuthContext), Modals (AddAttendance, AssessmentModal, etc.), Charts (Chart.js/Recharts)
- Public assets: index.html, manifest.json
- State & routing: React Context API, React Router DOM
- Styling: TailwindCSS, DaisyUI
- API calls: Axios to `/api/*` endpoints
B. Backend (Express)
- Entry: app.js
- Routes: authentication, teachers, students, assessments, sessions, branches, feedbacks, ECAs, clusters, drive
- Middleware: uploadMiddleware (Multer), error handler, JWT validation
- Business logic: server/utils/services.js
- Email: Nodemailer for notifications & password reset
- Google Drive: server/config/googleConfig.js for file storage integration
C. Database
- MongoDB via Mongoose models: Teacher, Student, Assessment, Feedback, ECA, Branch, Cluster, Session
D. External Services
- SMTP server (via Nodemailer)
- Google Drive API
- (Potential) third‑party services for analytics or hosting

##### Component Interactions and Data Flows
- User opens web browser → React SPA served by frontend build (port 3001)
- React makes HTTP(S) requests (Axios) to Express API (`/api/auth/*`, `/api/students`, etc.)
- Express routes invoke controller logic → Mongoose queries to MongoDB
- File uploads: React uploads files via form data → Express Multer middleware → Google Drive or local storage
- Authentication: React stores session/token → JWT sent with each request → Express middleware validates role-based access
- Notifications: Express triggers Nodemailer to send emails on certain events (password reset, feedback alerts)

##### Architectural Patterns and Design Principles
- Separation of concerns: clear split between UI, API, and data layers
- MVC‑style organization in backend (Routes → Models → Services)
- Component-driven UI with reusable hooks & context
- RESTful API design with resource-based endpoints
- Role-based access control enforced via middleware
- Environment-based configuration (.env files for API endpoints, DB URIs, secrets)

##### Detailed Elements
- Clear labels: “React SPA”, “Express API”, “MongoDB Atlas”
- Rounded rectangles for UI components
- Standard rectangles for services and databases
- Configuration notes: environment variables for ports, DB URIs, API keys

##### Final Checklist
- [ ] All major components (frontend, backend, database, external services) represented
- [ ] Data flows between tiers clearly indicated
- [ ] Architectural patterns (REST, MVC, middleware) annotated
- [ ] Technology stack noted alongside each component

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        ReactSPA["React SPA"]:::frontend
        PublicAssets["Public Assets"]:::frontend
        RootApp["Root React App & Routing"]:::frontend
        AuthContext["AuthContext"]:::frontend
        DashboardComp["Dashboard Component"]:::frontend
        Modals["Modals"]:::frontend
        Charts["Charts & Visualization"]:::frontend
        AuthPages["Authentication Pages"]:::frontend
        StudentMgmt["Student Management"]:::frontend
        TeacherMgmt["Teacher Management"]:::frontend
        SessionMgmt["Session Components"]:::frontend
        FeedbackViewer["Feedback Viewer"]:::frontend
        StylingConfig["Styling Configuration"]:::frontend
    end

    %% API Tier
    subgraph "API Tier"
        direction TB
        ExpressAPI["Express API"]:::backend
        subgraph "Routes"
            direction TB
            AuthRoute["Authentication/Receptionist"]:::backend
            TeachersRoute["Teachers"]:::backend
            StudentsRoute["Students"]:::backend
            AssessmentsRoute["Assessments"]:::backend
            SessionsRoute["Sessions"]:::backend
            BranchesRoute["Branches"]:::backend
            ClustersRoute["Clusters"]:::backend
            FeedbacksRoute["Feedbacks"]:::backend
            ECAsRoute["ECAs"]:::backend
            DriveRoute["Google Drive"]:::backend
        end
        subgraph "Middleware & Services"
            direction TB
            UploadMW["File Upload Middleware"]:::backend
            JWTMW["JWT Validation Middleware"]:::backend
            ErrorMW["Error Handler Middleware"]:::backend
            Services["Business Logic Services"]:::backend
            GoogleConfig["Google Drive Config"]:::backend
        end
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        MongoDB["MongoDB Atlas"]:::database
        subgraph "Mongoose Models"
            direction TB
            TeacherModel["Teacher Model"]:::database
            StudentModel["Student Model"]:::database
            AssessmentModel["Assessment Model"]:::database
            FeedbackModel["Feedback Model"]:::database
            ECAModel["ECA Model"]:::database
            BranchModel["Branch Model"]:::database
            ClusterModel["Cluster Model"]:::database
            SessionModel["Session Model"]:::database
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        EmailService["SMTP Email Service"]:::external
        GDriveAPI["Google Drive API"]:::external
    end

    %% Connections
    ReactSPA -->|"HTTP(S) Requests"| ExpressAPI
    ExpressAPI -->|"Mongoose Queries"| MongoDB
    ExpressAPI -.->|Asynchronous Email| EmailService
    ExpressAPI -.->|File Storage| GDriveAPI

    ReactSPA --> PublicAssets
    ReactSPA --> RootApp
    ReactSPA --> AuthContext
    ReactSPA --> DashboardComp
    ReactSPA --> Modals
    ReactSPA --> Charts
    ReactSPA --> AuthPages
    ReactSPA --> StudentMgmt
    ReactSPA --> TeacherMgmt
    ReactSPA --> SessionMgmt
    ReactSPA --> FeedbackViewer
    ReactSPA --> StylingConfig

    ExpressAPI --> AuthRoute
    ExpressAPI --> TeachersRoute
    ExpressAPI --> StudentsRoute
    ExpressAPI --> AssessmentsRoute
    ExpressAPI --> SessionsRoute
    ExpressAPI --> BranchesRoute
    ExpressAPI --> ClustersRoute
    ExpressAPI --> FeedbacksRoute
    ExpressAPI --> ECAsRoute
    ExpressAPI --> DriveRoute

    ExpressAPI --> UploadMW
    ExpressAPI --> JWTMW
    ExpressAPI --> ErrorMW
    ExpressAPI --> Services
    ExpressAPI --> GoogleConfig

    MongoDB --> TeacherModel
    MongoDB --> StudentModel
    MongoDB --> AssessmentModel
    MongoDB --> FeedbackModel
    MongoDB --> ECAModel
    MongoDB --> BranchModel
    MongoDB --> ClusterModel
    MongoDB --> SessionModel

    %% Click Events
    click ReactSPA "https://github.com/bhargava1424/sat/tree/main/frontend/"
    click PublicAssets "https://github.com/bhargava1424/sat/blob/main/frontend/public/index.html"
    click PublicAssets "https://github.com/bhargava1424/sat/blob/main/frontend/public/manifest.json"
    click RootApp "https://github.com/bhargava1424/sat/blob/main/frontend/src/App.js"
    click RootApp "https://github.com/bhargava1424/sat/blob/main/frontend/src/index.js"
    click AuthContext "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/AuthContext.js"
    click DashboardComp "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/Dashboard.js"
    click Modals "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/AddAttendance.js"
    click Modals "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/AssessmentModal.js"
    click Modals "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/UploadModal.js"
    click Modals "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/Modal.js"
    click Charts "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/OverallSpider.js"
    click Charts "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/WeightSignificance.js"
    click AuthPages "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/LoginPage.js"
    click AuthPages "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/ForgotPasswordPage.js"
    click StudentMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/StudentAssessment.js"
    click StudentMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/StudentECA.js"
    click StudentMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/UpdateStudent.js"
    click StudentMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/StudentListModal.js"
    click StudentMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/StudentReport.js"
    click TeacherMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/AddTeachers.js"
    click TeacherMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/EditTeacherModal.js"
    click TeacherMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/TeachersList.js"
    click SessionMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/PendingSessions.js"
    click SessionMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/UpcomingSessions.js"
    click SessionMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/CompletedSessions.js"
    click SessionMgmt "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/SessionsAndAllotments.js"
    click FeedbackViewer "https://github.com/bhargava1424/sat/blob/main/frontend/src/components/ViewFeedbacks.js"
    click StylingConfig "https://github.com/bhargava1424/sat/blob/main/frontend/tailwind.config.js"
    click StylingConfig "https://github.com/bhargava1424/sat/blob/main/frontend/postcss.config.js"
    click ExpressAPI "https://github.com/bhargava1424/sat/blob/main/server/app.js"
    click AuthRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/receptionist.js"
    click TeachersRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/teachers.js"
    click StudentsRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/students.js"
    click AssessmentsRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/assessments.js"
    click SessionsRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/sessions.js"
    click BranchesRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/branches.js"
    click ClustersRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/clusters.js"
    click FeedbacksRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/feedbacks.js"
    click ECAsRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/ecas.js"
    click DriveRoute "https://github.com/bhargava1424/sat/blob/main/server/routes/drive.js"
    click UploadMW "https://github.com/bhargava1424/sat/blob/main/server/middleware/uploadMiddleware.js"
    click Services "https://github.com/bhargava1424/sat/blob/main/server/utils/services.js"
    click GoogleConfig "https://github.com/bhargava1424/sat/blob/main/server/config/googleConfig.js"
    click TeacherModel "https://github.com/bhargava1424/sat/blob/main/server/models/Teacher.js"
    click StudentModel "https://github.com/bhargava1424/sat/blob/main/server/models/Student.js"
    click AssessmentModel "https://github.com/bhargava1424/sat/blob/main/server/models/Assessment.js"
    click FeedbackModel "https://github.com/bhargava1424/sat/blob/main/server/models/Feedback.js"
    click ECAModel "https://github.com/bhargava1424/sat/blob/main/server/models/ECA.js"
    click BranchModel "https://github.com/bhargava1424/sat/blob/main/server/models/Branch.js"
    click ClusterModel "https://github.com/bhargava1424/sat/blob/main/server/models/Cluster.js"
    click SessionModel "https://github.com/bhargava1424/sat/blob/main/server/models/Session.js"

    %% Styles
    classDef frontend fill:#e0f7e9,stroke:#2e7d32,stroke-width:2px
    classDef backend fill:#e3f2fd,stroke:#1565c0,stroke-width:2px
    classDef database fill:#fff3e0,stroke:#ef6c00,stroke-width:2px
    classDef external fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px
```
