This document follows the C4 Model (Context, Containers, Components, Code) standard for documenting the VTEX Rewriter architecture.
⚙️ Technical Details: For detailed technical diagrams, flows, and troubleshooting information, see Complete Architecture Documentation.
📋 C4 Model Overview
The C4 model provides a hierarchical set of software architecture diagrams for context, containers, components, and code.
- Level 1: System Context - Shows how the software system fits into the world
- Level 2: Container - Shows the high-level shape of the architecture
- Level 3: Component - Shows how a container is made up of components
- Level 4: Code - Shows how a component is implemented
🌍 Level 1: System Context Diagram
Shows how the VTEX Rewriter fits into the overall VTEX ecosystem.
Key Relationships:
- Customers browse the storefront and trigger route resolution
- Store Admins manage routes and redirects through Admin UI
- VTEX Router forwards requests to Rewriter based on routing rules
- Rewriter processes URLs, applies redirects, and proxies to Render Server
- VBase stores all route and redirect configurations
- Catalog API provides product and category data for route resolution
🏗️ Level 2: Container Diagram
Shows the high-level technology choices and how containers communicate.
Technology Stack:
- Node.js - Runtime environment
- TypeScript - Primary language
- GraphQL - API layer
- Express.js - HTTP server framework
- VBase - Document storage
- LRU Cache - In-memory caching
⚙️ Level 3: Component Diagram
Shows how the Node.js application is structured internally.
Key Components:
- HTTP Handlers - Entry points for different request types
- GraphQL API - Admin interface for route management
- Middleware Pipeline - Sequential request processing
- Route Resolvers - Business logic for different route types
- Resource Layer - Data abstraction and validation
- API Clients - External service integrations
- LRU Caches - Performance optimization
💻 Level 4: Code Diagram - Route Resolution Component
Shows the internal structure of the critical Route Identifier component.
Key Classes and Responsibilities:
-
RouteIdentifier - Main orchestrator
_10class RouteIdentifier {_10async identify(ctx: Context): Promise<Route | null>_10private async findRedirect(locator: RouteLocator): Promise<Redirect | null>_10private async findInternal(locator: RouteLocator): Promise<Internal | null>_10} -
RedirectStrategy - Redirect route resolution
_10class RedirectStrategy implements RouteStrategy {_10async resolve(locator: RouteLocator): Promise<Redirect | null>_10private async searchWithQueryString(locator: RouteLocator): Promise<Redirect | null>_10private async searchWithoutQueryString(locator: RouteLocator): Promise<Redirect | null>_10} -
RouteValidator - Route validation logic
_10class RouteValidator {_10validateRedirect(redirect: Redirect): ValidationResult_10validateInternal(internal: Internal): ValidationResult_10checkExpiration(route: Route): boolean_10}
This C4 model provides a comprehensive view of the VTEX Rewriter architecture at all necessary levels of detail.