Back to skills
SKILL.md
Collection
ASecurityMicroservices architecture for Tzurot v3 - Service boundaries, responsibilities, dependency rules, and anti-patterns from v2. Use when deciding where code belongs or designing new features.
- 24 stars
- 0 votes
- 0 copies
- 5 views
- Added September 8, 2026
Works with
Security analysis
100/100Pro scans all 21 files and shows the line behind each finding
npx -y skills add mattnigh/skills_collection --skill collection --agent claude-codeAre you the author of Collection?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mattnigh-collection-9bf74761)---
name: tzurot-architecture
description: Microservices architecture for Tzurot v3 - Service boundaries, responsibilities, dependency rules, and anti-patterns from v2. Use when deciding where code belongs or designing new features.
lastUpdated: '2025-12-20'
---
# Tzurot v3 Architecture
**Use this skill when:** Adding new features, deciding where code belongs, designing system interactions, or refactoring service boundaries.
## Quick Reference
```
Discord User
↓
bot-client (Discord.js)
↓ HTTP
api-gateway (Express + BullMQ)
↓ Redis Queue
ai-worker (AI + pgvector)
↓
OpenRouter/Gemini API
```
## Core Principles
1. **Simple, clean classes** - No DDD over-engineering (learned from v2)
2. **Clear service boundaries** - Each service has single responsibility
3. **No circular dependencies** - Services can't import from each other
4. **Shared code in common-types** - Cross-service types, utils, services
5. **Constructor injection** - Simple dependency passing, no DI containers
## Three Microservices
| Service | Responsibility | Does | Does NOT |
| --------------- | ----------------- | -------------------------------------- | ----------------------------------- |
| **bot-client** | Discord interface | Events, webhooks, commands, formatting | Business logic, AI calls, direct DB |
| **api-gateway** | HTTP API + queue | Endpoints, validation, job creation | AI processing, Discord interaction |
| **ai-worker** | AI + memory | Jobs, memory, AI calls, embeddings | HTTP endpoints, Discord interaction |
## Where to Put New Code
| Type | Location |
| -------------------------- | ---------------------- |
| Webhook/message formatting | `bot-client/` |
| Slash commands | `bot-client/commands/` |
| HTTP endpoints | `api-gateway/routes/` |
| Job creation | `api-gateway/queue.ts` |
| AI provider clients | `ai-worker/providers/` |
| Memory/embeddings | `ai-worker/services/` |
| Shared types/constants | `common-types/` |
| Discord type guards | `common-types/types/` |
## Autocomplete Utilities (CRITICAL)
**ALWAYS check for existing utilities before writing autocomplete handlers.**
Available in `bot-client/src/utils/autocomplete/`:
| Utility | Purpose | Option Names |
| ------------------------------- | ------------------------- | -------------------------- |
| `handlePersonalityAutocomplete` | Personality selection | `personality`, `character` |
| `handlePersonaAutocomplete` | Profile/persona selection | `profile`, `persona` |
```typescript
// ✅ GOOD - Delegate to shared utility
import { handlePersonalityAutocomplete } from '../../utils/autocomplete/personalityAutocomplete.js';
await handlePersonalityAutocomplete(interaction, {
optionName: 'personality',
showVisibility: true,
ownedOnly: false,
});
// ❌ BAD - Duplicating 50+ lines of autocomplete logic
```
## Error Message Patterns
| Layer | Pattern | Example |
| --------------- | --------------------- | ---------------------------------------------------------- |
| **api-gateway** | Clean JSON, NO emojis | `{ "error": "NOT_FOUND", "message": "Persona not found" }` |
| **bot-client** | ADD emojis for users | `'❌ Profile not found.'` |
```typescript
// ✅ Gateway - clean for programmatic use
sendError(res, ErrorResponses.notFound('Persona'));
// ✅ Bot - emoji for users
await interaction.editReply({ content: '❌ Profile not found.' });
```
## Anti-Patterns from v2 (DON'T DO)
| Pattern | Why Not | v3 Alternative |
| ------------------------------------------- | --------------- | ---------------------------- |
| Generic `IRepository<T>` | Too abstract | Concrete service methods |
| DI containers | Over-engineered | Direct instantiation |
| `Controller→UseCase→Service→Repository→ORM` | Too many layers | `Route→Service→Prisma` |
| Complex event bus | Unnecessary | Redis pub/sub for cache only |
| Value objects everywhere | Overhead | Simple validation functions |
```typescript
// ❌ v2 - Container hell
container.bind('PersonalityService').to(PersonalityService);
const service = container.get('PersonalityService');
// ✅ v3 - Simple
const service = new PersonalityService(prisma);
```
## Dependency Injection
```typescript
// ✅ GOOD - Simple constructor injection
class MyService {
constructor(
private prisma: PrismaClient,
private redis: Redis
) {}
}
const service = new MyService(prisma, redis);
```
## When to Extract a Service
**Extract when:**
- Shared across multiple microservices → common-types
- Complex business logic
- Stateful operations
- Easier testability needed
**Keep inline when:**
- Used in one place only
- Stateless utility function
- Very simple logic
## Database Access
**Direct Prisma in services** - No repository pattern
```typescript
// ✅ Direct Prisma
async getPersonality(id: string) {
return this.prisma.personality.findUnique({ where: { id } });
}
// ❌ Generic repository
interface PersonalityRepository {
findById(id: string): Promise<Personality>;
}
```
## Configuration
- **Environment variables**: Secrets (tokens, DB URLs)
- **common-types constants**: Application config (timeouts, limits)
```typescript
import { TIMEOUTS, RETRY_CONFIG } from '@tzurot/common-types';
const timeout = TIMEOUTS.LLM_INVOCATION;
```
## Related Skills
- **tzurot-async-flow** - BullMQ job patterns
- **tzurot-db-vector** - Database patterns
- **tzurot-types** - Type definitions
- **tzurot-gemini-collab** - Major design decisions
## References
- Full architecture: `CLAUDE.md#architecture`
- Project structure: `CLAUDE.md#project-structure`
- Architecture decisions: `docs/architecture/ARCHITECTURE_DECISIONS.md`
Files in this skill
- 0Chan-smc__claude-code-workflow-lab__claude__skills__frontend-dev-guidelines__SKILL.md
- 17hz__nextjs-template__claude__skills__example-skill__SKILL.md
- 1ambda__dataops-platform__claude__skills__context-synthesis__SKILL.md
- 1natsu172__dotfiles__claude__skills__git-analysis__SKILL.md
- 1natsu172__dotfiles__claude__skills__github-pr-best-practices__SKILL.md
- 23Maestro__prospect-pipeline__claude__skills__npid-fastapi-skill.md
- 360AYA25__ClaudeN8N__claude__skills__n8n-code-javascript__SKILL.md
- 360AYA25__ClaudeN8N__claude__skills__n8n-code-python__SKILL.md
- 360AYA25__ClaudeN8N__claude__skills__n8n-expression-syntax__SKILL.md
- 360AYA25__ClaudeN8N__claude__skills__n8n-mcp-tools-expert__SKILL.md
- 360AYA25__ClaudeN8N__claude__skills__n8n-node-configuration__SKILL.md
- 360AYA25__ClaudeN8N__claude__skills__n8n-workflow-patterns__SKILL.md
- 3x-Projetos__claude-memory-framework__claude__skills__scientist__SKILL.md
- 5MinFutures__futures-arena__claude__skills__migration-tracker__SKILL.md
- 5MinFutures__futures-arena__claude__skills__planning-guidelines__SKILL.md
- 92Bilal26__TaskPilotAI__claude__skills__assessment-builder__SKILL.md
- 92Bilal26__TaskPilotAI__claude__skills__book-scaffolding__SKILL.md
- 92Bilal26__TaskPilotAI__claude__skills__code-validation-sandbox__SKILL.md
- 92Bilal26__TaskPilotAI__claude__skills__exercise-designer__SKILL.md
- 92Bilal26__TaskPilotAI__claude__skills__learning-objectives__SKILL.md
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.