How pardeshibabu/loan_service works
Main Components
• API Layer / HTTP Handlers: Represented by the "actions" directory. These include endpoints like creating loans, approving or disbursing loans, adding investments, and document handling.
• Business Logic / Controllers: Although intertwined with actions, this layer includes the core logic processing validated inputs and transitioning loan states.
• Data Models: Represented in the "models" directory containing the core entities (Loan, Investment, Document, Notification, etc.) as well as database validation and state logic.
• Database / Persistence Layer: The "migrations" directory and "database.yml" describe the schema and configuration for the MySQL database (using Buffalo’s POP ORM).
• View / Template Layer: Located in the "templates" directory (for server-side HTML rendering) and the "public" directory (for static assets like CSS, JS, and images).
• Notification Service: The "services/notification" directory encapsulates the logic to send agreement and other emails.
• Additional Layers:
• Middleware (in "middleware") for aspects like authentication.
• Configuration and deployment support from files like Dockerfile, docker-compose.yml, and various config files.
• Command entry point under "cmd/app/main.go" for starting the application.
• Asset pipeline configuration (Webpack, Babel, PostCSS, etc.) for front-end assets.
Relationships and Interactions
• Frontend Requests: Browser calls hit the HTTP endpoints defined in the actions.
• Business Logic Processing: Each endpoint calls application services (controllers) that handle business rules (e.g., validating loan state transitions) and invoke model operations.
• Data Persistence: Models interact with the MySQL database for CRUD operations. Migrations ensure the database schema is consistently managed.
• Template Rendering: For the HTML views served, the controllers use the template engine (using Buffalo templates in the “templates” directory).
• API Documentation: The README indicates a Swagger file (in public/swagger) to document the API, which should be represented as an external documentation component.
• Notification Triggers: After events like a fully invested loan, a notification service (email) is triggered, interacting with external mail servers.
• Docker & Deployment: Docker-compose orchestrates the containerized deployment, connecting the application, database, and other environmental configurations.
Architectural Patterns and Design Principles
• MVC Pattern: Clearly separate Models, Views, and Controllers.
• Containerization: Use Docker for consistent development, testing, and production environments.
• RESTful API Design: The endpoints follow REST principles.
• Modular/Service-based: The system modularly separates concerns (loan management, investment management, document handling, notifications).
Deployment Elements
• Optionally, connect the container to the external database host (as described by environment variables in docker-compose.yml).