How gicehajunior/sproutpy-framework works
Main Components
• Framework Core (sproutpy package): This includes modules such as DatabaseManager, Router, SprouteApp, SprouteRequest, SprouteRequestHandler, TemplatingEngine, and Helper. They are the internal backbone of the framework, handling routing, database interactions, request processing, and templating.
• Application Layer (app directory): This encompasses the HTTP-related components:
• Controllers (in app/http/controllers) like DashboardController
• Authentication (in app/http/authentication & models) including AuthController, middleware for authentication (app/http/middlewares/Auth.py, app/models/Auth.py)
• Utilities (in app/http/utils) for helper functionality.
• Configuration (config directory): Contains config files for overall app settings and database configuration.
• Resources (resources directory): Houses HTML templates and layout files (like header, footer, and authentication views) that are rendered by the templating engine.
• Routes (routes directory): Responsible for defining the URL mapping (the routes/pathway.py file) that ties HTTP requests to controllers.
• Public Assets (public directory): Contains static files such as CSS, JS (including public/index.js), and other asset files that are built using Node/npm and Webpack.
• Tests (tests directory): Contains unit tests and documentation on testing approaches.
Relationships and Interactions
• The controller (in app/http/controllers) handles the business logic, and if required, communicates with models for data interactions.
• The views (resources directory) are rendered using the templating engine (sproutepy/TemplatingEngine.py), and final HTML output is sent back to the client.
• An authentication flow is evident—from HTTP request authentication, middleware validation (app/http/middlewares/Auth.py) to corresponding controller actions.
• Configuration settings from the config files (config/configuration.py and config/database.py) are used throughout the app and by the Sproutpy core components.
• The asset flow is managed separately via Node.js and built with Webpack (webpack.config.js, package.json, package-lock.json), and these assets reside in the public directory.
Architectural Patterns and Design Principles
• The framework uses an MVC-like pattern: Controllers and Models exist in the app directory, and Views are separated into the resources directory.
• Separation of concerns is emphasized through distinct directories (configuration, public assets, tests, and sproutepy core libraries).
• The modular design of the sproutepy library, including the Router and RequestHandler components, indicates adherence to a layered architecture.
• There’s clear integration between the backend (Python, HTTP handling) and frontend assets (built via Node/npm).