This document outlines the core backend entities, their relationships, and the boundaries between different modules in the Access Layer Server.
The following diagram illustrates the core entities and their relationships within the system:
erDiagram
User ||--o| CreatorProfile : "owns"
User ||--o| StellarWallet : "links"
User {
string id PK
string email
string passwordHash
string firstName
string lastName
boolean emailVerified
}
CreatorProfile {
string id PK
string userId FK
string handle
string displayName
string bio
json perks
}
StellarWallet {
string id PK
string userId FK
string address
}
IndexerDLQ {
string id PK
string jobType
json payload
string failureReason
}
AuditEvent {
string id PK
string actor
string action
string target
string targetId
json metadata
}
- User: Represents a registered user. Holds authentication and basic profile data.
- CreatorProfile: Represents the creator persona of a user. Tied to a specific handle and contains metadata like bio and perks. See Creator Data Model Reference for field-level types, constraints, and required/optional rules.
- StellarWallet: Links a user to their Stellar public address. Used for identity verification and ownership checks.
- IndexerDLQ: Stores failed indexing jobs from the Stellar blockchain for manual review or reprocessing.
- AuditEvent: A generic log for significant actions occurring in the system.
The server is organized into feature-based modules under src/modules/. Each module is responsible for its own business logic, routes, and (where applicable) data validation.
| Module | Responsibility | Primary Entities |
|---|---|---|
auth |
User registration, login, session management, and password resets. | User |
creators |
Public and private creator profile management, including stats and discovery. | CreatorProfile |
wallet |
Linking and verifying Stellar wallets. | StellarWallet |
admin |
Internal management tools and system monitoring. | All |
health |
System health checks and status monitoring. | N/A |
To ensure a maintainable and decoupled architecture, the following rules apply:
- No Direct Database Access: Modules should not directly query Prisma models belonging to other modules if a service/utility exists.
- Shared Utilities: Common logic (e.g., mail sending, logging, pagination) belongs in
src/utils/and can be used by any module. - Constants: Shared configuration and string constants belong in
src/constants/. - Types: Cross-cutting TypeScript types belong in
src/types/.
- Initialization:
src/app.tsassembles the modules and registers global middlewares. - Data Sharing: If a module needs data from another (e.g.,
creatorsneeding user info), it should use the Prisma client (which is shared) but respect the logical boundaries defined in the schema files.