# mahnoor643/ethical_hacking_project architecture

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

- Interactive diagram: https://gitdiagram.com/mahnoor643/ethical_hacking_project
- Repository: https://github.com/mahnoor643/ethical_hacking_project

## Overview

Agent Activity Logger is a security-monitoring dashboard for submitting sales-analysis tasks to a constrained AI agent, then reviewing recorded runs, event timelines, and security alerts. The principal workflow runs from the authenticated React interface through the Worker API, which applies rate limits and task policy before invoking the agent; approved tool results and security events are recorded in D1. The dashboard also supports login/session management, run history, and alert filtering. Worker routing and agent calls are excerpted; UI/API and storage capabilities are also supported by the README. Unshown route-to-storage details are omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/App.jsx) (App Navigation), [`worker/src/agent.ts`](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/agent.ts) (Agent Orchestrator), [`frontend/src/services/api.js`](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/services/api.js) (API Client), [`worker/src/index.ts`](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/index.ts) (API Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Dashboard UI"]
  node_app["App Navigation<br/>[App.jsx]"]
  node_login["Login Screen<br/>[Login.jsx]"]
  node_auth_hook["Session State<br/>[useAuth.js]"]
  node_execution_page["Agent Execution<br/>[AgentExecution.jsx]"]
  node_task_form["Task Form<br/>[TaskForm.jsx]"]
  node_execution_hook["Execution State"]
  node_agent_result["Agent Result<br/>[AgentResult.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_run_history["Run History<br/>[RunHistory.jsx]"]
  node_runs_hook["Run Queries<br/>[useRuns.js]"]
  node_timeline_page["Timeline View<br/>[TimelinePage.jsx]"]
  node_activity_timeline["Activity Timeline"]
  node_alerts_page["Security Alerts<br/>[SecurityAlerts.jsx]"]
  node_api_client["API Client<br/>[api.js]"]
end

subgraph group_api["Worker API"]
  node_worker_router["API Router<br/>[index.ts]"]
  node_auth["Session Auth<br/>[auth.ts]"]
  node_rate_limit["Rate Limiting<br/>[ratelimit.ts]"]
end

subgraph group_agent["Agent Controls"]
  node_agent_run["Agent Orchestrator<br/>[agent.ts]"]
  node_policy["Task Policy<br/>[policy.ts]"]
  node_tools["Approved Tools<br/>[tools.ts]"]
end

subgraph group_data["Persistence And AI"]
  node_logger["Run Logger<br/>[logger.ts]"]
  node_alerts["Alert Recording<br/>[alerts.ts]"]
  node_d1[("Activity Database<br/>[schema.sql]")]
  node_workers_ai{{"Workers AI"}}
end

node_browser(("Browser User"))

node_browser -->|"uses dashboard"| node_app
node_app -->|"renders when unauthenticated"| node_login
node_app -->|"checks session"| node_auth_hook
node_auth_hook -->|"requests session"| node_api_client
node_app -->|"routes to"| node_execution_page
node_execution_page -->|"renders"| node_task_form
node_execution_page -->|"renders"| node_agent_result
node_execution_page -->|"uses execution state"| node_execution_hook
node_execution_hook -->|"submits task"| node_api_client
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_run_history
node_app -->|"routes to"| node_timeline_page
node_app -->|"routes to"| node_alerts_page
node_dashboard -->|"loads recent runs"| node_runs_hook
node_run_history -->|"loads run history"| node_runs_hook
node_runs_hook -->|"requests runs"| node_api_client
node_timeline_page -->|"renders timeline"| node_activity_timeline
node_activity_timeline -->|"requests run logs"| node_api_client
node_alerts_page -->|"requests alerts"| node_api_client
node_api_client -->|"sends API requests"| node_worker_router
node_worker_router -->|"checks sessions"| node_auth
node_worker_router -->|"applies limits"| node_rate_limit
node_worker_router -->|"starts agent run"| node_agent_run
node_agent_run -->|"screens and validates task"| node_policy
node_agent_run -->|"requests tool decision"| node_workers_ai
node_agent_run -->|"executes approved tool"| node_tools
node_agent_run -->|"records run activity"| node_logger
node_agent_run -->|"records security events"| node_alerts
node_logger -->|"writes run logs"| node_d1
node_alerts -->|"writes alerts"| node_d1
node_rate_limit -->|"stores limit windows"| node_d1
node_auth -.->|"stores signed session"| node_d1
node_worker_router -->|"reads run and alert data"| node_d1

click node_app "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/Login.jsx"
click node_auth_hook "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/hooks/useAuth.js"
click node_execution_page "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/AgentExecution.jsx"
click node_task_form "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/components/TaskForm.jsx"
click node_execution_hook "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/hooks/useAgentExecution.js"
click node_agent_result "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/components/AgentResult.jsx"
click node_dashboard "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/Dashboard.jsx"
click node_run_history "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/RunHistory.jsx"
click node_runs_hook "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/hooks/useRuns.js"
click node_timeline_page "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/TimelinePage.jsx"
click node_activity_timeline "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/components/ActivityTimeline.jsx"
click node_alerts_page "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/SecurityAlerts.jsx"
click node_api_client "https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/services/api.js"
click node_worker_router "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/index.ts"
click node_auth "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/auth.ts"
click node_rate_limit "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/ratelimit.ts"
click node_agent_run "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/agent.ts"
click node_policy "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/policy.ts"
click node_tools "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/tools.ts"
click node_logger "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/logger.ts"
click node_alerts "https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/alerts.ts"
click node_d1 "https://github.com/mahnoor643/ethical_hacking_project/blob/main/schema.sql"

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_app,node_login,node_auth_hook,node_execution_page,node_task_form,node_execution_hook,node_agent_result,node_dashboard,node_run_history,node_runs_hook,node_timeline_page,node_activity_timeline,node_alerts_page,node_api_client,node_browser toneBlue
class node_worker_router,node_auth,node_rate_limit toneAmber
class node_agent_run,node_policy,node_tools toneMint
class node_logger,node_alerts,node_d1,node_workers_ai toneRose
```

## Components

### Dashboard UI

- [App Navigation](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login Screen](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Session State](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/hooks/useAuth.js): `frontend/src/hooks/useAuth.js`
- [Agent Execution](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/AgentExecution.jsx): `frontend/src/pages/AgentExecution.jsx`
- [Task Form](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/components/TaskForm.jsx): `frontend/src/components/TaskForm.jsx`
- [Execution State](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/hooks/useAgentExecution.js): `frontend/src/hooks/useAgentExecution.js`
- [Agent Result](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/components/AgentResult.jsx): `frontend/src/components/AgentResult.jsx`
- [Dashboard](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Run History](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/RunHistory.jsx): `frontend/src/pages/RunHistory.jsx`
- [Run Queries](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/hooks/useRuns.js): `frontend/src/hooks/useRuns.js`
- [Timeline View](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/TimelinePage.jsx): `frontend/src/pages/TimelinePage.jsx`
- [Activity Timeline](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/components/ActivityTimeline.jsx): `frontend/src/components/ActivityTimeline.jsx`
- [Security Alerts](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/pages/SecurityAlerts.jsx): `frontend/src/pages/SecurityAlerts.jsx`
- [API Client](https://github.com/mahnoor643/ethical_hacking_project/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Worker API

- [API Router](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/index.ts): `worker/src/index.ts`
- [Session Auth](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/auth.ts): `worker/src/auth.ts`
- [Rate Limiting](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/ratelimit.ts): `worker/src/ratelimit.ts`

### Agent Controls

- [Agent Orchestrator](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/agent.ts): `worker/src/agent.ts`
- [Task Policy](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/policy.ts): `worker/src/policy.ts`
- [Approved Tools](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/tools.ts): `worker/src/tools.ts`

### Persistence And AI

- [Run Logger](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/logger.ts): `worker/src/logger.ts`
- [Alert Recording](https://github.com/mahnoor643/ethical_hacking_project/blob/main/worker/src/alerts.ts): `worker/src/alerts.ts`
- [Activity Database](https://github.com/mahnoor643/ethical_hacking_project/blob/main/schema.sql): `schema.sql`
- **Workers AI**

### Other components

- **Browser User**

## Connections

- Browser User → App Navigation: uses dashboard (evidence: `README.md`)
- App Navigation → Login Screen: renders when unauthenticated (evidence: `frontend/src/App.jsx`)
- App Navigation → Session State: checks session (evidence: `frontend/src/App.jsx`)
- Session State → API Client: requests session (evidence: `frontend/src/hooks/useAuth.js`)
- App Navigation → Agent Execution: routes to (evidence: `frontend/src/App.jsx`)
- Agent Execution → Task Form: renders (evidence: `frontend/src/pages/AgentExecution.jsx`)
- Agent Execution → Agent Result: renders (evidence: `frontend/src/pages/AgentExecution.jsx`)
- Agent Execution → Execution State: uses execution state (evidence: `frontend/src/App.jsx`)
- Execution State → API Client: submits task (evidence: `frontend/src/hooks/useAgentExecution.js`)
- App Navigation → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App Navigation → Run History: routes to (evidence: `frontend/src/App.jsx`)
- App Navigation → Timeline View: routes to (evidence: `frontend/src/App.jsx`)
- App Navigation → Security Alerts: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard → Run Queries: loads recent runs (evidence: `frontend/src/pages/Dashboard.jsx`)
- Run History → Run Queries: loads run history (evidence: `frontend/src/pages/RunHistory.jsx`)
- Run Queries → API Client: requests runs (evidence: `frontend/src/hooks/useRuns.js`)
- Timeline View → Activity Timeline: renders timeline (evidence: `frontend/src/pages/TimelinePage.jsx`)
- Activity Timeline → API Client: requests run logs (evidence: `frontend/src/components/ActivityTimeline.jsx`)
- Security Alerts → API Client: requests alerts (evidence: `frontend/src/pages/SecurityAlerts.jsx`)
- API Client → API Router: sends API requests (evidence: `frontend/src/services/api.js`)
- API Router → Session Auth: checks sessions (evidence: `worker/src/index.ts`)
- API Router → Rate Limiting: applies limits (evidence: `worker/src/index.ts`)
- API Router → Agent Orchestrator: starts agent run (evidence: `worker/src/index.ts`)
- Agent Orchestrator → Task Policy: screens and validates task (evidence: `worker/src/agent.ts`)
- Agent Orchestrator → Workers AI: requests tool decision (evidence: `README.md`)
- Agent Orchestrator → Approved Tools: executes approved tool (evidence: `README.md`)
- Agent Orchestrator → Run Logger: records run activity (evidence: `worker/src/agent.ts`)
- Agent Orchestrator → Alert Recording: records security events (evidence: `worker/src/agent.ts`)
- Run Logger → Activity Database: writes run logs (evidence: `README.md`)
- Alert Recording → Activity Database: writes alerts (evidence: `README.md`)
- Rate Limiting → Activity Database: stores limit windows (evidence: `README.md`)
- Session Auth → Activity Database: stores signed session
- API Router → Activity Database: reads run and alert data (evidence: `worker/src/index.ts`)
