# shashank832832/zero-trust-edge architecture

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

- Interactive diagram: https://gitdiagram.com/shashank832832/zero-trust-edge
- Repository: https://github.com/shashank832832/zero-trust-edge

## Overview

ZeroTrust Edge is an educational identity-aware API gateway. Its main workflow is client request → JWT authentication → policy authorization → per-user rate limiting → controlled proxy to an internal service → audit of the final API outcome. The dashboard demonstrates registration, login, profile access, rate-limit behavior, security checks, and audit-log viewing. PostgreSQL holds users, policies, and audit records; Redis holds rate-limit state. Routes for policy administration and audit queries are additional gateway capabilities. The README documents deployment isolation and security controls; unsampled modules are represented only where the README or source index supports them.

Main entry points: [`apps/gateway/src/app.ts`](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/app.ts) (Gateway App), [`apps/gateway/src/routes/protected.ts`](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/protected.ts) (Protected Routes), [`apps/gateway/src/config/database.ts`](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/config/database.ts) (Database Client), [`apps/gateway/src/routes/auth.ts`](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/auth.ts) (Auth Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client Experience"]
  node_dashboard["Security Dashboard<br/>[App.tsx]"]
end

subgraph group_gateway["Gateway Security"]
  node_app["Gateway App<br/>[app.ts]"]
  node_auth_routes["Auth Routes<br/>[auth.ts]"]
  node_auth_service["Identity Service<br/>[authService.ts]"]
  node_jwt["JWT Utilities<br/>[jwt.ts]"]
  node_authenticate["JWT Authentication<br/>[authenticate.ts]"]
  node_protected["Protected Routes<br/>[protected.ts]"]
  node_authorize["Policy Authorization<br/>[authorize.ts]"]
  node_rate_limiter["Rate Limiter<br/>[rateLimiter.ts]"]
  node_proxy["Identity Proxy<br/>[proxyService.ts]"]
end

subgraph group_admin["Policy and Audit"]
  node_policy_service["Policy Engine<br/>[policyService.ts]"]
  node_audit_middleware["Outcome Auditing<br/>[audit.ts]"]
  node_audit_routes["Audit Queries<br/>[audit.ts]"]
  node_policy_routes["Policy Management<br/>[policy.ts]"]
  node_audit_service["Audit Persistence<br/>[auditService.ts]"]
end

subgraph group_services["Internal Services"]
  node_user_service["User Service<br/>[index.ts]"]
  node_data_service["Data Service<br/>[index.ts]"]
end

subgraph group_state["Gateway State"]
  node_postgres[("PostgreSQL<br/>[schema.prisma]")]
  node_database_config["Database Client<br/>[database.ts]"]
  node_redis[("Redis<br/>[redis.ts]")]
end

node_actor(("Client"))

node_actor -->|"uses"| node_dashboard
node_dashboard -->|"calls gateway"| node_app
node_app -->|"mounts"| node_auth_routes
node_app -->|"mounts"| node_protected
node_app -->|"mounts"| node_policy_routes
node_app -->|"mounts"| node_audit_routes
node_app -->|"runs for API"| node_audit_middleware
node_auth_routes -->|"calls"| node_auth_service
node_auth_service -->|"uses client"| node_database_config
node_auth_service -->|"issues tokens"| node_jwt
node_authenticate -.->|"verifies token"| node_jwt
node_protected -->|"authenticates"| node_authenticate
node_protected -->|"authorizes"| node_authorize
node_authorize -->|"evaluates policy"| node_policy_service
node_policy_service -->|"reads policies"| node_database_config
node_protected -->|"limits requests"| node_rate_limiter
node_rate_limiter -->|"stores counters"| node_redis
node_protected -->|"proxies authorized requests"| node_proxy
node_proxy -->|"forwards profile"| node_user_service
node_proxy -->|"forwards data"| node_data_service
node_audit_middleware -.->|"records outcome"| node_audit_service
node_audit_service -->|"persists records"| node_database_config
node_auth_routes -->|"protects profile"| node_authenticate
node_database_config -.->|"connects to"| node_postgres
node_policy_routes -.->|"manages policies"| node_policy_service
node_audit_routes -.->|"queries records"| node_audit_service

click node_dashboard "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/dashboard/src/App.tsx"
click node_app "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/app.ts"
click node_auth_routes "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/auth.ts"
click node_auth_service "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/authService.ts"
click node_jwt "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/utils/jwt.ts"
click node_authenticate "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/authenticate.ts"
click node_protected "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/protected.ts"
click node_authorize "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/authorize.ts"
click node_policy_service "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/policyService.ts"
click node_rate_limiter "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/rateLimiter.ts"
click node_proxy "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/proxyService.ts"
click node_audit_middleware "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/audit.ts"
click node_audit_routes "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/audit.ts"
click node_policy_routes "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/policy.ts"
click node_audit_service "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/auditService.ts"
click node_user_service "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/user-service/src/index.ts"
click node_data_service "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/data-service/src/index.ts"
click node_postgres "https://github.com/shashank832832/zero-trust-edge/blob/main/prisma/schema.prisma"
click node_database_config "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/config/database.ts"
click node_redis "https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/config/redis.ts"

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_actor toneBlue
class node_app,node_auth_routes,node_auth_service,node_jwt,node_authenticate,node_protected,node_authorize,node_rate_limiter,node_proxy toneAmber
class node_policy_service,node_audit_middleware,node_audit_routes,node_policy_routes,node_audit_service toneMint
class node_user_service,node_data_service toneRose
class node_postgres,node_database_config,node_redis toneIndigo
```

## Components

### Client Experience

- [Security Dashboard](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/dashboard/src/App.tsx): `apps/dashboard/src/App.tsx`

### Gateway Security

- [Gateway App](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/app.ts): `apps/gateway/src/app.ts`
- [Auth Routes](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/auth.ts): `apps/gateway/src/routes/auth.ts`
- [Identity Service](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/authService.ts): `apps/gateway/src/services/authService.ts`
- [JWT Utilities](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/utils/jwt.ts): `apps/gateway/src/utils/jwt.ts`
- [JWT Authentication](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/authenticate.ts): `apps/gateway/src/middleware/authenticate.ts`
- [Protected Routes](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/protected.ts): `apps/gateway/src/routes/protected.ts`
- [Policy Authorization](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/authorize.ts): `apps/gateway/src/middleware/authorize.ts`
- [Rate Limiter](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/rateLimiter.ts): `apps/gateway/src/middleware/rateLimiter.ts`
- [Identity Proxy](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/proxyService.ts): `apps/gateway/src/services/proxyService.ts`

### Policy and Audit

- [Policy Engine](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/policyService.ts): `apps/gateway/src/services/policyService.ts`
- [Outcome Auditing](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/middleware/audit.ts): `apps/gateway/src/middleware/audit.ts`
- [Audit Queries](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/audit.ts): `apps/gateway/src/routes/audit.ts`
- [Policy Management](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/routes/policy.ts): `apps/gateway/src/routes/policy.ts`
- [Audit Persistence](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/services/auditService.ts): `apps/gateway/src/services/auditService.ts`

### Internal Services

- [User Service](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/user-service/src/index.ts): `apps/user-service/src/index.ts`
- [Data Service](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/data-service/src/index.ts): `apps/data-service/src/index.ts`

### Gateway State

- [PostgreSQL](https://github.com/shashank832832/zero-trust-edge/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Database Client](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/config/database.ts): `apps/gateway/src/config/database.ts`
- [Redis](https://github.com/shashank832832/zero-trust-edge/blob/main/apps/gateway/src/config/redis.ts): `apps/gateway/src/config/redis.ts`

### Other components

- **Client**

## Connections

- Client → Security Dashboard: uses (evidence: `apps/dashboard/src/App.tsx`)
- Security Dashboard → Gateway App: calls gateway (evidence: `apps/dashboard/src/App.tsx`)
- Gateway App → Auth Routes: mounts (evidence: `apps/gateway/src/app.ts`)
- Gateway App → Protected Routes: mounts (evidence: `apps/gateway/src/app.ts`)
- Gateway App → Policy Management: mounts (evidence: `apps/gateway/src/app.ts`)
- Gateway App → Audit Queries: mounts (evidence: `apps/gateway/src/app.ts`)
- Gateway App → Outcome Auditing: runs for API (evidence: `apps/gateway/src/app.ts`)
- Auth Routes → Identity Service: calls (evidence: `apps/gateway/src/routes/auth.ts`)
- Identity Service → Database Client: uses client (evidence: `apps/gateway/src/services/authService.ts`)
- Identity Service → JWT Utilities: issues tokens (evidence: `apps/gateway/src/services/authService.ts`)
- JWT Authentication → JWT Utilities: verifies token
- Protected Routes → JWT Authentication: authenticates (evidence: `apps/gateway/src/routes/protected.ts`)
- Protected Routes → Policy Authorization: authorizes (evidence: `apps/gateway/src/routes/protected.ts`)
- Policy Authorization → Policy Engine: evaluates policy (evidence: `apps/gateway/src/middleware/authorize.ts`)
- Policy Engine → Database Client: reads policies (evidence: `apps/gateway/src/services/policyService.ts`)
- Protected Routes → Rate Limiter: limits requests (evidence: `apps/gateway/src/routes/protected.ts`)
- Rate Limiter → Redis: stores counters (evidence: `README.md`)
- Protected Routes → Identity Proxy: proxies authorized requests (evidence: `apps/gateway/src/routes/protected.ts`)
- Identity Proxy → User Service: forwards profile (evidence: `README.md`)
- Identity Proxy → Data Service: forwards data (evidence: `README.md`)
- Outcome Auditing → Audit Persistence: records outcome
- Audit Persistence → Database Client: persists records (evidence: `apps/gateway/src/services/auditService.ts`)
- Auth Routes → JWT Authentication: protects profile (evidence: `apps/gateway/src/routes/auth.ts`)
- Database Client → PostgreSQL: connects to (evidence: `README.md`)
- Policy Management → Policy Engine: manages policies
- Audit Queries → Audit Persistence: queries records
