# abhaytr/muj-camp architecture

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

- Interactive diagram: https://gitdiagram.com/abhaytr/muj-camp
- Repository: https://github.com/abhaytr/muj-camp

## Overview

##### Project type and purpose
- MUJ CAMP is a full‑stack alumni management portal with two main subsystems:
- A LinkedIn data‐syncing engine (“ATLIS”) that scrapes and stores alumni profile data into MongoDB.
- A React‑based web portal plus a Node.js/TypeScript WebSocket/REST backend that provides authentication, real‑time updates, and AI‑driven dashboards.

##### File structure
- Top‑level directories:
- ATLIS/ATLIS_Desktop – Python desktop UI and orchestration scripts (app.py, linkedin_instance.py, data.js)
- ATLIS/ATLIS_Engine – Core scraping engine, queue management, DB adapter (atlis_db.py), logging, LinkedIn API wrapper
- muj_camp – React front‑end (src/, public/, package.json) using Redux‑style app_state
- muj_camp_server – Node.js/TypeScript backend, with WebSocket server (CampWSServer.ts), auth modules, data managers, AI managers, utils, TypeScript config

##### README for insights
- Purpose: sync 15,000+ alumni LinkedIn data in days via WebSockets‐backed scraping engine.
- Features: AI dashboard for ad‑hoc MongoDB queries powered by Llama.

a. Main components
- Desktop Scraper UI (ATLIS_Desktop)
- Scraper Engine (ATLIS_Engine)
- Data Store (MongoDB)
- Backend API & WebSocket Server (muj_camp_server)
- Front‑end Web Client (muj_camp)
- External Services: LinkedIn, Llama/AI model endpoints
b. Relationships & interactions
1. Operator triggers scraping in Desktop UI → invokes Engine modules → fetch data from LinkedIn (via linkedin_instance)
2. Engine writes/updates records in MongoDB (atlis_db adapter)
3. Backend server (CampWSServer + REST endpoints) listens for WebSocket events & incoming web requests
4. Server reads from MongoDB, processes data (aiManager, dataManager), and pushes real‑time updates via WS to clients
5. Front‑end connects via WS + HTTP, dispatches Redux actions, renders dashboard and AI‑query results
6. For AI insights, backend queries MongoDB and/or invokes Llama, returns results to front‑end
c. Architectural patterns & design principles
- Separation of concerns: scraping engine separated from web server
- Event‑driven & queue‐based scraping (atlisq_manager)
- Client‑server with real‑time channel (WebSockets) plus REST
- Modular code organization (auth, data, AI managers in server; Redux slices in front‑end)
- Reusable core engine library (ATLIS_Engine) vs. thin orchestration layer (ATLIS_Desktop)
d. Key technologies & frameworks
- Python 3, requests/selenium (assumed) for ATLIS_Engine
- MongoDB for alumni data store
- Node.js + TypeScript + ws or socket.io for WebSocket server
- Express‑style REST API (in muj_camp_server/src/utils)
- React.js + Redux (app_state) + WebSocket client in front‑end
- Llama (or OpenAI) for AI‑driven dashboard

