Database Schema Standards
Initial deployments utilize a single-data base architecture. Horizontal scaling via sharding can be implemented later based on specific requirements. Table naming follows a [module]_[feature] pattern, such as sys_user_role or blog_article_category.
Every persistent model should incorporate standard audit and metadata columns:
| Column Key | Data Type | Purpose |
|---|---|---|
entity_uuid |
BIGINT |
Primary key, auto-incrementing |
created_by |
BIGINT |
Assigned during insertion |
created_at |
DATETIME |
Timestamp upon creation |
modified_by |
BIGINT |
Updated on insert/create and edit/update |
modified_at |
DATETIME |
Refreshed during any state change |
Supplementary operational columns are frequently utilized:
| Column Key | Data Type | Purpose |
|---|---|---|
active_flag |
TINYINT(1) |
Mapped to Boolean in Java (0=inactive, 1=active) |
notes |
VARCHAR(500) |
Descriptive text area input |
display_order |
BIGINT |
Controls ascending list sequencing |
deleted_flag |
TINYINT(1) |
Soft-delete indicator, managed by framwork ORM annotations |
lock_version |
BIGINT |
Optimistic locking counter |
For hierarchical data structures, include:
hierarchy_parent:BIGINT(Set to0for root entries)path_chain:VARCHAR(255)(Stores comma-separated ancestor IDs for UI rendering)
Backend Architecture Patterns
Business capabilities should be isolated into distinct packages. Typical divisions include core utilities and integration layers. The integration layer acts solely as an API facade, routing requests to underlying service implementations without executing domain logic directly.
Directory layout for a functional unit:
[module-name]
└─ src/main/java/com/project/[module]
├─ dto // Request/Response payloads
├─ mapper // Persistence interfaces
├─ model // Database row representations
├─ service // Interface definitions
│ └─ impl // Service implementations
└─ query // Search/filter parameters
└─ resources/mapper // XML mappings
The public API gateway maintains a flattened controller structure:
[api-gateway-module]
└─ src/main/java/com/project/api
├─ config // Framework initialization settings
├─ controller // Endpoint handlers
│ ├─ internal // Administrative endpoints
│ └─ public // Shared endpoints
├─ aspect // Cross-cutting concerns
└─ scheduler // Cron task configurations
Data Type Alignment
Relational columns translate to Java primitives/reference types as follows:
| SQL Type | Java Equivalent |
|---|---|
TINYINT(1) |
Boolean |
INT, SMALLINT, MEDIUMINT |
Integer |
VARCHAR, TEXT families |
String |
DATE, TIME, TIMESTAMP |
LocalDateTime |
BIGINT |
Long |
DECIMAL, NUMERIC |
BigDecimal |
Core record classes typically extend a foundational superclass containing audit metadata:
@Getter
@Setter
public abstract class AuditableRecord implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long recordUid;
@Column(name = "created_by", updatable = false)
private Long initiatorUid;
@Column(name = "created_at", updatable = false)
private LocalDateTime registeredAt;
@Column(name = "updated_by")
private Long editorUid;
@Column(name = "updated_at")
private LocalDateTime lastModifiedAt;
}
Object Transformation Protocol
Internal persistence models remain decoupled from external contracts. All outbound traffic requires serialization into dedicated transfer objects. A centralized mapping utility handles structural translation:
public final class ObjectMapperHelper {
private static final BeanCopierRegistry copier = new BeanCopierRegistry();
public static <Target> Target convert(Source object, Class<Target> targetClass) {
if (object == null) return null;
return copier.copy(object, targetClass);
}
public static <Target> List<Target> convertBatch(Iterable<Source> sources, Class<Target> targetClass) {
List<Target> results = new ArrayList<>();
sources.forEach(src -> results.add(convert(src, targetClass)));
return results;
}
}
Frontend Organization
Client-side applications rely on standardized scaffolding. Resources are compartmentalized for clarity and maintenance:
[web-client]
├─ public // Static assets
└─ src
├─ adapters // HTTP request wrappers
├─ components // Reusable UI blocks
├─ directives // Custom HTML attributes
├─ locales // Multi-language dictionaries
├─ layouts // Shell templates
├─ routes // Navigation guard configurations
├─ stores // Global state repositories
├─ styles // Theme variables
├─ typing // TypeScript interfaces
├─ utilities // Helper functions
└─ pages // View-level containers