Backend Expert
The Backend Expert agent specializes in server-side development, APIs, and backend architecture.
Expertise Areas#
- Node.js/Express - Server setup, middleware, routing
- API Design - REST, GraphQL, tRPC, WebSockets
- Authentication - JWT, OAuth, sessions, API keys
- Database Integration - ORMs, query builders, raw SQL
- Caching - Redis, in-memory, CDN strategies
- Background Jobs - Queues, workers, scheduled tasks
- Error Handling - Logging, monitoring, graceful failures
Usage Examples#
Creating APIs#
Use the backend-expert agent to create a RESTful API for a blog with:
- CRUD operations for posts
- Authentication middleware
- Input validation
- Error handling
Response includes:
- Route definitions
- Controller logic
- Middleware setup
- Validation schemas
- Error handlers
Authentication Implementation#
Use the backend-expert agent to implement JWT authentication with refresh tokens.
Response includes:
- Token generation
- Refresh token rotation
- Middleware protection
- Secure cookie handling
Database Integration#
Use the backend-expert agent to set up Prisma with PostgreSQL including connection pooling.
Response includes:
- Prisma configuration
- Schema setup
- Connection management
- Transaction handling
Best Practices Applied#
1. Security#
- Input validation and sanitization
- SQL injection prevention
- Rate limiting
- CORS configuration
- Secure headers
2. Error Handling#
- Centralized error handling
- Structured error responses
- Logging strategies
- Graceful degradation
3. Performance#
- Connection pooling
- Query optimization
- Response compression
- Caching strategies
4. Architecture#
- Separation of concerns
- Dependency injection
- Service layer patterns
- Repository patterns
Common Patterns#
Express App Structure#
src/
├── controllers/ # Request handlers
├── services/ # Business logic
├── repositories/ # Data access
├── middleware/ # Custom middleware
├── routes/ # Route definitions
├── utils/ # Helpers
├── types/ # TypeScript types
└── app.ts # App setup
Controller Pattern#
1// controllers/users.controller.ts
2export class UsersController {
3 constructor(private usersService: UsersService) {}
4
5 async getAll(req: Request, res: Response) {
6 const users = await this.usersService.findAll();
7 res.json({ data: users });
8 }
9
10 async getById(req: Request, res: Response) {
11 const user = await this.usersService.findById(req.params.id);
12 if (!user) {
13 throw new NotFoundError('User not found');
14 }
15 res.json({ data: user });
16 }
17}Middleware Chain#
1router.post('/posts',
2 authenticate, // Verify JWT
3 authorize('admin'), // Check permissions
4 validate(createPostSchema), // Validate input
5 rateLimiter, // Rate limiting
6 postsController.create // Handle request
7);Framework Support#
Express.js#
- Middleware patterns
- Error handling
- Route organization
- Security middleware
Fastify#
- Plugin architecture
- Schema validation
- Serialization
- Hooks system
NestJS#
- Modules and providers
- Decorators
- Guards and interceptors
- Dependency injection
Hono#
- Edge-first design
- Middleware chaining
- Multi-runtime support
API Design Patterns#
RESTful Resources#
GET /api/posts # List all posts
GET /api/posts/:id # Get single post
POST /api/posts # Create post
PUT /api/posts/:id # Update post
DELETE /api/posts/:id # Delete post
Response Structure#
1{
2 "data": { ... },
3 "meta": {
4 "page": 1,
5 "perPage": 20,
6 "total": 100
7 },
8 "links": {
9 "self": "/api/posts?page=1",
10 "next": "/api/posts?page=2"
11 }
12}Error Response#
1{
2 "error": {
3 "code": "VALIDATION_ERROR",
4 "message": "Invalid input",
5 "details": [
6 { "field": "email", "message": "Invalid email format" }
7 ]
8 }
9}Sample Prompts#
| Task | Prompt |
|---|---|
| API endpoint | "Create a paginated endpoint for fetching orders" |
| Auth middleware | "Build JWT verification middleware with role checking" |
| File upload | "Implement secure file upload with S3 storage" |
| Webhooks | "Create a webhook handler with signature verification" |
| Rate limiting | "Add rate limiting with Redis backend" |
Configuration#
1// bootspring.config.js
2module.exports = {
3 agents: {
4 customInstructions: {
5 'backend-expert': `
6 - Use async/await for all async operations
7 - Include comprehensive error handling
8 - Follow REST API conventions
9 - Add request validation
10 - Include logging for debugging
11 `,
12 },
13 },
14 skills: {
15 preferred: {
16 api: 'rest',
17 validation: 'zod',
18 orm: 'prisma',
19 },
20 },
21};Related Agents#
- Database Expert - Database design and optimization
- API Expert - API design patterns
- Security Expert - Authentication and security