How matheusfcorocher/shopping-cart works
Main Architectural Layers (Use vertical layers from top to bottom)
a. Interface Layer (Top)
• HTTP Controllers & Routes
• Serializers
• Swagger Documentation
b. Application Layer
• Use Cases (Cart, Product, Voucher operations)
c. Domain Layer
• Entities (Cart, Product, Buyer, Order, Voucher)
• Value Objects (Money, AppliedVoucher)
• Domain Services (CheckoutDomainService)
• Repository Interfaces
d. Infrastructure Layer (Bottom)
• Database (PostgreSQL)
• ORM (Objection.js)
• Repository Implementations
Component Relationships
• HTTP Routes → Controllers → Use Cases
• Use Cases → Domain Services/Entities
• Domain Layer → Repository Interfaces
• Repository Implementations → Database
Key Components
a. External Interface:
• Fastify Server
• Swagger UI
• API Endpoints (/cart, /product, /voucher)
b. Core Business Components:
• Cart Management
• Product Catalog
• Voucher System
• Checkout Process
c. Data Storage:
• PostgreSQL Database
• Knex Migrations
• Objection.js Models
Technical Details
• Technologies: TypeScript, Fastify, PostgreSQL, Objection.js
• Testing Framework: Jest
• Money Pattern Implementation
• Dependency Injection Container
Component Interactions
Specific flows for key operations:
• Product Listing
• Cart Management
• Voucher Application
• Checkout Process
External API endpoints
• Rectangles: Modules/Components
• Hexagons: Domain Entities
• Rounded Rectangles: Services
• Diamonds: Decision Points