# 3dbmonitoraedu/tcc architecture

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

- Interactive diagram: https://gitdiagram.com/3dbmonitoraedu/tcc
- Repository: https://github.com/3dbmonitoraedu/tcc

## Overview

MoniTec is a school-computer monitoring system: a teacher uses a web dashboard to manage rooms, view connected agents and machine metrics, and issue remote actions; local agents poll a backend with status and pending commands. The tree contains both a Cloudflare Worker backend and a separate Express/SQLite server, so both are shown as backend implementations rather than assuming they are deployed together. README statements support the broad HTTP flows; source-index references and excerpts support the internal links shown. Unsampled integrations are omitted where their wiring is uncertain.

Main entry points: [`projeto/moniedu-worker/src/routes/agents.ts`](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/routes/agents.ts) (Agent Routes), [`projeto/servidor/src/index.js`](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/index.js) (Express Routes), [`projeto/agente/internal/agent/agent.go`](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/agent/agent.go) (Agent Runtime), [`projeto/front/src/App.tsx`](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/App.tsx) (Web Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Teacher Web App"]
  node_app["Web Routes<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_adminui["Admin Console<br/>[Admin.tsx]"]
  node_frontapi["API Clients"]
end

subgraph group_worker["Worker Backend"]
  node_workerentry["Worker Routes<br/>[index.ts]"]
  node_agentroutes["Agent Routes<br/>[agents.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_authmiddleware["Auth Middleware<br/>[auth.ts]"]
  node_agentservice["Agent Registry<br/>[agents.ts]"]
  node_metrics["Metrics<br/>[metrics.ts]"]
  node_processes["Process Data<br/>[processes.ts]"]
  node_dns["DNS Policy<br/>[dns.ts]"]
  node_commands["Command Queue<br/>[command.ts]"]
  node_rooms["Room Management<br/>[rooms.ts]"]
  node_d1[("Worker Database")]
end

subgraph group_server["Express Backend"]
  node_serverroutes["Express Routes<br/>[index.js]"]
  node_serverauth["Session Services<br/>[auth.js]"]
  node_serveragents["Agent Services<br/>[agents.js]"]
  node_servercommands["Command Services<br/>[command.js]"]
  node_sqlite[("SQLite Store<br/>[index.js]")]
end

subgraph group_agent["Local Agent"]
  node_agentmain["Agent Runtime<br/>[agent.go]"]
  node_apiclient["HTTP Client<br/>[apiclient.go]"]
  node_collector["Machine Collector<br/>[collector.go]"]
  node_executor["Command Executor<br/>[executor.go]"]
  node_agentdns["Local DNS<br/>[dns.go]"]
  node_setup["Initial Setup<br/>[setup.go]"]
end

node_teacher(("Teacher"))

node_teacher -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_adminui
node_teacher -->|"requests status"| node_frontapi
node_frontapi -.->|"HTTP requests"| node_workerentry
node_frontapi -.->|"HTTP requests"| node_serverroutes
node_workerentry -.->|"routes requests"| node_agentroutes
node_agentroutes -->|"calls"| node_agentservice
node_agentroutes -->|"records metrics"| node_metrics
node_agentroutes -->|"reads and updates"| node_dns
node_agentroutes -->|"fetches commands"| node_commands
node_agentroutes -->|"protects dashboard calls"| node_authmiddleware
node_authmiddleware -->|"gets session"| node_auth
node_agentservice -->|"uses"| node_processes
node_metrics -->|"uses"| node_processes
node_dns -->|"reads and writes"| node_d1
node_agentroutes -->|"returns metrics and policy"| node_teacher
node_agentmain -.->|"polls backend"| node_apiclient
node_agentmain -.->|"collects machine data"| node_collector
node_agentmain -.->|"runs authorized commands"| node_executor
node_agentmain -.->|"applies DNS policy"| node_agentdns
node_agentmain -.->|"configured by"| node_setup
node_apiclient -->|"polls by HTTP"| node_workerentry
node_apiclient -.->|"polls by HTTP"| node_serverroutes
node_serverroutes -->|"dispatches auth"| node_serverauth
node_serverauth -->|"reads and writes"| node_sqlite
node_serverauth -->|"returns session"| node_serverroutes
node_serverroutes -->|"dispatches agent requests"| node_serveragents
node_serverroutes -.->|"routes commands"| node_servercommands
node_agentmain -->|"sends status, checks commands"| node_serverroutes

click node_app "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/App.tsx"
click node_dashboard "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/pages/Dashboard.tsx"
click node_adminui "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/pages/Admin.tsx"
click node_frontapi "https://github.com/3dbmonitoraedu/tcc/tree/main/projeto/front/src/api"
click node_workerentry "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/index.ts"
click node_agentroutes "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/routes/agents.ts"
click node_auth "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/auth.ts"
click node_authmiddleware "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/middlewares/auth.ts"
click node_agentservice "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/agents.ts"
click node_metrics "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/metrics.ts"
click node_processes "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/processes.ts"
click node_dns "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/dns.ts"
click node_commands "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/command.ts"
click node_rooms "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/rooms.ts"
click node_serverroutes "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/index.js"
click node_serverauth "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/services/auth.js"
click node_serveragents "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/services/agents.js"
click node_servercommands "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/services/command.js"
click node_sqlite "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/db/index.js"
click node_agentmain "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/agent/agent.go"
click node_apiclient "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/apiclient/apiclient.go"
click node_collector "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/collector/collector.go"
click node_executor "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/executor/executor.go"
click node_agentdns "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/dns/dns.go"
click node_setup "https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/setup/setup.go"

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_dashboard,node_adminui,node_frontapi toneBlue
class node_workerentry,node_agentroutes,node_auth,node_authmiddleware,node_agentservice,node_metrics,node_processes,node_dns,node_commands,node_rooms,node_d1 toneAmber
class node_serverroutes,node_serverauth,node_serveragents,node_servercommands,node_sqlite toneMint
class node_agentmain,node_apiclient,node_collector,node_executor,node_agentdns,node_setup toneRose
class node_teacher toneIndigo
```

## Components

### Teacher Web App

- [Web Routes](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/App.tsx): `projeto/front/src/App.tsx`
- [Dashboard](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/pages/Dashboard.tsx): `projeto/front/src/pages/Dashboard.tsx`
- [Admin Console](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/front/src/pages/Admin.tsx): `projeto/front/src/pages/Admin.tsx`
- [API Clients](https://github.com/3dbmonitoraedu/tcc/tree/main/projeto/front/src/api): `projeto/front/src/api`

### Worker Backend

- [Worker Routes](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/index.ts): `projeto/moniedu-worker/src/index.ts`
- [Agent Routes](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/routes/agents.ts): `projeto/moniedu-worker/src/routes/agents.ts`
- [Authentication](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/auth.ts): `projeto/moniedu-worker/src/auth.ts`
- [Auth Middleware](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/middlewares/auth.ts): `projeto/moniedu-worker/src/middlewares/auth.ts`
- [Agent Registry](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/agents.ts): `projeto/moniedu-worker/src/services/agents.ts`
- [Metrics](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/metrics.ts): `projeto/moniedu-worker/src/services/metrics.ts`
- [Process Data](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/processes.ts): `projeto/moniedu-worker/src/services/processes.ts`
- [DNS Policy](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/dns.ts): `projeto/moniedu-worker/src/services/dns.ts`
- [Command Queue](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/command.ts): `projeto/moniedu-worker/src/services/command.ts`
- [Room Management](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/moniedu-worker/src/services/rooms.ts): `projeto/moniedu-worker/src/services/rooms.ts`
- **Worker Database**

### Express Backend

- [Express Routes](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/index.js): `projeto/servidor/src/index.js`
- [Session Services](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/services/auth.js): `projeto/servidor/src/services/auth.js`
- [Agent Services](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/services/agents.js): `projeto/servidor/src/services/agents.js`
- [Command Services](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/services/command.js): `projeto/servidor/src/services/command.js`
- [SQLite Store](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/servidor/src/db/index.js): `projeto/servidor/src/db/index.js`

### Local Agent

- [Agent Runtime](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/agent/agent.go): `projeto/agente/internal/agent/agent.go`
- [HTTP Client](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/apiclient/apiclient.go): `projeto/agente/internal/apiclient/apiclient.go`
- [Machine Collector](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/collector/collector.go): `projeto/agente/internal/collector/collector.go`
- [Command Executor](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/executor/executor.go): `projeto/agente/internal/executor/executor.go`
- [Local DNS](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/dns/dns.go): `projeto/agente/internal/dns/dns.go`
- [Initial Setup](https://github.com/3dbmonitoraedu/tcc/blob/main/projeto/agente/internal/setup/setup.go): `projeto/agente/internal/setup/setup.go`

### Other components

- **Teacher**

## Connections

- Teacher → Web Routes: uses
- Web Routes → Dashboard: routes to (evidence: `projeto/front/src/App.tsx`)
- Web Routes → Admin Console: routes to (evidence: `projeto/front/src/App.tsx`)
- Teacher → API Clients: requests status
- API Clients → Worker Routes: HTTP requests
- API Clients → Express Routes: HTTP requests
- Worker Routes → Agent Routes: routes requests
- Agent Routes → Agent Registry: calls (evidence: `projeto/moniedu-worker/src/routes/agents.ts`)
- Agent Routes → Metrics: records metrics (evidence: `projeto/moniedu-worker/src/routes/agents.ts`)
- Agent Routes → DNS Policy: reads and updates (evidence: `projeto/moniedu-worker/src/routes/agents.ts`)
- Agent Routes → Command Queue: fetches commands (evidence: `projeto/moniedu-worker/src/routes/agents.ts`)
- Agent Routes → Auth Middleware: protects dashboard calls (evidence: `projeto/moniedu-worker/src/routes/agents.ts`)
- Auth Middleware → Authentication: gets session (evidence: `projeto/moniedu-worker/src/middlewares/auth.ts`)
- Agent Registry → Process Data: uses (evidence: `projeto/moniedu-worker/src/services/agents.ts`)
- Metrics → Process Data: uses (evidence: `projeto/moniedu-worker/src/services/metrics.ts`)
- DNS Policy → Worker Database: reads and writes (evidence: `projeto/moniedu-worker/src/services/dns.ts`)
- Agent Routes → Teacher: returns metrics and policy (evidence: `projeto/moniedu-worker/src/routes/agents.ts`)
- Agent Runtime → HTTP Client: polls backend
- Agent Runtime → Machine Collector: collects machine data
- Agent Runtime → Command Executor: runs authorized commands
- Agent Runtime → Local DNS: applies DNS policy
- Agent Runtime → Initial Setup: configured by
- HTTP Client → Worker Routes: polls by HTTP
- HTTP Client → Express Routes: polls by HTTP
- Express Routes → Session Services: dispatches auth
- Session Services → SQLite Store: reads and writes (evidence: `projeto/servidor/src/services/auth.js`)
- Session Services → Express Routes: returns session
- Express Routes → Agent Services: dispatches agent requests
- Express Routes → Command Services: routes commands
- Agent Runtime → Express Routes: sends status, checks commands
