Logo di Software Architecture

Software Architecture

Community
sabahattink
software-architecture

System design patterns, Clean Architecture, SOLID principles, domain modeling. Use when making architectural decisions, designing new modules, refactoring a tangled codebase, or reviewing system design.

Panoramica

Pubblicato dasabahattink
Repositoryantigravity-fullstack-hq
Nome della skillsoftware-architecture
Stelle
31
Fork
9
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da sabahattink su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Software Architecture in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/sabahattink/antigravity-fullstack-hq/tree/main/skills/software-architecture
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/sabahattink/antigravity-fullstack-hq.git /tmp/antigravity-fullstack-hq
mkdir -p .claude/skills
cp -r /tmp/antigravity-fullstack-hq/skills/software-architecture .claude/skills/software-architecture
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Software Architecture in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Software Architecture non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Software Architecture non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Software Architecture

Clean Architecture Layers

┌─────────────────────────────────────────────┐
│              Frameworks & Drivers           │  ← NestJS, TypeORM, Express
├─────────────────────────────────────────────┤
│           Interface Adapters                │  ← Controllers, Repositories, Presenters
├─────────────────────────────────────────────┤
│            Application Layer                │  ← Use Cases, Application Services
├─────────────────────────────────────────────┤
│              Domain Layer                   │  ← Entities, Value Objects, Domain Services
└─────────────────────────────────────────────┘

Dependency Rule: outer layers depend on inner layers — NEVER the reverse.

Domain Layer

Entities

typescript
// domain/user/user.entity.ts
// Entities contain identity and business rules. No framework dependencies.

export class User {
  private constructor(
    public readonly id: UserId,
    public readonly email: Email,
    private _name: string,
    private _role: UserRole,
    public readonly createdAt: Date,
  ) {}

  static create(props: {
    id: UserId
    email: Email
    name: string
    role?: UserRole
  }): User {
    if (!props.name.trim()) {
      throw new DomainError('Name cannot be empty')
    }
    return new User(
      props.id,
      props.email,
      props.name.trim(),
      props.role ?? UserRole.USER,
      new Date(),
    )
  }

  get name(): string { return this._name }
  get role(): UserRole { return this._role }

  rename(newName: string): User {
    if (!newName.trim()) throw new DomainError('Name cannot be empty')
    // Return new instance — immutability
    return new User(this.id, this.email, newName.trim(), this._role, this.createdAt)
  }

  promote(to: UserRole, by: User): User {
    if (by.role !== UserRole.ADMIN) {
      throw new DomainError('Only admins can promote users')
    }
    return new User(this.id, this.email, this._name, to, this.createdAt)
  }
}

Value Objects

typescript
// domain/shared/value-objects/email.vo.ts
export class Email {
  private constructor(public readonly value: string) {}

  static create(raw: string): Email {
    const normalized = raw.toLowerCase().trim()
    if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalized)) {
      throw new DomainError(`Invalid email: ${raw}`)
    }
    return new Email(normalized)
  }

  equals(other: Email): boolean {
    return this.value === other.value
  }

  toString(): string {
    return this.value
  }
}

// domain/shared/value-objects/money.vo.ts
export class Money {
  private constructor(
    public readonly amount: number,  // in cents
    public readonly currency: string,
  ) {}

  static of(amount: number, currency: string): Money {
    if (amount < 0) throw new DomainError('Amount cannot be negative')
    if (!['USD', 'EUR', 'GBP', 'TRY'].includes(currency)) {
      throw new DomainError(`Unsupported currency: ${currency}`)
    }
    return new Money(Math.round(amount), currency)
  }

  add(other: Money): Money {
    if (this.currency !== other.currency) {
      throw new DomainError('Cannot add different currencies')
    }
    return Money.of(this.amount + other.amount, this.currency)
  }

  format(): string {
    return new Intl.NumberFormat('en-US', {
      style: 'currency',
      currency: this.currency,
    }).format(this.amount / 100)
  }
}

Domain Events

typescript
// domain/shared/domain-event.ts
export abstract class DomainEvent {
  public readonly occurredAt: Date
  public readonly eventId: string

  constructor(
    public readonly aggregateId: string,
    public readonly eventType: string,
  ) {
    this.occurredAt = new Date()
    this.eventId    = crypto.randomUUID()
  }
}

// domain/user/events/user-created.event.ts
export class UserCreatedEvent extends DomainEvent {
  constructor(
    public readonly userId: string,
    public readonly email: string,
    public readonly name: string,
  ) {
    super(userId, 'user.created')
  }
}

Application Layer

Use Cases (Command/Query pattern)

typescript
// application/users/commands/create-user/create-user.command.ts
export class CreateUserCommand {
  constructor(
    public readonly email: string,
    public readonly password: string,
    public readonly name: string,
    public readonly actorId: string,
  ) {}
}

// application/users/commands/create-user/create-user.handler.ts
import { CommandHandler, ICommandHandler, EventBus } from '@nestjs/cqrs'

@CommandHandler(CreateUserCommand)
export class CreateUserHandler implements ICommandHandler<CreateUserCommand> {
  constructor(
    private readonly userRepo:     IUserRepository,
    private readonly hasher:       IPasswordHasher,
    private readonly eventBus:     EventBus,
  ) {}

