# mohamed-samehh/bue-spec-path architecture

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

- Interactive diagram: https://gitdiagram.com/mohamed-samehh/bue-spec-path
- Repository: https://github.com/mohamed-samehh/bue-spec-path

## Overview

##### Project Type & Purpose
- Full-stack web application for personalized career specialization recommendations, course exploration (via external API), and user reviews.
- Frontend: React + Vite; Backend: Node.js + Express; Database: MongoDB Atlas; External Service: Coursera API; Auth: JWT.

##### File Structure & Architectural Patterns
- Monorepo with two top-level folders:
- frontend/ (React components, CSS, router, entry point)
- backend/ (Express server, config, controllers, services, models, routes)
- MVC-style separation in backend:
- Models → define MongoDB schemas
- Controllers → handle HTTP requests, orchestrate services
- Services → business logic (auth, recommendation, career, knowledge hub, reviews)
- Configuration & environment:
- config/.env, db.js for Mongo connection
- dotenv, cors, body-parser, bcrypt, JWT
- Build & run scripts: Vite (frontend), nodemon (backend).

##### Main Components
A. Users & Client (Browser)
B. Frontend Application (React + Vite)
- AppRouter, individual page components (Auth, CareerPlanning, KnowledgeHub, Reviews, Profile)
- Static assets (images, CSS)
C. Backend API (Express)
- Entry: server.js
- Routes (auth, career, knowledgeHub, recommendation, review)
- Controllers & Services
- Config (env, db connection)
D. Database (MongoDB Atlas)
- Collections: Users, Careers/Specializations, RecommendationResults, Reviews
E. External Service
- Coursera API for fetching course data
F. Supporting libraries
- bcrypt, JWT secret, cors, body-parser

##### Interactions & Data Flows
1. User → Browser → React UI
2. React UI → HTTP (Axios/fetch) → Express API routes
- Auth endpoints (/signup, /login, /user, /check-token)
- Career endpoints (/get-specializations, /explore-career-options)
- Recommendation endpoint (/recommend-specialization)
- Knowledge hub (/get-courses → Coursera API)
- Reviews (/reviews CRUD)
3. Express Service Layer → MongoDB (via Mongoose)
4. For course search, Express calls Coursera’s external HTTP API and returns results to UI

