Kiến trúc & Thiết kế Hệ thống
Khám phá triết lý thiết kế đằng sau Data Explorer — từ Clean Architecture đến các Design Patterns cấp cao giúp hệ thống mở rộng và bảo mật.
Hexagonal Architecture
Tách biệt Domain logic khỏi Database và UI thông qua Ports & Adapters.
Strategy Pattern
Hỗ trợ đa Database Engines mà không làm phình to bộ mã nguồn cốt lõi.
Dependency Rule
Sự phụ thuộc chỉ hướng vào bên trong (Lõi Domain), đảm bảo tính bền vững.
Cấu trúc Lớp (Deep Clean Architecture)
Luật Nghiệp vụ Tinh khiết
Chứa các Entities (Connection, User, Table) và POJO (Plain Old Java/TS Objects). Lớp này hoàn toàn không có sự phụ thuộc vào các thư viện bên ngoài như NestJS hay TypeORM. Đây là 'Trái tim' của hệ thống, nơi lưu giữ logic cốt lõi về cách một truy vấn được cấu trúc.
Điều phối Luồng (Orchestration)
Chứa các Use Cases (vd: ExecuteQueryUseCase, GetSchemaUseCase). Lớp này định nghĩa các 'Interface' (Ports) mà hạ tầng phải tuân theo. Nó đóng vai trò như một nhạc trưởng, điều phối dữ liệu đi qua các Ports mà không cần biết Adapter cụ thể phía sau là gì.
Chi tiết Triển khai (Details)
Nơi các công nghệ cụ thể 'cắm' vào hệ thống. Bao gồm PostgreSQL/MySQL/MSSQL/MongoDB drivers, AI provider runners, Prisma, và các interceptor của NestJS. Việc thêm lane AI mới hay engine mới chủ yếu diễn ra ở lớp này mà không làm vỡ Domain Core.
Nghịch đảo Phụ thuộc (Dependency Inversion)
# // Lớp Application định nghĩa "Port"
interface DatabasePort {
execute(query: string): Promise<Result>;
}
# // Lớp Infrastructure triển khai "Adapter"
@Injectable()
class PostgresAdapter implements DatabasePort {
async execute(query: string) { /* pg driver logic */ }
}
# // Dependency Injection lo việc "cắm" Adapter vào
providers: [{ provide: DatabasePort, useClass: PostgresAdapter }]
Strategy Pattern: Đa cơ sở dữ liệu
# // Định nghĩa bản hợp đồng cho mọi Database Engine
abstract class DatabaseStrategy {
abstract connect(id: string): Promise<Client>;
abstract getMetadata(schema: string): Promise<TableMetadata[]>;
abstract generateExplain(sql: string): Promise<string>;
}
# // Triển khai cụ thể
class PostgresStrategy extends DatabaseStrategy { ... }
class MySqlStrategy extends DatabaseStrategy { ... }
"Strategy Pattern cho phép chúng tôi mở rộng thêm MongoDB, một dialect SQL khác, hoặc một AI execution lane mới mà không cần viết lại toàn bộ UI."
Đồng bộ trạng thái (Zustand Topology)
Connection Slice
Quản lý danh sách DB và trạng thái kết nối active.
Tab Slice
Luồng điều phối các cửa sổ làm việc SQL độc lập.
UI/UX Slice
Toàn bộ trạng thái hiển thị (Sidebar, Panels, Modals).
Những miền chức năng lớn đang có trong repo
Backend domains
Những nhóm thư mục đáng chú ý nhất hiện tại gồm `query`, `metadata`, `nosql`, `ai`, `auth`, `otp`, `billing`, `collaboration`, `organizations`, `permissions`, `teamspaces`, `notifications`, `presence`, `redis`, `mail`, và `database-strategies`. Chúng cho thấy server đang đóng cả vai trò query engine, AI orchestration layer, và business platform.
Client surfaces
Ở phía client, các module lớn nhất hiện tại là `Query`, `NoSqlExplorer`, `Visualization`, `Explorer`, `Dashboard`, `Connection`, `Layout`, và `LandingPage`. Trên mặt page, repo còn có `DocumentationPage`, `TeamPage`, `LoginPage`, `OnboardingPage`, `BillingReturnPage`, `ERDPage`, và `VisualizePage`.
Đây là lý do docs và kiến trúc nên được đọc theo “khối chức năng” thay vì chỉ theo cây thư mục. Một thay đổi nhỏ ở AI routing hoặc team permissions có thể chạm đồng thời vào editor, assistant, billing entitlement, và UI trạng thái người dùng.
Cấu trúc thư mục theo bề mặt hiện tại
server/
├── src/
│ ├── auth/ # Auth, JWT, OAuth, session flows
│ ├── otp/ # OTP verification and email confirmation
│ ├── connections/ # Connection records + safety policies
│ ├── query/ # SQL execution và guardrails
│ ├── nosql/ # NoSQL execution, parsing, and Mongo-oriented flows
│ ├── ai/ # AI routing, prompts, provider runners
│ ├── billing/ # Plans, checkout providers, and entitlements
│ ├── collaboration/ # Comments, team activity, shared review context
│ ├── organizations/ # Organization ownership and membership flows
│ ├── permissions/ # Per-resource access control and labels
│ ├── teamspaces/ # Workspace grouping for team resources
│ ├── notifications/ # In-app notices and delivery orchestration
│ ├── presence/ # Team presence and real-time collaboration hints
│ ├── saved-queries/ # Shared saved queries
│ ├── dashboards/ # Dashboards và widgets
│ ├── database-strategies/ # Engine-specific DB strategies
│ ├── metadata/ # Schema/context builders
│ ├── redis/ # Caching and presence backing services
│ └── mail/ # Transactional email integration
client/
├── src/
│ ├── core/ # Adapters, domain entities, app services
│ ├── infrastructure/ # Infra glue cho client
│ ├── presentation/ # Pages, modules, docs, UI shell
│ │ ├── modules/ # SQL, NoSQL, visualization, landing, layout
│ │ ├── pages/ # Docs, auth, team, billing return, ERD, visualize
│ │ └── components/# Shared UI and documentation sections
│ └── test/ # Frontend test setup
Sẵn sàng khám phá dữ liệu?
Tham gia cộng đồng trên GitHub để đóng góp cho IDE cơ sở dữ liệu địa phương thông minh nhất.
Mở Ứng dụng