Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
* [Folder structure](architectures/space-based-architecture/folder-structure.md)
* [Implementation guide](architectures/space-based-architecture/implementation-guide.md)
* [Trade offs](architectures/space-based-architecture/trade-offs.md)
* **Agentic architecture**
* [Overview](architectures/agentic-architecture/readme.md)
* **Microkernel architecture**
* [Overview](architectures/microkernel-architecture/readme.md)
* **Backend**
* [Overview](backend/readme.md)
* **Expressjs**
Expand Down
4 changes: 4 additions & 0 deletions architectures/agentic-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class MonolithicAIAgent {
Loading a monolithic agent with unbounded context leads to "Context Explosion", resulting in non-deterministic hallucinations, excessive token costs, and security risks (like arbitrary code execution). A single LLM call attempting multiple distinct personas (Planner, Coder, Reviewer) fundamentally degrades reasoning quality.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
interface AgentTask {
goal: string;
Expand Down
4 changes: 4 additions & 0 deletions architectures/backend-for-frontend/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class UniversalGatewayController {
Using a single gateway or backend for diverse clients leads to bloated endpoints, complex `if/else` branching for different client needs, and over-fetching or under-fetching of data. Changing the API for a web feature risks breaking the mobile app.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// --- Web BFF ---
class WebDashboardController {
Expand Down
4 changes: 4 additions & 0 deletions architectures/clean-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export class User extends BaseEntity {
The Domain layer (the core of the application) is tightly coupled with a specific third-party ORM library (`TypeORM`). This violates the Dependency Rule. Changing the database technology will require rewriting core business logic.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// Pure Domain Entity completely agnostic of infrastructure
export class User {
Expand Down
4 changes: 4 additions & 0 deletions architectures/cqrs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class UserService {
Combining complex read queries and heavy write operations in a single service and database leads to severe performance bottlenecks. Scaling writes and reads independently is impossible, and the Domain logic for commands becomes entangled with data-shaping logic for queries.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// --- COMMAND SIDE ---
class CreateUserCommandHandler {
Expand Down
4 changes: 4 additions & 0 deletions architectures/domain-driven-design/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class OrderService {
Using Anemic Domain Models breaks the core principle of Domain-Driven Design. The Entity (`Order`) is reduced to a pure data structure without behavior. The business rules ("How does an order get paid?") leak into the `OrderService`, causing logic duplication, difficult testing, and poor encapsulation. The Domain becomes passive.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// Rich Domain Entity - Encapsulates both data and behavior
class Order {
Expand Down
4 changes: 4 additions & 0 deletions architectures/event-driven-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class OrderService {
Treating an event bus like an RPC (Remote Procedure Call) mechanism defeats the purpose of EDA. Synchronous waiting re-introduces tight temporal coupling. If the consumer is slow, it blocks the producer, leading to cascading failures and timeouts across the system.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
class OrderService {
async createOrder(data: OrderData) {
Expand Down
4 changes: 4 additions & 0 deletions architectures/event-sourcing/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class BankAccount {
Directly mutating state overwrites historical data. If there is a bug or an audit requirement, it is impossible to determine *why* an account has a specific balance. We have only the final snapshot, not the journey.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
class BankAccount {
private balance: number = 0;
Expand Down
4 changes: 4 additions & 0 deletions architectures/feature-sliced-design/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ import { User } from 'entities/user';
Violation of the upward dependency flow constraints. `shared` is the lowest infrastructure layer; it has no right to know anything about the business domain (`entities`), features (`features`), and widgets. This leads to circular dependencies and tight coupling.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// The Entities layer naturally depends on the infra-layer below (Shared)
import { Button } from 'shared/ui/button';
Expand Down
4 changes: 4 additions & 0 deletions architectures/hexagonal-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export class ProcessDocumentService {
The Core Domain is directly importing and depending on a specific technical implementation (`AWS S3`). If the project migrates to Azure or GCP, the core business logic must be rewritten. Testing requires a live S3 connection or complex module mocking.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// Port (Interface defined in the Core Domain)
export interface IFileStoragePort {
Expand Down
4 changes: 4 additions & 0 deletions architectures/micro-frontends/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const cart = window.__APP_STATE__.cart;
Directly mutating and depending on global objects like `window` creates tight coupling between micro-frontends. This leads to race conditions, unpredictable state mutations, and makes isolated testing impossible. It destroys the independence of micro-frontends.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```javascript
// Using an Event Bus or Custom Events for decoupled communication

Expand Down
4 changes: 4 additions & 0 deletions architectures/microservices/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ services:
Sharing a single database among multiple microservices completely violates the core principle of microservices (independence). If `order-service` performs a heavy migration or drops a table, `inventory-service` crashes. Database schemas cannot evolve independently, recreating monolithic tight coupling at the data layer.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```yaml
# docker-compose.yml
services:
Expand Down
4 changes: 4 additions & 0 deletions architectures/model-view-controller/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class UserController {
The Controller is overloaded with low-level implementation details (SQL, hashing, email processing). This grossly violates the Single Responsibility Principle (SRP) and makes the code monolithic and untestable.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
class UserController {
constructor(private userService: UserService) {}
Expand Down
4 changes: 4 additions & 0 deletions architectures/monolithic-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export class PaymentProcessor {
Directly accessing tables or internal state of other modules within a monolith creates a "Big Ball of Mud". Changing the `users` table schema will silently break the `PaymentModule`. This prevents the monolith from ever being safely split into microservices in the future.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
// PaymentModule interacting with UserModule via an explicit Interface/Facade
import { UserService } from '../users/user.service';
Expand Down
1 change: 1 addition & 0 deletions architectures/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Don't know where to start? Here are a few golden rules:
- [Space-Based Architecture](./space-based-architecture/readme.md)
- [Serverless](./serverless/readme.md)
- [Agentic Architecture (AI Agent Orchestration)](./agentic-architecture/readme.md)
- [Microkernel Architecture (Plugin Architecture)](./microkernel-architecture/readme.md)

## πŸ† Top 15 Best Architectural Approaches

Expand Down
4 changes: 4 additions & 0 deletions architectures/serverless/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ exports.handler = async (event) => {
Grouping unrelated endpoints into a single function defeats the purpose of Serverless. It increases the deployment package size (slowing down cold starts), couples business domains together, complicates IAM permissions (granting excessive privileges), and makes individual function metrics/tracing impossible.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```javascript
// One function strictly mapped to one specific capability
// users-create.js
Expand Down
8 changes: 6 additions & 2 deletions architectures/space-based-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ import { Database } from 'infrastructure/database';
class OrderProcessingUnit {
constructor(private readonly db: Database) {}

public async processOrder(orderData: any): Promise<void> {
public async processOrder(orderData: unknown): Promise<void> {
// 1. Process business logic
const processedOrder = this.calculateTaxes(orderData);

// 2. Synchronous write to persistent database inside the hot path
await this.db.save(processedOrder);
}

private calculateTaxes(data: any): any {
private calculateTaxes(data: unknown): unknown {
return { ...data, tax: 10 };
}
}
Expand All @@ -88,6 +88,10 @@ class OrderProcessingUnit {
Directly writing to a persistent database synchronously within a Processing Unit defeats the entire purpose of the Space-Based Architecture. During high-traffic spikes, the database connection pool will exhaust, locks will accumulate, and the central database will become a catastrophic bottleneck, crashing the independent processing units waiting for disk I/O.

### βœ… Best Practice

> [!NOTE]
> **Internal Routing:** For more context, refer back to the [Architecture Map](../readme.md).

```typescript
import { InvalidateType } from 'infrastructure/cache';

Expand Down
Loading