# yashkambaria/farmer-helping-team architecture

> Architecture diagram of the GitHub repository yashkambaria/farmer-helping-team, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yashkambaria/farmer-helping-team
- Repository: https://github.com/yashkambaria/farmer-helping-team

## Overview

##### Project Type & Purpose
- The project is a full‐stack application combining a React.js frontend (using Tailwind CSS, Framer Motion, Chart.js, D3.js) with a dual-backend approach.
- The backend is split between two main services: a Spring Boot service that handles authentication, authorization (using Spring Security and JWT) and another Flask service that focuses on machine learning and data processing (for credit score prediction and integration with the Gemini AI API).
- There’s also an ML module (found in CreditScorePrediction-main) that contains training scripts and a pickled model, as well as a separate chatAI component that likely provides a chat-related interface.

##### Analyzing the File Structure
- The “frontend” directory holds all the React application files, including components, assets, and configuration (Vite, ESLint). This represents the user interface.
- The “journalApp” directory contains a full Java Spring Boot application. Its structure (Controllers, Entities, Services, Repositories, config, filters) clearly indicates that it is responsible for authentication, user management, and other secure operations.
- The “CreditScorePrediction-main” folder is a Python-based module with a pre-trained ML model (random_forest_credit_score.pkl) and training script (train_model.py). This indicates a dedicated ML service or microservice.
- The “chatAI” directory, with its own configuration and main.py, suggests another backend module that might be powering a chatbot or conversational AI feature.

##### Key Components
a. Frontend Component:
– Label it “Frontend (React.js)” and include elements like Tailwind styling, interactive charting (Chart.js, D3.js), animations (Framer Motion), and UI components.
– Emphasize that it interacts with backend components through RESTful API calls.

b. Backend Components:
- “Spring Boot Authentication Service”:
– Represents the Java-based “journalApp”.
– Include details such as authentication endpoints, role-based access controlled via JWT, and integration with MongoDB for storing user credentials and authentication data.
- “Flask ML & Data Processing Service”:
– Encompasses the functionalities detailed in the README (credit score prediction, data processing) with endpoints like /api/credit-score, and routes for farmer data.
– Also, note the Python dependencies (pandas, numpy, scikit-learn, flask-cors, etc.) and integration with MongoDB from the ML perspective.
- “Credit Score Prediction Module”:
– Derived from the CreditScorePrediction-main directory. This module includes scripts and a pickled model, thus it represents the ML model training/inference process.
- “Chat AI Module”:
– Even though not explicitly detailed in the README, the existence of a chatAI folder with its configuration indicates it’s providing supplementary interactive or conversational capabilities.

c. External Services & Database:
– “Gemini AI API”: External service for AI-driven credit analysis. Connect this particularly to the Flask ML service.
– “MongoDB Database”: Used by both Spring Boot (for authentication data) and Flask (for farmer data/credit history). Mark it as a central data store.

##### Establishing Relationships & Interactions
– Show data flow directions (e.g., requests and responses) between the components.

##### Architectural Patterns and Design Strategies
– Emphasize the separation of concerns by isolating UI, authentication/authorization, and ML/data processing as independent service layers.
– Note the microservices or modular approach (distinct Spring Boot and Flask services) that increase scalability and maintainability.
– Include external integrations (Gemini AI API, MongoDB) and any RESTful API patterns that are in place.

##### Assembly and Detail
– Split backend services as two (or more) distinct nodes (Spring Boot and Flask) with clearly defined responsibilities.
– Connect the Flask ML Service to the ML module and its data/model artifacts.
– Make sure all endpoints (as described in the README’s API endpoints section) are conceptually reflected (authentication endpoints, credit score endpoints, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    U("User/Browser"):::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        F("Frontend (React.js)"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        S("Spring Boot Auth Service\n(Port 8080)"):::backend
        FL("Flask ML & Data Processing Service\n(Port 5000)"):::backend
        CP("Credit Score Predictor"):::ml
        CA("Chat AI Module"):::backend
    end

    %% External Services
    subgraph "External Services"
        M("MongoDB Database"):::database
        G("Gemini AI API"):::external
    end

    %% Relationships
    U -->|"accesses"| F
    F -->|"authCalls"| S
    F -->|"creditScoreCalls"| FL
    F -->|"chatRequests"| CA

    S -->|"storesAuthData"| M
    FL -->|"accessesFarmerData"| M
    FL -->|"integratesWith"| G
    FL -->|"invokesPrediction"| CP

    %% Click Events
    click F "https://github.com/yashkambaria/farmer-helping-team/tree/main//frontend"
    click S "https://github.com/yashkambaria/farmer-helping-team/tree/main//journalApp"
    click FL "https://github.com/yashkambaria/farmer-helping-team/tree/main//chatAI"
    click CP "https://github.com/yashkambaria/farmer-helping-team/tree/main//CreditScorePrediction-main"
    click CA "https://github.com/yashkambaria/farmer-helping-team/tree/main//chatAI"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef ml fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
