How drogonframework/drogon works
Main Components
• Core Framework (Drogon Engine): This encapsulates modules such as the HTTP server implementation (in lib/src/HttpServer.cc and related files), asynchronous I/O (relying on epoll/kqueue through the trantor library), request parsing (HttpRequestParser, HttpResponseParser), and response generation.
• Routing & Controller Dispatch: This component handles the mapping of incoming URLs to controllers and filters (see the “HttpController”, “HttpSimpleController”, and associated binding code in both lib and drogon_ctl).
• Middleware & Filter Chains: These are used to implement cross-cutting concerns like authentication, logging, and HTTP method verification.
• Plugins and Extensions: Encapsulated in the plugin interface files (in lib/inc/drogon/plugins/) and managed at runtime via the plugins system.
• Command-Line Tool (drogon_ctl): A separate module providing an interface for code scaffolding and project creation. It uses templates (under drogon_ctl/templates) to generate new controllers, models, plugins, views, etc.
• ORM and Database Support: Areas in “orm_lib” provide object-to-database mapping and support asynchronous database access for SQL databases, while “nosql_lib” provides Redis integration.
• Configuration System: Managed through configuration files (e.g., config.example.json, config.example.yaml) in the root folder and facilitated by ConfigLoader & various ConfigAdapters.
• Build/CI Infrastructure: Captured through CMake scripts, GitHub workflows, and other related build scripts for testing and analysis.
• Testing Modules: Unit tests, integration tests, and sample applications (in “lib/tests” and “examples”) that show the end-to-end use of the framework.
Relationships and Interactions
• Asynchronous Processing: Represent the non-blocking event loop (powered by epoll/kqueue) that handles I/O and dispatches callbacks to controllers.
• Middleware Chain: Show how pre-request filters or middleware components intercept requests before reaching the designated controller.
• Configuration Loader: Indicate that the application’s runtime behavior (e.g., listening ports, thread pool settings) is dynamically loaded through configuration files.
• Command-Line Interface: Include drogon_ctl as a separate auxiliary tool that generates the scaffold for new controllers, plugins, or views, feeding into the core modules.
Important Architectural Patterns/Design Principles
• Asynchronous and Non-Blocking I/O: Emphasize that the framework is designed for high concurrency by using an event-driven architecture.
• Modular Design and Separation of Concerns: Controllers, filters, and plugins are developed as separate modules, allowing for extensibility and customization.
• Code Generation & Template Use: The drogon_ctl component’s use of templates promotes standard patterns in code across the project.
• Middleware Pattern: Clearly indicate how filter chains are used to inject additional logic into request processing.
Relevant Technologies, Frameworks, or Libraries
• C++17/20 Standard: The project is built in modern C++.
• Trantor Library: For asynchronous I/O operations.
• CMake and Conan: For build configuration and dependency management.
• JSON and YAML Processing: For configuration and potentially for responses.
• Integration with OpenSSL for HTTPS support.