Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Service Badge Services

dev-mondoshawan edited this page Apr 16, 2026 · 1 revision

Service - Badge Services

**Referenced Files in This Document** - [backend/src/services/badgeBuilder.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/services/badgeBuilder.js) - [backend/src/routes/badge.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/routes/badge.js) - [backend/src/routes/widget.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/routes/widget.js) - [backend/src/models/redis.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/models/redis.js) - [backend/src/config/index.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/config/index.js) - [backend/src/utils/transform.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/utils/transform.js) - [backend/server.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/server.js) - [frontend/src/components/TrustBadge.jsx](https://github.com/RunTimeAdmin/AgentID/blob/main/frontend/src/components/TrustBadge.jsx) - [frontend/src/widget/Widget.jsx](https://github.com/RunTimeAdmin/AgentID/blob/main/frontend/src/widget/Widget.jsx) - [agentid_build_plan.md](https://github.com/RunTimeAdmin/AgentID/blob/main/agentid_build_plan.md)

Table of Contents

  1. Introduction
  2. Project Structure
  3. Core Components
  4. Architecture Overview
  5. Detailed Component Analysis
  6. Dependency Analysis
  7. Performance Considerations
  8. Troubleshooting Guide
  9. Conclusion
  10. Appendices

Introduction

This document explains the AgentID badge services that power trust badges, SVG generation, and widget rendering.

Project Structure

The badge services span backend and frontend:

  • Backend exposes badge JSON, SVG, and widget endpoints
  • Frontend provides React TrustBadge component and standalone widget
graph TB
subgraph "Backend"
S["Server<br/>server.js"]
R1["Routes<br/>routes/badge.js"]
R2["Routes<br/>routes/widget.js"]
B["Badge Builder<br/>services/badgeBuilder.js"]
C["Config<br/>config/index.js"]
D["Redis Cache<br/>models/redis.js"]
T["Transform Utils<br/>utils/transform.js"]
end
subgraph "Frontend"
F1["TrustBadge Component<br/>frontend/src/components/TrustBadge.jsx"]
F2["Widget App<br/>frontend/src/widget/Widget.jsx"]
end
S --> R1
S --> R2
R1 --> B
R2 --> B
B --> D
B --> C
B --> T
F2 --> F1
Loading

Core Components

  • Badge Builder service: Computes reputation, constructs badge JSON, generates SVG
  • Routes: Expose endpoints for badge JSON, SVG, and widget HTML
  • Redis cache: Stores badge JSON with TTL
  • Frontend TrustBadge: Renders compact badge UI
  • Frontend Widget: Standalone embeddable widget

Architecture Overview

The badge pipeline:

  1. Request arrives at route endpoint
  2. Route delegates to badgeBuilder service
  3. badgeBuilder retrieves agent data, computes reputation
  4. Results cached in Redis
  5. For SVG/widget, generates markup and returns

Detailed Component Analysis

Badge Builder Service

Responsibilities:

  • Compute reputation and derive status
  • Build badge JSON with metadata
  • Generate SVG with dynamic colors
  • Produce HTML widget with auto-refresh

Routes: Badge and Widget

  • GET /badge/:pubkey → JSON
  • GET /badge/:pubkey/svg → SVG
  • GET /widget/:pubkey → HTML widget

Frontend Components

TrustBadge

  • Props: status, name, score, registeredAt, totalActions
  • Status-dependent styling

Widget Application

  • Standalone React app in iframe
  • Auto-refreshes every 60 seconds
  • Themed CSS with glow effects

Dependency Analysis

  • badgeBuilder depends on queries, reputation service, redis, config
  • Routes depend on badgeBuilder and rate limiting
  • Frontend widget depends on axios

Performance Considerations

  • Caching: Badge JSON cached with TTL
  • Rate limiting: Protects backend resources
  • Rendering: SVG generated server-side
  • Auto-refresh: Widget refreshes every 60s

Troubleshooting Guide

  • Agent not found: Returns 404
  • Redis connectivity: Graceful fallback
  • XSS prevention: HTML/XML escaping
  • Widget loading: Skeleton while loading

Conclusion

The badge services provide a robust, cache-backed pipeline for generating trust badges in JSON, SVG, and HTML formats.

Appendices

Configuration Options

  • Cache TTL: Badge cache duration
  • Base URL: Widget URL construction
  • Redis URL: Caching connection

Customization

  • Status theming: green (verified), red (flagged), amber (unverified)
  • SVG colors derived from status
  • Widget theme via CSS variables

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /