# varunkonka2673/final-year-project architecture

> Architecture diagram of the GitHub repository varunkonka2673/final-year-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/varunkonka2673/final-year-project
- Repository: https://github.com/varunkonka2673/final-year-project

## Overview

SocialGuard is a web dashboard and FastAPI service for detecting fraudulent accounts and coordinated bot networks. Users authenticate, submit a profile for scoring or upload a CSV, then explore risk results, model evaluations, clusters, live simulated detections, dataset tools, and scan history. The backend orchestrates feature extraction, classification, and anomaly analysis; the dashboard also supports admin access, feedback, and research-report export. The graph follows documented features and shown references; unsampled implementation details are omitted where relationships cannot be verified.

Main entry points: [`backend/api/app.py`](https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/app.py) (FastAPI service), [`frontend/src/App.jsx`](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/App.jsx) (Dashboard shell), [`backend/ml/pipeline.py`](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/pipeline.py) (ML orchestrator), [`frontend/src/services/historyService.js`](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/services/historyService.js) (History service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Dashboard shell<br/>[App.jsx]"]
  node_auth_portal["Sign-in portal<br/>[AuthPortal.jsx]"]
  node_single_scan["Profile scanner<br/>[SingleScanner.jsx]"]
  node_batch_scan["Batch audit<br/>[BatchScanner.jsx]"]
  node_model_arena["Model arena<br/>[ModelArena.jsx]"]
  node_cluster_view["Bot clusters"]
  node_stream_view["Sentinel stream"]
  node_dataset_view["Dataset explorer"]
  node_history_view["Scan history<br/>[HistoryViewer.jsx]"]
  node_paper_view["Research report"]
end

subgraph group_api["API and persistence"]
  node_api["FastAPI service<br/>[app.py]"]
  node_api_schemas["Request schemas<br/>[schemas.py]"]
  node_relational_db[("API database<br/>[db.py]")]
end

subgraph group_ml["Detection engine"]
  node_pipeline["ML orchestrator<br/>[pipeline.py]"]
  node_features["Profile features<br/>[preprocessor.py]"]
  node_profile_extract["Profile extraction"]
  node_linkedin_extract["LinkedIn extraction"]
  node_nlp["Text features<br/>[nlp_engine.py]"]
  node_models["Model suite<br/>[models.py]"]
  node_imbalance["SMOTE balancing"]
  node_anomaly["Anomaly and rings<br/>[anomaly_engine.py]"]
  node_dataset_gen["Dataset generator"]
  node_collector["Data collector<br/>[data_collector.py]"]
end

subgraph group_identity["Identity and history"]
  node_auth_context["Auth state<br/>[AuthContext.jsx]"]
  node_firebase["Firebase client<br/>[firebase.js]"]
  node_history_service["History service<br/>[historyService.js]"]
  node_firestore[("Firestore")]
end

node_user(("Dashboard user"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"shows"| node_auth_portal
node_dashboard -->|"routes to"| node_single_scan
node_dashboard -->|"routes to"| node_batch_scan
node_dashboard -->|"routes to"| node_model_arena
node_dashboard -->|"routes to"| node_cluster_view
node_dashboard -->|"routes to"| node_stream_view
node_dashboard -->|"routes to"| node_dataset_view
node_dashboard -->|"routes to"| node_history_view
node_dashboard -->|"routes to"| node_paper_view
node_dashboard -->|"provides auth"| node_auth_context
node_auth_portal -->|"calls auth"| node_auth_context
node_auth_context -->|"uses auth"| node_firebase
node_auth_context -->|"checks admins"| node_api
node_single_scan -->|"requests scoring"| node_api
node_single_scan -->|"saves scans"| node_history_service
node_batch_scan -->|"submits CSV"| node_api
node_model_arena -->|"loads metrics"| node_api
node_cluster_view -->|"loads clusters"| node_api
node_stream_view -->|"requests ticks"| node_api
node_dataset_view -->|"uses dataset tools"| node_api
node_paper_view -->|"exports report"| node_api
node_history_view -->|"loads history"| node_history_service
node_history_service -->|"uses Firestore SDK"| node_firebase
node_history_service -->|"reads and writes"| node_firestore
node_history_service -->|"submits feedback"| node_api
node_api -->|"scores accounts"| node_pipeline
node_api -->|"validates requests"| node_api_schemas
node_api -->|"uses persistence"| node_relational_db
node_api -->|"generates retraining data"| node_dataset_gen
node_api -->|"uses extraction"| node_profile_extract
node_api -->|"aligns features"| node_features
node_api -->|"uses collection"| node_collector
node_pipeline -->|"preprocesses"| node_features
node_pipeline -->|"extracts text features"| node_nlp
node_pipeline -->|"runs classifiers"| node_models
node_pipeline -->|"balances training"| node_imbalance
node_pipeline -->|"scores anomalies"| node_anomaly
node_pipeline -->|"generates data"| node_dataset_gen
node_profile_extract -->|"delegates to"| node_linkedin_extract
node_collector -->|"uses pipeline"| node_pipeline

click node_dashboard "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/App.jsx"
click node_auth_portal "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/AuthPortal.jsx"
click node_single_scan "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/SingleScanner.jsx"
click node_batch_scan "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/BatchScanner.jsx"
click node_model_arena "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/ModelArena.jsx"
click node_cluster_view "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/BotClusterVisualizer.jsx"
click node_stream_view "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/LiveSentinelStream.jsx"
click node_dataset_view "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/DatasetExplorer.jsx"
click node_history_view "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/HistoryViewer.jsx"
click node_paper_view "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/IEEEPaperViewer.jsx"
click node_api "https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/app.py"
click node_api_schemas "https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/schemas.py"
click node_relational_db "https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/db.py"
click node_pipeline "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/pipeline.py"
click node_features "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/preprocessor.py"
click node_profile_extract "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/profile_extractor.py"
click node_linkedin_extract "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/linkedin_extractor.py"
click node_nlp "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/nlp_engine.py"
click node_models "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/models.py"
click node_imbalance "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/imbalance_handler.py"
click node_anomaly "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/anomaly_engine.py"
click node_dataset_gen "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/dataset_generator.py"
click node_collector "https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/data_collector.py"
click node_auth_context "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/context/AuthContext.jsx"
click node_firebase "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/firebase.js"
click node_history_service "https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/services/historyService.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_auth_portal,node_single_scan,node_batch_scan,node_model_arena,node_cluster_view,node_stream_view,node_dataset_view,node_history_view,node_paper_view,node_user toneBlue
class node_api,node_api_schemas,node_relational_db toneAmber
class node_pipeline,node_features,node_profile_extract,node_linkedin_extract,node_nlp,node_models,node_imbalance,node_anomaly,node_dataset_gen,node_collector toneMint
class node_auth_context,node_firebase,node_history_service,node_firestore toneRose
```

## Components

### Dashboard

- [Dashboard shell](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in portal](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/AuthPortal.jsx): `frontend/src/components/AuthPortal.jsx`
- [Profile scanner](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/SingleScanner.jsx): `frontend/src/components/SingleScanner.jsx`
- [Batch audit](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/BatchScanner.jsx): `frontend/src/components/BatchScanner.jsx`
- [Model arena](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/ModelArena.jsx): `frontend/src/components/ModelArena.jsx`
- [Bot clusters](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/BotClusterVisualizer.jsx): `frontend/src/components/BotClusterVisualizer.jsx`
- [Sentinel stream](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/LiveSentinelStream.jsx): `frontend/src/components/LiveSentinelStream.jsx`
- [Dataset explorer](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/DatasetExplorer.jsx): `frontend/src/components/DatasetExplorer.jsx`
- [Scan history](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/HistoryViewer.jsx): `frontend/src/components/HistoryViewer.jsx`
- [Research report](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/components/IEEEPaperViewer.jsx): `frontend/src/components/IEEEPaperViewer.jsx`

### API and persistence

- [FastAPI service](https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/app.py): `backend/api/app.py`
- [Request schemas](https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/schemas.py): `backend/api/schemas.py`
- [API database](https://github.com/varunkonka2673/final-year-project/blob/main/backend/api/db.py): `backend/api/db.py`

### Detection engine

- [ML orchestrator](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/pipeline.py): `backend/ml/pipeline.py`
- [Profile features](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/preprocessor.py): `backend/ml/preprocessor.py`
- [Profile extraction](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/profile_extractor.py): `backend/ml/profile_extractor.py`
- [LinkedIn extraction](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/linkedin_extractor.py): `backend/ml/linkedin_extractor.py`
- [Text features](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/nlp_engine.py): `backend/ml/nlp_engine.py`
- [Model suite](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/models.py): `backend/ml/models.py`
- [SMOTE balancing](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/imbalance_handler.py): `backend/ml/imbalance_handler.py`
- [Anomaly and rings](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/anomaly_engine.py): `backend/ml/anomaly_engine.py`
- [Dataset generator](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/dataset_generator.py): `backend/ml/dataset_generator.py`
- [Data collector](https://github.com/varunkonka2673/final-year-project/blob/main/backend/ml/data_collector.py): `backend/ml/data_collector.py`

### Identity and history

- [Auth state](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Firebase client](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/firebase.js): `frontend/src/firebase.js`
- [History service](https://github.com/varunkonka2673/final-year-project/blob/main/frontend/src/services/historyService.js): `frontend/src/services/historyService.js`
- **Firestore**

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Dashboard shell: uses (evidence: `README.md`)
- Dashboard shell → Sign-in portal: shows (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Profile scanner: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Batch audit: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Model arena: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Bot clusters: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Sentinel stream: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Dataset explorer: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Scan history: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Research report: routes to (evidence: `README.md`)
- Dashboard shell → Auth state: provides auth (evidence: `frontend/src/App.jsx`)
- Sign-in portal → Auth state: calls auth (evidence: `frontend/src/components/AuthPortal.jsx`)
- Auth state → Firebase client: uses auth (evidence: `frontend/src/context/AuthContext.jsx`)
- Auth state → FastAPI service: checks admins (evidence: `frontend/src/context/AuthContext.jsx`)
- Profile scanner → FastAPI service: requests scoring (evidence: `README.md`)
- Profile scanner → History service: saves scans (evidence: `frontend/src/components/SingleScanner.jsx`)
- Batch audit → FastAPI service: submits CSV (evidence: `README.md`)
- Model arena → FastAPI service: loads metrics (evidence: `README.md`)
- Bot clusters → FastAPI service: loads clusters (evidence: `README.md`)
- Sentinel stream → FastAPI service: requests ticks (evidence: `README.md`)
- Dataset explorer → FastAPI service: uses dataset tools (evidence: `README.md`)
- Research report → FastAPI service: exports report (evidence: `README.md`)
- Scan history → History service: loads history (evidence: `frontend/src/components/HistoryViewer.jsx`)
- History service → Firebase client: uses Firestore SDK (evidence: `frontend/src/services/historyService.js`)
- History service → Firestore: reads and writes (evidence: `frontend/src/services/historyService.js`)
- History service → FastAPI service: submits feedback (evidence: `frontend/src/services/historyService.js`)
- FastAPI service → ML orchestrator: scores accounts (evidence: `backend/api/app.py`)
- FastAPI service → Request schemas: validates requests (evidence: `backend/api/app.py`)
- FastAPI service → API database: uses persistence (evidence: `backend/api/app.py`)
- FastAPI service → Dataset generator: generates retraining data (evidence: `backend/api/app.py`)
- FastAPI service → Profile extraction: uses extraction (evidence: `backend/api/app.py`)
- FastAPI service → Profile features: aligns features (evidence: `backend/api/app.py`)
- FastAPI service → Data collector: uses collection (evidence: `backend/api/app.py`)
- ML orchestrator → Profile features: preprocesses (evidence: `backend/ml/pipeline.py`)
- ML orchestrator → Text features: extracts text features (evidence: `backend/ml/pipeline.py`)
- ML orchestrator → Model suite: runs classifiers (evidence: `backend/ml/pipeline.py`)
- ML orchestrator → SMOTE balancing: balances training (evidence: `backend/ml/pipeline.py`)
- ML orchestrator → Anomaly and rings: scores anomalies (evidence: `backend/ml/pipeline.py`)
- ML orchestrator → Dataset generator: generates data (evidence: `backend/ml/pipeline.py`)
- Profile extraction → LinkedIn extraction: delegates to (evidence: `backend/ml/profile_extractor.py`)
- Data collector → ML orchestrator: uses pipeline (evidence: `backend/ml/data_collector.py`)