  async execute(cmd: CreateUserCommand): Promise<UserId> {
    const email = Email.create(cmd.email)

    const exists = await this.userRepo.existsByEmail(email)
    if (exists) throw new ConflictException('Email already in use')

    const passwordHash = await this.hasher.hash(cmd.password)
    const userId       = UserId.generate()

    const user = User.create({
      id:    userId,
      email,
      name:  cmd.name,
      passwordHash,
    })

    await this.userRepo.save(user)
    this.eventBus.publish(new UserCreatedEvent(userId.value, email.value, cmd.name))

    return userId
  }
}

Repository Pattern (Interface in Domain)

typescript
// domain/user/user.repository.interface.ts
export interface IUserRepository {
  findById(id: UserId): Promise<User | null>
  findByEmail(email: Email): Promise<User | null>
  existsByEmail(email: Email): Promise<boolean>
  save(user: User): Promise<void>
  delete(id: UserId): Promise<void>
}

// infrastructure/persistence/typeorm/user.typeorm-repository.ts
@Injectable()
export class UserTypeOrmRepository implements IUserRepository {
  constructor(
    @InjectRepository(UserOrmEntity)
    private readonly ormRepo: Repository<UserOrmEntity>,
    private readonly mapper:  UserMapper,
  ) {}

  async findById(id: UserId): Promise<User | null> {
    const row = await this.ormRepo.findOne({ where: { id: id.value } })
    return row ? this.mapper.toDomain(row) : null
  }

  async save(user: User): Promise<void> {
    const row = this.mapper.toOrm(user)
    await this.ormRepo.save(row)
  }
  // ...
}

SOLID in Practice

Single Responsibility

typescript
// Bad: UserService does too much
class UserService {
  async register(dto) { /* creates user + sends email + logs audit */ }
  async updateProfile(dto) { /* validates + updates + notifies */ }
  async generateReport() { /* queries DB + formats CSV + sends email */ }
}

// Good: each class has one reason to change
class UserRegistrationService { /* only: validate, create, emit event */ }
class EmailNotificationService { /* only: send emails */ }
class AuditLogService { /* only: write audit entries */ }
class UserReportService { /* only: query, format, export */ }

Open/Closed

typescript
// Open for extension, closed for modification
interface NotificationChannel {
  send(message: NotificationMessage): Promise<void>
}

class EmailChannel implements NotificationChannel { /* ... */ }
class SmsChannel   implements NotificationChannel { /* ... */ }
class SlackChannel implements NotificationChannel { /* ... */ }

class NotificationService {
  constructor(private channels: NotificationChannel[]) {}

  // No modification needed when adding a new channel
  async notify(message: NotificationMessage) {
    await Promise.all(this.channels.map(c => c.send(message)))
  }
}

Dependency Inversion

typescript
// Domain doesn't depend on infrastructure
// Bad:
class OrderService {
  private repo = new TypeOrmOrderRepository() // concrete dep!
}

// Good:
@Injectable()
class OrderService {
  constructor(
    @Inject(ORDER_REPOSITORY_TOKEN)
    private readonly repo: IOrderRepository, // interface dep
  ) {}
}

Module Design

typescript
// users/users.module.ts
@Module({
  imports: [
    TypeOrmModule.forFeature([UserOrmEntity]),
    CqrsModule,
    ConfigModule,
  ],
  controllers: [UsersController],
  providers: [
    // Application
    CreateUserHandler,
    GetUserQueryHandler,
    // Domain services
    UserDomainService,
    // Infrastructure adapters
    {
      provide:  IUserRepository,   // injection token
      useClass: UserTypeOrmRepository,
    },
    {
      provide:  IPasswordHasher,
      useClass: BcryptPasswordHasher,
    },
  ],
  exports: [IUserRepository],  // only export what other modules need
})
export class UsersModule {}

Event-Driven Architecture

typescript
// Sagas coordinate cross-module workflows
@Injectable()
export class UserOnboardingSaga {
  @Saga()
  userCreated = (events$: Observable<unknown>): Observable<ICommand> => {
    return events$.pipe(
      ofType(UserCreatedEvent),
      map(event => new SendWelcomeEmailCommand(event.email, event.name)),
    )
  }
}

ADR (Architecture Decision Record) Template

markdown
# ADR-001: Use CQRS Pattern for Write-Heavy Modules

## Status
Accepted

## Context
Orders and inventory modules have complex write operations with multiple side effects.
Read and write models diverge significantly.

## Decision
Adopt CQRS using @nestjs/cqrs for these modules.
Simple CRUD modules (users, settings) remain using direct service calls.

## Consequences
+ Clear separation of read/write models
+ Easier to add event sourcing later
+ Better testability via command/query handlers
- Higher initial complexity
- Two data models to maintain in some cases

Forbidden Patterns

  • Never have circular dependencies between modules — restructure into shared modules
  • Never access the database from the domain layer — only through repository interfaces
  • Never put I/O (HTTP, DB, file system) in domain entities or value objects
  • Never use static mutable state in services — it breaks testability and concurrency
  • Never expose ORM entities directly to the API layer — map to DTOs
  • Never put business rules in controllers — they belong in the domain or application layer
  • Never use inheritance where composition would work — prefer interfaces and DI

Domande frequenti

Cosa fa la skill IA Software Architecture?

System design patterns, Clean Architecture, SOLID principles, domain modeling. Use when making architectural decisions, designing new modules, refactoring a tangled codebase, or reviewing system design.

Perché usare Software Architecture su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Software Architecture è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Software Architecture in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/sabahattink/antigravity-fullstack-hq/tree/main/skills/software-architecture. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Software Architecture?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Software Architecture?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Software Architecture: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Software Architecture è gratuita?

Sì. È pubblicata su GitHub da sabahattink con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