This article explores a novel approach to system design, using a large language model (LLM) as an architectural co-pilot. It demonstrates how to move beyond basic AI interactions to a collaborative dialogue for rapid, iterative design of complex systems, significantly accelerating the journey from concept to code.
Read original on Dev.to #systemdesignThe traditional system design process is often characterized by lengthy whiteboard sessions and extensive documentation, which can be time-consuming. This article introduces an accelerated, AI-assisted methodology where an LLM functions as an architectural co-pilot, transforming the design process into a rapid, iterative cycle.
The core shift required is to treat the LLM not as a search engine or code generator, but as a collaborative partner. By maintaining a continuous conversation within the LLM's context window, the AI develops a deep understanding of design goals, constraints, and previous decisions. This allows it to act as a tireless junior architect for brainstorming and validation.
The author illustrates this methodology by designing a data model for an engineering analytics platform. Starting with a broad prompt for entities like Projects, Developers, Commits, Pull Requests, and Deployments, the LLM initially generated a normalized relational schema. This initial output served as a base for further iterative refinement.
# AI-Generated Foundational Models (First Pass)
import datetime
from typing import List, Optional
from pydantic import BaseModel, Field
class Developer(BaseModel):
id: int
username: str
email: str
class Project(BaseModel):
id: int
name: str
repository_url: str
class Commit(BaseModel):
id: str = Field(..., description="Git commit hash")
project_id: int
author_id: int
message: str
committed_at: datetime.datetime
class PullRequest(BaseModel):
id: int
project_id: int
author_id: int
title: str
created_at: datetime.datetime
merged_at: Optional[datetime.datetime] = None
closed_at: Optional[datetime.datetime] = NoneThe key insight is the power of follow-up prompts that build on the existing context. By asking the AI to refine the `PullRequest` model to include a `PullRequestEvent` for detailed cycle time analysis (e.g., `review_requested`, `approval_given`), the design evolved into a more robust, event-sourced model tailored for specific business metrics. This demonstrates how a few iterative steps can lead from a high-level concept to a sophisticated, purpose-built architectural component.
# AI-Assisted Refined Models (Second Pass)
import datetime
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel, Field
# ... (Developer, Project, Commit models remain the same)
class EventType(str, Enum):
REVIEW_REQUESTED = "review_requested"
COMMENT_ADDED = "comment_added"
APPROVAL_GIVEN = "approval_given"
MERGE_COMMITTED = "merge_committed"
CLOSED = "closed"
class PullRequestEvent(BaseModel):
id: int
pull_request_id: int
actor_id: int
event_type: EventType
created_at: datetime.datetime = Field(default_factory=datetime.datetime.utcnow)
class PullRequest(BaseModel):
id: int
project_id: int
author_id: int
title: str
created_at: datetime.datetime
events: List[PullRequestEvent] = []