##### Final recommendations
- Every module boundary (Desktop UI vs. Engine vs. Server vs. Client).
- Data flows (scrape→store, store→AI query, AI→UI).
- Auth flow separately (login → JWT manager → protected WS/REST).
- Incorporate at least one example of a sequence (e.g., admin triggers scrape → desktop updates UI via WebSockets).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Desktop UI
    subgraph "Desktop Scraper UI"
        direction TB
        DS_App["app.py"]:::backend
        DS_LinkInst["linkedin_instance.py"]:::backend
        DS_DataJS["data.js"]:::backend
        DS_Logger["atlis_logger.py"]:::backend
        DS_ID["id.js"]:::backend
    end

    %% Scraper Engine
    subgraph "Scraper Engine Library"
        direction TB
        SE_Engine["engine.py"]:::backend
        SE_Queue["atlisq_manager.py"]:::backend
        SE_DB["atlis_db.py"]:::backend
        SE_LinkInst["linkedin_instance.py"]:::backend
        SE_Logger["atlis_logger.py"]:::backend
    end

    %% Database
    MongoDB["MongoDB"]:::database

    %% Backend Server
    subgraph "WS/REST Server"
        direction TB
        SV_Index["index.ts"]:::backend
        SV_WSS["CampWSServer.ts"]:::backend
        subgraph "Auth Modules"
            direction TB
            Auth_Auth["auth.ts"]:::backend
            Auth_JWT["jwtmanager.ts"]:::backend
            Auth_OTP["otp.ts"]:::backend
            Auth_User["user.ts"]:::backend
        end
        subgraph "Utils"
            direction TB
            Util_REQ["CAMPRequest.ts"]:::backend
            Util_Common["common.ts"]:::backend
            Util_Init["init.ts"]:::backend
            Util_Mail["mail.ts"]:::backend
        end
        subgraph "Data & AI Managers"
            direction TB
            DM_Data["dataManager.ts"]:::backend
            DM_AI["aiManager.ts"]:::backend
            DM_Dash["dashboardManager.ts"]:::backend
            DM_Atlis["atlisManager.ts"]:::backend
            DM_Alma["almashineManager.ts"]:::backend
            DM_Status["alumniLIStatus.ts"]:::backend
            DM_Sub["subscriberManager.ts"]:::backend
            DM_Doar["doarData.ts"]:::backend
            DM_AIComments["aiManager.comments.ts"]:::backend
        end
    end

    %% Front-end
    subgraph "React Front-end"
        direction TB
        FE_Package["package.json"]:::frontend
        FE_Index["index.js"]:::frontend
        FE_AppState["app_state"]:::frontend
        FE_Pages["pages"]:::frontend
        FE_Components["custom_components"]:::frontend
        FE_Hooks["hooks"]:::frontend
        FE_Tools["tools"]:::frontend
    end

    %% External Services
    LinkedIn["LinkedIn Service"]:::external
    Llama["Llama AI Service"]:::external

    %% Data Flows
    DS_App -->|"invoke scrapers"| SE_Engine
    SE_Engine -->|"fetch data"| LinkedIn
    SE_Engine -->|"write records"| MongoDB
    SV_Index -->|"connect WS"| SV_WSS
    SV_Index -->|"HTTP API"| FE_Index
    SV_WSS -->|"WS push updates"| FE_Index
    FE_Index -->|"login"| SV_Index
    SV_Index -->|"validate JWT"| Auth_JWT
    SV_Index -->|"query DB"| MongoDB
    DM_AI -->|"AI query"| Llama
    Llama -->|"AI response"| DM_AI
    MongoDB -->|"read/write"| SV_Index
    DM_Data -->|"process data"| SV_WSS
    DM_Dash -->|"dashboard data"| SV_WSS

    %% Click Events Desktop UI
    click DS_App "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Desktop/app.py"
    click DS_LinkInst "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Desktop/linkedin_instance.py"
    click DS_DataJS "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Desktop/data.js"
    click DS_Logger "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Desktop/atlis_logger.py"
    click DS_ID "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Desktop/id.js"

    %% Click Events Scraper Engine
    click SE_Engine "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Engine/engine.py"
    click SE_Queue "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Engine/atlisq_manager.py"
    click SE_DB "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Engine/atlis_db.py"
    click SE_LinkInst "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Engine/linkedin_instance.py"
    click SE_Logger "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Engine/atlis_logger.py"

    %% Click Events Database Adapter
    click SE_DB "https://github.com/abhaytr/muj-camp/blob/master/ATLIS/ATLIS_Engine/atlis_db.py"
    click SV_Index "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/utils/campdb.ts"

    %% Click Events Backend Server
    click SV_WSS "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/CampWSServer.ts"
    click SV_Index "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/index.ts"
    click Auth_Auth "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/auth/auth.ts"
    click Auth_JWT "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/auth/jwtmanager.ts"
    click Auth_OTP "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/auth/otp.ts"
    click Auth_User "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/auth/user.ts"
    click Util_REQ "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/utils/CAMPRequest.ts"
    click Util_Common "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/utils/common.ts"
    click Util_Init "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/utils/init.ts"
    click Util_Mail "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/utils/mail.ts"

    %% Click Events Data & AI Managers
    click DM_Data "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/dataManager.ts"
    click DM_AI "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/aiManager.ts"
    click DM_Dash "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/dashboardManager.ts"
    click DM_Atlis "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/atlisManager.ts"
    click DM_Alma "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/almashineManager.ts"
    click DM_Status "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/alumniLIStatus.ts"
    click DM_Sub "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/subscriberManager.ts"
    click DM_Doar "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/doar/doarData.ts"
    click DM_AIComments "https://github.com/abhaytr/muj-camp/blob/master/muj_camp_server/src/comments/aiManager.comments.ts"

    %% Click Events Front-end
    click FE_Package "https://github.com/abhaytr/muj-camp/blob/master/muj_camp/package.json"
    click FE_Index "https://github.com/abhaytr/muj-camp/blob/master/muj_camp/src/index.js"
    click FE_AppState "https://github.com/abhaytr/muj-camp/tree/master/muj_camp/src/app_state"
    click FE_Pages "https://github.com/abhaytr/muj-camp/tree/master/muj_camp/src/pages"
    click FE_Components "https://github.com/abhaytr/muj-camp/tree/master/muj_camp/src/custom_components"
    click FE_Hooks "https://github.com/abhaytr/muj-camp/tree/master/muj_camp/src/hooks"
    click FE_Tools "https://github.com/abhaytr/muj-camp/tree/master/muj_camp/src/tools"

    %% Styles
    classDef backend fill:#dae8fc,stroke:#6c8ebf,color:#1a1a1a;
    classDef frontend fill:#d5e8d4,stroke:#82b366,color:#1a1a1a;
    classDef external fill:#ffe6cc,stroke:#d79b00,color:#1a1a1a;
    classDef database fill:#fff2cc,stroke:#d6b656,color:#1a1a1a;
```
