How kralamoure/dofus works
Project type and purpose
• Project type: Go library / domain service package.
• Purpose: Provide domain types for Dofus entities (accounts, users, chat channels, etc.), a service layer for account-related operations, and declare a Storer interface for persistence.
Main components
a. Domain Types Layer (dofustyp package)
• Entities: AccountName, Community, Email, Gender, Hash, Nickname, Password, ChatChannel.
• Purpose: Define value objects and aggregate roots for the domain.
b. Core Domain Package (root files: account.go, user.go, store.go)
• Domain interfaces and glue code.
• Storer interface declaration (in store.go).
c. Service Layer (dofussvc package)
• Services: account‐related methods (CreateAccount, GetUser, etc.).
• Objects: dofussvc.Go orchestrates calls to domain types and Storer.
d. External Persistence / Implementation
• Out-of-tree package: dofuspg implements the Storer interface for PostgreSQL.
e. Client Code
• The importing application that calls into dofus to manage accounts.
Relationships and interactions
• The Service Layer depends on the Domain Types Layer and the Storer interface.
• The Domain Types are passed into services, validated, and manipulated.
• The Service Layer invokes Storer methods to persist or retrieve domain aggregates.
• External Persistence (e.g., dofuspg) implements Storer and interacts with a database.
• Client code calls into the Service Layer.
Architectural patterns and design principles
• Layered architecture: separation of domain types, domain interfaces, and services.
• Dependency Inversion: services depend on the Storer interface (not a concrete DB).
• Modularity: three Go packages (dofustyp, root, dofussvc).
• Single Responsibility: each package handles a distinct concern.