# jaysanghani08/common_ground architecture

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

- Interactive diagram: https://gitdiagram.com/jaysanghani08/common_ground
- Repository: https://github.com/jaysanghani08/common_ground

## Overview

##### Project type and purpose
- This is a full-stack web application (“Common Ground”) consisting of:
- A Node.js/Express REST API Backend under BackEnd/
- A React Single Page Application frontend under public/ + src/
- A MongoDB (or similar NoSQL) persistence layer accessed via Mongoose‐style models
- Local file storage for uploads and an external email service for notifications
- Purpose: enable educators and students to sign up, create/enroll in courses, upload assignments, participate in discussion forums, and manage certificates aligned to Common Core Standards.

##### File structure
- Backend (BackEnd/)
- server.js + app.js bootstraps Express, middleware, routes
- api/routes/*.js define REST endpoints (/educator, /student, /files, /query)
- api/controllers/*.js implement business logic (CRUD, file streaming, discussions)
- api/middleware handles authentication (JWT), authorization (enrollment), file uploads (Multer)
- api/models/*.js map domain entities (Course, Assignment, Submission, Student, Educator, Token)
- utils/sendEmail.js integrates with SMTP/third-party service; utils/deleteFile.js cleans up uploads
- uploads/ holds file assets: certificates, course materials, profile pictures
- test/ contains Jest or Mocha tests for controllers
- Frontend (src/ + public/)
- public/ serves static assets (HTML, CSS, fonts, images)
- src/ holds the React app:
– pages/ organizes top-level views (HomePage, Educator, Student, CourseDetail, Error, Loading, Logout)
– components under each page (buttons, sidebars, cards, accordions, discussion forum, PDF viewer)
– services/ wrap HTTP calls (ApiCall.js, Apis.js, routes definitions, token helpers)
– data/ provides static JSON for UI cards, countries, logos
– App.js + index.js configure React Router and global context/state
- Configuration: package.json / package-lock.json, config.env for environment variables, .gitignore

##### README insights
- Backend folder outline confirms RESTful MVC pattern.

a. Main components
- Browser / React SPA (static assets + client-side routing)
- REST API Server (Node.js/Express)
- Database (MongoDB cluster)
- File Store (local disk under uploads/ or cloud storage)
- External Email Service (SMTP / SendGrid API)
- Authentication (JWT tokens)
b. Relationships & interactions
- User → React UI
- React UI ↔ REST API over HTTPS
- REST API ↔ Database for CRUD on models
- REST API ↔ File Store via Multer middleware
- REST API ↔ Email service via utils/sendEmail.js
- Middleware enforces JWT auth & role-based access (educator vs student)
c. Architectural patterns & principles
- MVC pattern in backend (Models, Controllers, Routes)
- Component-based React architecture
- Layered security: authentication, authorization, input validation
- RESTful resource design
- Separation of concerns: file handling via dedicated middleware, email via utility module
d. Key technologies
- Node.js, Express, Mongoose (MongoDB)
- React, React Router, Axios or fetch wrappers
- Multer for multipart/form-data uploads
- JWT for stateless authentication
- CSS frameworks (Bootstrap, custom SCSS)
- Testing frameworks: Jest/Mocha for backend, Java+Selenium for GUI tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        Browser["User's Browser"]:::frontend
        ReactRouter["React Router"]:::frontend
        UIComponents["UI Components (Pages & Components)"]:::frontend
        APIService["API Service Layer"]:::frontend
        StaticData["Static Data"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        ExpressApp["Express App (server.js & app.js)"]:::backend
        Middleware["Middleware (Auth, Enrollment, File Upload)"]:::backend
        Routes["REST API Routes"]:::backend
        Controllers["Controllers (Business Logic)"]:::backend
        Models["Mongoose Models"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Database["MongoDB Database"]:::external
        FileStore["File Storage (uploads/)"]:::external
        EmailService["Email Service (SMTP/SendGrid)"]:::external
    end

    %% Flows
    Browser -->|"navigates"| ReactRouter
    ReactRouter -->|"renders"| UIComponents
    UIComponents -->|"uses data"| StaticData
    UIComponents -->|"calls"| APIService
    APIService -->|"HTTPS requests"| ExpressApp
    ExpressApp -->|"routes to"| Routes
    Routes -->|"executes"| Middleware
    Middleware -->|"passes to"| Controllers
    Controllers -->|"CRUD ops"| Models
    Models -->|"reads/writes"| Database
    Controllers -->|"sends files"| FileStore
    Controllers -->|"sends emails"| EmailService

    %% File Upload Flow
    UIComponents -->|"file upload"| APIService
    APIService -->|"POST /files"| ExpressApp
    ExpressApp -->|"multer handles"| Middleware

    %% Authentication Flow
    UIComponents -->|"login/signup"| APIService
    APIService -->|"POST /auth"| ExpressApp
    ExpressApp -->|"checkAuth & checkEnroll"| Middleware

    %% Click Events
    click Browser "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/public/"
    click ReactRouter "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/src/index.js"
    click ReactRouter "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/src/App.js"
    click UIComponents "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/src/pages/"
    click APIService "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/src/services/"
    click StaticData "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/src/data/"
    click ExpressApp "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/BackEnd/server.js"
    click ExpressApp "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/BackEnd/app.js"
    click ExpressApp "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/BackEnd/config.env"
    click Routes "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/BackEnd/api/routes/"
    click Controllers "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/BackEnd/api/controllers/"
    click Models "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/BackEnd/api/models/"
    click Middleware "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/BackEnd/api/middleware/"
    click FileStore "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/BackEnd/uploads/"
    click EmailService "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/BackEnd/utils/sendEmail.js"
    click EmailService "https://github.com/jaysanghani08/common_ground/blob/Common-Ground/BackEnd/utils/deleteFile.js"
    click ExpressApp "https://github.com/jaysanghani08/common_ground/tree/Common-Ground/BackEnd/test/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef backend fill:#D0FFD0,stroke:#028A02,color:#028A02;
    classDef external fill:#FFD0A0,stroke:#d66d00,color:#d66d00;
```
