How chatbot-builder-project/chatbot-builder-api works
Project Type and Purpose
• This is an API microservice designed to support end-to-end chatbot building, including managing chatbots, conversations, workflows, images, graphs (with nodes, links, and ports), and users.
• The README highlights integration with gRPC/protos (infrastructure layer using externally maintained “chatbot-builder-protos”), and notes on using Guid for entities and int ids for workflow components.
• It is built in .NET, following a CQRS-inspired approach where commands, queries, and event-driven behavior are managed separately within the Application layer.
Main Components
• Presentation Layer:
• Found in the “ChatbotBuilderApi.Presentation” project.
• Contains API controllers (e.g., ChatbotsController, ConversationsController, UsersController, etc.), request and response view models, query parameters, and filters.
• This layer accepts HTTP requests, validates input, and orchestrates calls into the Application layer.
• Application Layer:
• Located in the “ChatbotBuilderApi.Application” project.
• Contains the core business logic: Commands, CommandHandlers, Queries, QueryHandlers, Validators, and Domain Events.
• Manages operations for managing chatbots, conversations, images, graphs, users, and workflows.
• Uses abstractions for messaging (ICommand, IQuery, etc.) and domain notifications.
• Domain Layer:
• Found in “ChatbotBuilderApi.Domain”.
• Consists of pure business entities such as Chatbot, Conversation, Graph, various Graph nodes (API Action, Generation, Interaction, Prompt, etc.), Images, and Users.
• Implements business rules, value objects (e.g., ChatbotId, ConversationId, etc.), and domain events.
• Enforces business invariants and encapsulates core domain logic.
• Infrastructure Layer:
• Located in “ChatbotBuilderApi.Infrastructure”.
• Provides concrete implementations for cross-cutting concerns: file storage (AzureBlobStorageSettings, AzureFileService, LocalFileService), graph-related services (ApiActionService, GenerationService, SmartRoutingService), and pipeline behaviors (LoggingPipelineBehavior, ValidationPipelineBehavior).
• Contains the integration with the external “chatbot-builder-protos” project (as indicated in the README).
• Persistence Layer:
• Represented by “ChatbotBuilderApi.Persistence”.
• Implements the EF Core DbContext (AppDbContext), entity configurations/mappings (for chatbots, conversations, graphs, images, users, workflows), data migrations, and repositories (e.g., ChatbotRepository, ConversationRepository, WorkflowRepository, UnitOfWork).
• Acts as a bridge between the domain/application layers and the underlying database.
• Composition and Bootstrapping:
• The main “ChatbotBuilderApi” project and “DependencyInjection” folders in the solution handle the overall wiring of components via ServiceCollection extensions.
• The “Program.cs”, “Dockerfile”, and various appsettings.json files indicate multi-environment configuration and deployment via Docker.
Architectural Patterns & Design Principles
• That the solution is built upon Clean Architecture/CQRS principles:
• Separate layers for API, Application, Domain, Infrastructure, and Persistence.
• Use of command and query segregation (e.g., “CreateChatbotCommand”, “DeleteChatbotCommandHandler”, “GetChatbotQuery”).
• Domain events (e.g., ChatbotCreatedEvent, WorkflowDeletedEvent) that trigger further processing.
• Dependency Injection (DI) as the method for wiring services (see DependencyInjection folder).
• How validation (via validators in the Application and Core layers) and logging (pipeline behaviors) are inserted into the request processing lifecycle.