How ksacheth/sih-2026 works
Purpose and Runtime Shape
This is a privacy-preserving personal data exposure monitor. A Next.js App Router application accepts user identifiers, discovers public/breach evidence, extracts and correlates PII, assigns deterministic risk, and presents remediation actions. A separate Python/FastAPI sidecar provides GLiNER-based extraction. The repository includes both scaffolded product layers and a production evaluation dataset.
Primary application entry points: src/app/page.tsx, src/app/dashboard/page.tsx, src/app/api/scan/route.ts, and sidecar/main.py.
API and User Boundary
Next.js Route Handlers form the application boundary for authenticated account, identifier, scan, exposure, and health operations. The UI is a dashboard/onboarding client layered over those APIs, rather than a separate backend service.
Key paths:
• src/app/api/auth/[...nextauth]/route.ts
• src/app/api/identifiers/route.ts
• src/app/api/scan/route.ts
• src/components/dashboard/dashboard-client.tsx
• src/lib/auth/require-user.ts
Scan Orchestration
The scan pipeline is the central control flow: validate and normalize identifiers; create/manage scan state; invoke permitted discovery connectors; then pass collected evidence to extraction, correlation, rules, and persistence/presentation stages. Fetch protections constrain external retrieval.
Key paths:
• src/lib/pipeline/orchestrator.ts
• src/lib/pipeline/scanState.ts
• src/lib/pipeline/fetchGuard.ts
• src/lib/validation.ts
• src/lib/identifiers.ts
Discovery Connectors and External Services
Connectors isolate third-party discovery semantics behind a shared contract. Expected sources include Serper.dev web search, ExposedOrNot, optional HIBP, Pwned Passwords range API, and the local broker catalog. Cache support limits repeated external calls.
Key paths:
• src/lib/connectors/index.ts
• src/lib/connectors/types.ts
• src/lib/connectors/serper.ts
• src/lib/connectors/exposedOrNot.ts
• src/lib/connectors/cache.ts
• data/brokers.json
Evidence Extraction and Correlation
Raw source responses are converted to extracted identifiers using rules/checksums and the GLiNER sidecar, then fused and matched against the user’s identity. This is the key boundary between untrusted external content and internally assessed evidence.
Key paths:
• src/lib/extraction/client.ts
• src/lib/extraction/fusion.ts
• src/lib/correlation/pipelineAdapter.ts
• src/lib/correlation/nameMatcher.ts
• sidecar/app.py
• sidecar/schemas.py
Deterministic Risk and Action Layer
Rules turn correlated evidence into severity, confidence, threats, broker context, and recommendations. LLM output is limited to explaining an already-redacted finding; it is not an evidence, identity, or severity authority. Monitoring tracks future exposure state via fingerprints and a state machine.
Key paths:
• src/lib/rules/rulesEngine.ts is not present; rule modules are under src/lib/rules/
• src/lib/rules/confidence.ts
• src/lib/rules/severity.ts
• src/lib/rules/recommendations.ts
• src/lib/llm/explain.ts
• src/lib/monitoring/stateMachine.ts
Data, Security, and Operations
MongoDB Atlas is the durable store, with TTL-oriented cache/quota support implied by models and connector caching. Sensitive values are normalized, masked, encrypted/audited, rate-limited, and redacted before Gemini. Docker Compose coordinates the application, Mongo initialization, and sidecar runtime.
Key paths:
• src/lib/models/db.ts
• src/lib/models/Cache.ts
• src/lib/security/crypto.ts
• src/lib/security/audit.ts
• src/lib/security/rate-limit.ts
• Docker-compose.yml
• scripts/init-mongo.js
Evaluation Asset Boundary
The golden corpus, decoys, ground truth, generator, and Python evaluators are offline quality assets for correlation/detection validation, not runtime discovery infrastructure.
Key paths:
• data/eval/ground_truth.json
• data/eval/corpus/
• advanced_evaluator.py
• validate_dataset.py
Main entry points: route.ts Authenticated API routes · orchestrator.ts Scan orchestrator · index.ts Discovery connectors · fusion.ts Extraction fusion
Components 22
Next.js application
User-facing UI and authenticated route handlers.
- Dashboard & onboarding
src/components/dashboard/dashboard-client.tsx - Authenticated API routes · Account, identifier, scan, exposure, and health boundary.
src/app/api/scan/route.ts - User authorization
src/lib/auth/require-user.ts
Scan assessment pipeline
Transforms identifiers and external evidence into findings.
- Identifier normalization
src/lib/validation.ts - Scan orchestrator · Coordinates discovery, assessment, persistence, and scan state.
src/lib/pipeline/orchestrator.ts - Scan state
src/lib/pipeline/scanState.ts - Fetch protections
src/lib/pipeline/fetchGuard.ts - Discovery connectors · Adapters cover search, breach, password, and broker sources.
src/lib/connectors/index.ts - Connector cache · Limits repeated third-party calls.
src/lib/connectors/cache.ts - Broker catalog
data/brokers.json - Extraction fusion · Combines rule/checksum extraction with sidecar entities.
src/lib/extraction/fusion.ts - Identity correlation · Matches fused identifiers to the user's identity.
src/lib/correlation/pipelineAdapter.ts - Deterministic risk rules · Derives confidence, severity, threats, and recommendations.
src/lib/rules/severity.ts - Exposure monitoring · Tracks future exposure state using fingerprints.
src/lib/monitoring/stateMachine.ts - Redacted finding explanation · Gemini can explain findings but cannot determine evidence or severity.
src/lib/llm/explain.ts
Extraction sidecar
FastAPI service for GLiNER-based entity extraction.
- GLiNER extraction API
sidecar/main.py - Extraction schemas
sidecar/schemas.py
Data and operations
Durable storage, security controls, and runtime coordination.
- MongoDB Atlas · Stores accounts, scans, findings, cache, and quota data.
src/lib/models/db.ts - Security controls · Encryption, audit, masking, redaction, and rate limiting.
src/lib/security/crypto.ts - Container runtime · Coordinates app, Mongo initialization, and extraction sidecar.
Docker-compose.yml
Offline evaluation
Quality assets excluded from runtime discovery.
- Golden evaluation dataset · Corpus, decoys, and ground truth validate detection and correlation.
data/eval/ground_truth.json - Python evaluators
advanced_evaluator.py
Connections 22
- Dashboard & onboarding → Authenticated API routes: uses
- Authenticated API routes → User authorization: authorizes
- Authenticated API routes → Identifier normalization: validates input
- Authenticated API routes → Scan orchestrator: starts scan
- Scan orchestrator → Scan state: manages
- Scan orchestrator → Fetch protections: constrains retrieval
- Fetch protections → Discovery connectors: permits calls
- Discovery connectors → Connector cache: reads/writes
- Discovery connectors → Broker catalog: uses catalog
- Discovery connectors → Extraction fusion: raw evidence
- Extraction fusion → GLiNER extraction API: GLiNER extraction
- GLiNER extraction API → Extraction schemas: uses
- Extraction fusion → Identity correlation: fused identifiers
- Identity correlation → Deterministic risk rules: matched evidence
- Deterministic risk rules → Exposure monitoring: findings and fingerprints
- Deterministic risk rules → Redacted finding explanation: redacted finding
- Scan orchestrator → MongoDB Atlas: persists scans
- Authenticated API routes → Security controls: protects access
- Security controls → MongoDB Atlas: encrypts/audits
- Container runtime → GLiNER extraction API: runs
- Container runtime → MongoDB Atlas: initializes
- Python evaluators → Golden evaluation dataset: validates