# arunbhadouria/naughty_company architecture

> Architecture diagram of the GitHub repository arunbhadouria/naughty_company, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arunbhadouria/naughty_company
- Repository: https://github.com/arunbhadouria/naughty_company

## Overview

Naughty Company is a web-based OSINT scam-risk investigator. A visitor submits a company or domain in the dashboard; the backend extracts the entity, searches for evidence, enriches results with fetched content, filters defensive sentiment, and returns a weighted risk verdict. Registered users can authenticate, retain scan history, and provide feedback. The graph also preserves the documented OAuth and guest-scan capabilities. Some subsystem links rely on README or SOURCE INDEX references; unsampled integrations are omitted where their wiring is unclear.

Main entry points: [`src/services/analyzer.service.js`](https://github.com/arunbhadouria/naughty_company/blob/main/src/services/analyzer.service.js) (Analysis coordinator), [`src/routes/analyze.routes.js`](https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/analyze.routes.js) (Analysis routes), [`frontend/src/services/api.js`](https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/services/api.js) (Frontend API client), [`src/models/User.js`](https://github.com/arunbhadouria/naughty_company/blob/main/src/models/User.js) (User and scan archive)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_dashboard["Scan dashboard<br/>[Dashboard.jsx]"]
  node_frontend_api["Frontend API client<br/>[api.js]"]
  node_auth_pages["Auth screens<br/>[AuthPages.jsx]"]
  node_history_page["Scan history view<br/>[History.jsx]"]
  node_risk_card["Risk result card<br/>[RiskCard.jsx]"]
end

subgraph group_identity["Identity and archives"]
  node_api_app["API application<br/>[app.js]"]
  node_analyze_routes["Analysis routes<br/>[analyze.routes.js]"]
  node_auth_routes["Auth routes<br/>[auth.routes.js]"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_jwt_guard["JWT protection<br/>[auth.middleware.js]"]
  node_usage_gate["Scan usage gate"]
  node_user_store[("User and scan archive<br/>[User.js]")]
end

subgraph group_intelligence["Investigation engine"]
  node_analyzer["Analysis coordinator"]
  node_entity_extract["Entity extraction<br/>[entityExtractor.js]"]
  node_search["Web search<br/>[search.service.js]"]
  node_content["Content enrichment<br/>[content.service.js]"]
  node_sentiment["Defensive sentiment filter"]
  node_classifier["Naive Bayes classifier"]
  node_scoring["Signals and source weights<br/>[signalCounter.js]"]
  node_legacy_checker["Standalone scam checker<br/>[scamChecker.js]"]
  node_content_fetcher["Content fetcher<br/>[contentFetcher.js]"]
end

subgraph group_learning["Feedback learning"]
  node_feedback_route["Feedback endpoint<br/>[feedback.routes.js]"]
  node_feedback_service["Feedback service"]
  node_feedback_store[("Classifier feedback store<br/>[feedback.js]")]
end

node_visitor(("Visitor or agent"))
node_search_provider{{"SerpApi"}}
node_web_sources{{"Public web sources"}}
node_mongo[("MongoDB")]

node_visitor -->|"submits query"| node_dashboard
node_dashboard -->|"requests analysis"| node_frontend_api
node_frontend_api -->|"posts scan"| node_analyze_routes
node_analyze_routes -->|"analyzes query"| node_analyzer
node_analyzer -->|"extracts entity"| node_entity_extract
node_analyzer -->|"searches entity"| node_search
node_search -->|"queries"| node_search_provider
node_search -.->|"returns results"| node_content
node_analyzer -->|"fetches content"| node_content
node_content -.->|"fetches pages"| node_web_sources
node_analyzer -->|"filters results"| node_sentiment
node_sentiment -->|"classifies text"| node_classifier
node_analyzer -->|"counts signals"| node_scoring
node_analyzer -->|"returns verdict"| node_risk_card
node_auth_pages -->|"calls auth API"| node_frontend_api
node_history_page -->|"loads archives"| node_frontend_api
node_api_app -->|"mounts routes"| node_analyze_routes
node_api_app -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"dispatches auth"| node_auth_controller
node_auth_routes -->|"protects profile"| node_jwt_guard
node_analyze_routes -->|"checks usage"| node_usage_gate
node_analyze_routes -->|"protects archive lookup"| node_jwt_guard
node_auth_controller -->|"creates and reads users"| node_user_store
node_auth_controller -->|"recovers pending scan"| node_analyzer
node_analyze_routes -->|"saves scan history"| node_user_store
node_jwt_guard -->|"loads user"| node_user_store
node_user_store -.->|"persists records"| node_mongo
node_feedback_route -->|"delegates feedback"| node_feedback_service
node_feedback_service -->|"records feedback"| node_feedback_store
node_legacy_checker -->|"fetches content"| node_content_fetcher
node_legacy_checker -->|"classifies sentiment"| node_classifier
node_legacy_checker -->|"uses feedback"| node_feedback_store

click node_dashboard "https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/pages/Dashboard.jsx"
click node_frontend_api "https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/services/api.js"
click node_auth_pages "https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/pages/AuthPages.jsx"
click node_history_page "https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/pages/History.jsx"
click node_risk_card "https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/components/RiskCard.jsx"
click node_api_app "https://github.com/arunbhadouria/naughty_company/blob/main/src/app.js"
click node_analyze_routes "https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/analyze.routes.js"
click node_auth_routes "https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/auth.routes.js"
click node_auth_controller "https://github.com/arunbhadouria/naughty_company/blob/main/src/controllers/auth.controller.js"
click node_jwt_guard "https://github.com/arunbhadouria/naughty_company/blob/main/src/middleware/auth.middleware.js"
click node_usage_gate "https://github.com/arunbhadouria/naughty_company/blob/main/src/middleware/usage.middleware.js"
click node_user_store "https://github.com/arunbhadouria/naughty_company/blob/main/src/models/User.js"
click node_analyzer "https://github.com/arunbhadouria/naughty_company/blob/main/src/services/analyzer.service.js"
click node_entity_extract "https://github.com/arunbhadouria/naughty_company/blob/main/src/utils/entityExtractor.js"
click node_search "https://github.com/arunbhadouria/naughty_company/blob/main/src/services/search.service.js"
click node_content "https://github.com/arunbhadouria/naughty_company/blob/main/src/services/content.service.js"
click node_sentiment "https://github.com/arunbhadouria/naughty_company/blob/main/src/services/sentiment.service.js"
click node_classifier "https://github.com/arunbhadouria/naughty_company/blob/main/sentiment-model/sentimentAnalyzer.js"
click node_scoring "https://github.com/arunbhadouria/naughty_company/blob/main/src/utils/signalCounter.js"
click node_legacy_checker "https://github.com/arunbhadouria/naughty_company/blob/main/scamChecker.js"
click node_content_fetcher "https://github.com/arunbhadouria/naughty_company/blob/main/contentFetcher.js"
click node_feedback_route "https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/feedback.routes.js"
click node_feedback_service "https://github.com/arunbhadouria/naughty_company/blob/main/src/services/feedback.service.js"
click node_feedback_store "https://github.com/arunbhadouria/naughty_company/blob/main/sentiment-model/feedback.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_frontend_api,node_auth_pages,node_history_page,node_risk_card toneBlue
class node_api_app,node_analyze_routes,node_auth_routes,node_auth_controller,node_jwt_guard,node_usage_gate,node_user_store,node_mongo toneAmber
class node_analyzer,node_entity_extract,node_search,node_content,node_sentiment,node_classifier,node_scoring,node_legacy_checker,node_content_fetcher,node_search_provider toneMint
class node_feedback_route,node_feedback_service,node_feedback_store toneRose
class node_visitor,node_web_sources toneIndigo
```

## Components

### Web experience

- [Scan dashboard](https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Frontend API client](https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Auth screens](https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/pages/AuthPages.jsx): `frontend/src/pages/AuthPages.jsx`
- [Scan history view](https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/pages/History.jsx): `frontend/src/pages/History.jsx`
- [Risk result card](https://github.com/arunbhadouria/naughty_company/blob/main/frontend/src/components/RiskCard.jsx): `frontend/src/components/RiskCard.jsx`

### Identity and archives

- [API application](https://github.com/arunbhadouria/naughty_company/blob/main/src/app.js): `src/app.js`
- [Analysis routes](https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/analyze.routes.js): `src/routes/analyze.routes.js`
- [Auth routes](https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/auth.routes.js): `src/routes/auth.routes.js`
- [Auth controller](https://github.com/arunbhadouria/naughty_company/blob/main/src/controllers/auth.controller.js): `src/controllers/auth.controller.js`
- [JWT protection](https://github.com/arunbhadouria/naughty_company/blob/main/src/middleware/auth.middleware.js): `src/middleware/auth.middleware.js`
- [Scan usage gate](https://github.com/arunbhadouria/naughty_company/blob/main/src/middleware/usage.middleware.js): `src/middleware/usage.middleware.js`
- [User and scan archive](https://github.com/arunbhadouria/naughty_company/blob/main/src/models/User.js): `src/models/User.js`

### Investigation engine

- [Analysis coordinator](https://github.com/arunbhadouria/naughty_company/blob/main/src/services/analyzer.service.js): `src/services/analyzer.service.js`
- [Entity extraction](https://github.com/arunbhadouria/naughty_company/blob/main/src/utils/entityExtractor.js): `src/utils/entityExtractor.js`
- [Web search](https://github.com/arunbhadouria/naughty_company/blob/main/src/services/search.service.js): `src/services/search.service.js`
- [Content enrichment](https://github.com/arunbhadouria/naughty_company/blob/main/src/services/content.service.js): `src/services/content.service.js`
- [Defensive sentiment filter](https://github.com/arunbhadouria/naughty_company/blob/main/src/services/sentiment.service.js): `src/services/sentiment.service.js`
- [Naive Bayes classifier](https://github.com/arunbhadouria/naughty_company/blob/main/sentiment-model/sentimentAnalyzer.js): `sentiment-model/sentimentAnalyzer.js`
- [Signals and source weights](https://github.com/arunbhadouria/naughty_company/blob/main/src/utils/signalCounter.js): `src/utils/signalCounter.js`
- [Standalone scam checker](https://github.com/arunbhadouria/naughty_company/blob/main/scamChecker.js): `scamChecker.js`
- [Content fetcher](https://github.com/arunbhadouria/naughty_company/blob/main/contentFetcher.js): `contentFetcher.js`

### Feedback learning

- [Feedback endpoint](https://github.com/arunbhadouria/naughty_company/blob/main/src/routes/feedback.routes.js): `src/routes/feedback.routes.js`
- [Feedback service](https://github.com/arunbhadouria/naughty_company/blob/main/src/services/feedback.service.js): `src/services/feedback.service.js`
- [Classifier feedback store](https://github.com/arunbhadouria/naughty_company/blob/main/sentiment-model/feedback.js): `sentiment-model/feedback.js`

### Other components

- **Visitor or agent**
- **SerpApi**
- **Public web sources**
- **MongoDB**

## Connections

- Visitor or agent → Scan dashboard: submits query (evidence: `frontend/src/pages/Dashboard.jsx`)
- Scan dashboard → Frontend API client: requests analysis (evidence: `frontend/src/pages/Dashboard.jsx`)
- Frontend API client → Analysis routes: posts scan (evidence: `frontend/src/services/api.js`)
- Analysis routes → Analysis coordinator: analyzes query (evidence: `src/routes/analyze.routes.js`)
- Analysis coordinator → Entity extraction: extracts entity (evidence: `src/services/analyzer.service.js`)
- Analysis coordinator → Web search: searches entity (evidence: `src/services/analyzer.service.js`)
- Web search → SerpApi: queries (evidence: `README.md`)
- Web search → Content enrichment: returns results
- Analysis coordinator → Content enrichment: fetches content (evidence: `src/services/analyzer.service.js`)
- Content enrichment → Public web sources: fetches pages
- Analysis coordinator → Defensive sentiment filter: filters results (evidence: `src/services/analyzer.service.js`)
- Defensive sentiment filter → Naive Bayes classifier: classifies text (evidence: `src/services/sentiment.service.js`)
- Analysis coordinator → Signals and source weights: counts signals (evidence: `src/services/analyzer.service.js`)
- Analysis coordinator → Risk result card: returns verdict (evidence: `README.md`)
- Auth screens → Frontend API client: calls auth API (evidence: `frontend/src/pages/AuthPages.jsx`)
- Scan history view → Frontend API client: loads archives (evidence: `frontend/src/pages/History.jsx`)
- API application → Analysis routes: mounts routes (evidence: `src/app.js`)
- API application → Auth routes: mounts routes (evidence: `src/app.js`)
- Auth routes → Auth controller: dispatches auth (evidence: `src/routes/auth.routes.js`)
- Auth routes → JWT protection: protects profile (evidence: `src/routes/auth.routes.js`)
- Analysis routes → Scan usage gate: checks usage (evidence: `src/routes/analyze.routes.js`)
- Analysis routes → JWT protection: protects archive lookup (evidence: `src/routes/analyze.routes.js`)
- Auth controller → User and scan archive: creates and reads users (evidence: `src/controllers/auth.controller.js`)
- Auth controller → Analysis coordinator: recovers pending scan (evidence: `src/controllers/auth.controller.js`)
- Analysis routes → User and scan archive: saves scan history (evidence: `src/routes/analyze.routes.js`)
- JWT protection → User and scan archive: loads user (evidence: `src/middleware/auth.middleware.js`)
- User and scan archive → MongoDB: persists records
- Feedback endpoint → Feedback service: delegates feedback (evidence: `src/routes/feedback.routes.js`)
- Feedback service → Classifier feedback store: records feedback (evidence: `src/services/feedback.service.js`)
- Standalone scam checker → Content fetcher: fetches content (evidence: `scamChecker.js`)
- Standalone scam checker → Naive Bayes classifier: classifies sentiment (evidence: `scamChecker.js`)
- Standalone scam checker → Classifier feedback store: uses feedback (evidence: `scamChecker.js`)
