How shashank832832/zero-trust-edge works
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: app.ts Gateway App · protected.ts Protected Routes · database.ts Database Client · auth.ts Auth Routes
Components 21
Client Experience
- Security Dashboard
apps/dashboard/src/App.tsx
Gateway Security
- Gateway App
apps/gateway/src/app.ts - Auth Routes
apps/gateway/src/routes/auth.ts - Identity Service
apps/gateway/src/services/authService.ts - JWT Utilities
apps/gateway/src/utils/jwt.ts - JWT Authentication
apps/gateway/src/middleware/authenticate.ts - Protected Routes
apps/gateway/src/routes/protected.ts - Policy Authorization
apps/gateway/src/middleware/authorize.ts - Rate Limiter
apps/gateway/src/middleware/rateLimiter.ts - Identity Proxy
apps/gateway/src/services/proxyService.ts
Policy and Audit
- Policy Engine
apps/gateway/src/services/policyService.ts - Outcome Auditing
apps/gateway/src/middleware/audit.ts - Audit Queries
apps/gateway/src/routes/audit.ts - Policy Management
apps/gateway/src/routes/policy.ts - Audit Persistence
apps/gateway/src/services/auditService.ts
Internal Services
- User Service
apps/user-service/src/index.ts - Data Service
apps/data-service/src/index.ts
Gateway State
- PostgreSQL
prisma/schema.prisma - Database Client
apps/gateway/src/config/database.ts - Redis
apps/gateway/src/config/redis.ts
Other components
- Client
Connections 26
- Client → Security Dashboard: uses
apps/dashboard/src/App.tsx - Security Dashboard → Gateway App: calls gateway
apps/dashboard/src/App.tsx - Gateway App → Auth Routes: mounts
apps/gateway/src/app.ts - Gateway App → Protected Routes: mounts
apps/gateway/src/app.ts - Gateway App → Policy Management: mounts
apps/gateway/src/app.ts - Gateway App → Audit Queries: mounts
apps/gateway/src/app.ts - Gateway App → Outcome Auditing: runs for API
apps/gateway/src/app.ts - Auth Routes → Identity Service: calls
apps/gateway/src/routes/auth.ts - Identity Service → Database Client: uses client
apps/gateway/src/services/authService.ts - Identity Service → JWT Utilities: issues tokens
apps/gateway/src/services/authService.ts - JWT Authentication → JWT Utilities: verifies token
- Protected Routes → JWT Authentication: authenticates
apps/gateway/src/routes/protected.ts - Protected Routes → Policy Authorization: authorizes
apps/gateway/src/routes/protected.ts - Policy Authorization → Policy Engine: evaluates policy
apps/gateway/src/middleware/authorize.ts - Policy Engine → Database Client: reads policies
apps/gateway/src/services/policyService.ts - Protected Routes → Rate Limiter: limits requests
apps/gateway/src/routes/protected.ts - Rate Limiter → Redis: stores counters
README.md - Protected Routes → Identity Proxy: proxies authorized requests
apps/gateway/src/routes/protected.ts - Identity Proxy → User Service: forwards profile
README.md - Identity Proxy → Data Service: forwards data
README.md - Outcome Auditing → Audit Persistence: records outcome
- Audit Persistence → Database Client: persists records
apps/gateway/src/services/auditService.ts - Auth Routes → JWT Authentication: protects profile
apps/gateway/src/routes/auth.ts - Database Client → PostgreSQL: connects to
README.md - Policy Management → Policy Engine: manages policies
- Audit Queries → Audit Persistence: queries records