##### Architectural Patterns & Design Principles
- Separation of concerns: UI vs API vs DB
- Layered backend: Routes → Controllers → Services → Models
- Stateless JWT authentication for protected routes
- External integration abstracted behind KnowledgeHub service
- Config driven (dotenv), allowing multiple environments

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User & Browser
    User["User / Browser"]:::user

    %% Frontend Application
    subgraph "Frontend Application (React + Vite)"
        direction TB
        Entry["main.jsx"]:::frontend
        Router["AppRouter.jsx"]:::frontend
        subgraph "Pages & Components"
            direction TB
            Auth["Auth.jsx"]:::frontend
            CareerPlanning["CareerPlanning.jsx"]:::frontend
            KnowledgeHubPage["KnowledgeHub.jsx"]:::frontend
            UserProfile["UserProfile.jsx"]:::frontend
            UserReviews["UserReviews.jsx"]:::frontend
            Navbar["Navbar.jsx"]:::frontend
            MCQ["mcq.jsx"]:::frontend
        end
        Entry --> Router
        Router --> Auth
        Router --> CareerPlanning
        Router --> KnowledgeHubPage
        Router --> UserProfile
        Router --> UserReviews
        Router --> Navbar
        Auth -->|"uses"| MCQ
    end

    %% Backend API
    subgraph "Backend API (Node.js + Express)"
        direction TB
        Server["server.js"]:::backend
        subgraph "Configuration & DB Connection"
            direction TB
            Env[".env.example"]:::backend
            DBConfig["db.js"]:::backend
        end
        subgraph "Routes Layer"
            direction TB
            AuthRoute["auth.js"]:::backend
            CareerRoute["careerRoutes.js"]:::backend
            KnowledgeHubRoute["knowledgeHubRoutes.js"]:::backend
            RecommendationRoute["recommendationRoutes.js"]:::backend
            ReviewRoute["reviewRoutes.js"]:::backend
        end
        subgraph "Controllers Layer"
            direction TB
            AuthController["auth.js"]:::backend
            CareerController["careerController.js"]:::backend
            KnowledgeHubController["knowledgeHubController.js"]:::backend
            RecommendationController["recommendationController.js"]:::backend
            ReviewController["reviewController.js"]:::backend
        end
        subgraph "Services Layer"
            direction TB
            AuthService["auth.js"]:::backend
            CareerService["careerService.js"]:::backend
            KnowledgeHubService["knowledgeHubService.js"]:::backend
            RecommendationService["recommendationService.js"]:::backend
            ReviewService["reviewService.js"]:::backend
        end
        subgraph "Models Layer"
            direction TB
            UserModel["User.js"]:::backend
            CareerModel["Career.js"]:::backend
            RecommendationModel["RecommendationResult.js"]:::backend
            ReviewModel["Review.js"]:::backend
        end

        Server --> Env
        Server --> DBConfig
        Server --> AuthRoute
        Server --> CareerRoute
        Server --> KnowledgeHubRoute
        Server --> RecommendationRoute
        Server --> ReviewRoute

        AuthRoute --> AuthController
        CareerRoute --> CareerController
        KnowledgeHubRoute --> KnowledgeHubController
        RecommendationRoute --> RecommendationController
        ReviewRoute --> ReviewController

        AuthController --> AuthService
        CareerController --> CareerService
        KnowledgeHubController --> KnowledgeHubService
        RecommendationController --> RecommendationService
        ReviewController --> ReviewService

        AuthService --> UserModel
        CareerService --> CareerModel
        KnowledgeHubService -->|"calls Coursera API"| External
        RecommendationService --> RecommendationModel
        ReviewService --> ReviewModel
    end

    %% Database
    MongoDB["MongoDB Atlas"]:::database
    UserModel --> MongoDB
    CareerModel --> MongoDB
    RecommendationModel --> MongoDB
    ReviewModel --> MongoDB

    %% External Service
    External["Coursera API"]:::external

    %% Overall Flows
    User -->|"loads assets"| Entry
    User -->|"interacts"| Router
    Router -->|"HTTP (REST, JWT)"| Server
    Server -->|"TCP (Mongoose)"| MongoDB
    Server -->|"HTTP (REST)"| External

    %% Click Events
    click Entry "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/main.jsx"
    click Router "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/AppRouter.jsx"
    click Auth "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/Auth.jsx"
    click CareerPlanning "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/CareerPlanning.jsx"
    click KnowledgeHubPage "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/KnowledgeHub.jsx"
    click UserProfile "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/UserProfile.jsx"
    click UserReviews "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/UserReviews.jsx"
    click Navbar "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/Navbar.jsx"
    click MCQ "https://github.com/mohamed-samehh/bue-spec-path/blob/master/frontend/mcq.jsx"
    click Server "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/server.js"
    click Env "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/config/.env.example"
    click DBConfig "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/config/db.js"
    click AuthRoute "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/routes/auth.js"
    click CareerRoute "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/routes/careerRoutes.js"
    click KnowledgeHubRoute "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/routes/knowledgeHubRoutes.js"
    click RecommendationRoute "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/routes/recommendationRoutes.js"
    click ReviewRoute "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/routes/reviewRoutes.js"
    click AuthController "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/controllers/auth.js"
    click CareerController "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/controllers/careerController.js"
    click KnowledgeHubController "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/controllers/knowledgeHubController.js"
    click RecommendationController "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/controllers/recommendationController.js"
    click ReviewController "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/controllers/reviewController.js"
    click AuthService "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/services/auth.js"
    click CareerService "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/services/careerService.js"
    click KnowledgeHubService "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/services/knowledgeHubService.js"
    click RecommendationService "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/services/recommendationService.js"
    click ReviewService "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/services/reviewService.js"
    click UserModel "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/models/User.js"
    click CareerModel "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/models/Career.js"
    click RecommendationModel "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/models/RecommendationResult.js"
    click ReviewModel "https://github.com/mohamed-samehh/bue-spec-path/blob/master/backend/models/Review.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef backend fill:#DFF5D0,stroke:#228B22,stroke-width:1px;
    classDef database fill:#FFE5B4,stroke:#FF8C00,stroke-width:1px;
    classDef external fill:#F3D0FF,stroke:#800080,stroke-width:1px;
    classDef user fill:#CCE5FF,stroke:#1E90FF,stroke-width:1px;
```
