-
Notifications
You must be signed in to change notification settings - Fork 0
Developer Guidelines
dev-mondoshawan edited this page Apr 16, 2026
·
1 revision
**Referenced Files in This Document**
- [backend/src/middleware/rateLimit.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/middleware/rateLimit.js)
- [backend/src/middleware/errorHandler.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/middleware/errorHandler.js)
- [backend/src/models/db.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/models/db.js)
- [backend/src/models/queries.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/models/queries.js)
- [backend/src/services/badgeBuilder.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/services/badgeBuilder.js)
- [backend/src/utils/transform.js](https://github.com/RunTimeAdmin/AgentID/blob/main/backend/src/utils/transform.js)
- Introduction
- Code Style
- Naming Conventions
- Error Handling
- Security Practices
- Performance Guidelines
- Documentation Standards
These guidelines ensure consistency, maintainability, and quality across the AgentID codebase. All contributors should follow these standards.
- Use ES6+ features (async/await, destructuring, arrow functions)
- Prefer
constandletovervar - Use semicolons consistently
- 2-space indentation
- Max line length: 100 characters
- Functional components with hooks
- PropTypes for type checking
- Destructure props in component parameters
- Use TailwindCSS utility classes
- Routes:
kebab-case.js(e.g.,agents.js,badge.js) - Services:
camelCase.js(e.g.,bagsAuthVerifier.js) - Components:
PascalCase.jsx(e.g.,TrustBadge.jsx)
- Constants:
UPPER_SNAKE_CASE - Functions:
camelCase - Classes:
PascalCase - Private methods:
_camelCase(prefix with underscore)
- Tables:
snake_case(e.g.,agent_identities) - Columns:
snake_case(e.g.,registered_at) - Primary keys:
idor{table}_id - Foreign keys:
{referenced_table}_id
Always use try-catch blocks and pass errors to the next middleware:
try {
const result = await someAsyncOperation();
res.json(result);
} catch (error) {
next(error);
}The global error handler will:
- Log errors with context
- Return appropriate HTTP status codes
- Sanitize error messages in production
Use error boundaries and handle API errors gracefully:
try {
const data = await api.getAgent(pubkey);
setAgent(data);
} catch (error) {
setError(error.message);
}- Validate all user inputs
- Use parameterized queries (never string concatenation)
- Sanitize data before rendering
- Verify Ed25519 signatures for sensitive operations
- Use nonces to prevent replay attacks
- Implement rate limiting on all endpoints
- Never log sensitive data (API keys, private keys)
- Use environment variables for secrets
- Enable HTTPS in production
- Use indexes on frequently queried columns
- Implement connection pooling
- Use pagination for large result sets
- Cache badge data with appropriate TTL
- Use Redis for distributed caching
- Invalidate cache on data updates
- Lazy load components when possible
- Optimize images and assets
- Minimize re-renders with React.memo
Document all public functions:
/**
* Computes the Bags reputation score for an agent
* @param {string} pubkey - Agent's public key
* @returns {Promise<Object>} Score data with breakdown
* @throws {Error} If agent not found
*/
async function computeBagsScore(pubkey) {
// implementation
}Each major directory should have a README explaining:
- Purpose of the directory
- Key files and their roles
- Usage examples
Update wiki pages when:
- Adding new API endpoints
- Changing architecture
- Modifying deployment procedures