# harshavardhan-md/creditworthy architecture

> Architecture diagram of the GitHub repository harshavardhan-md/creditworthy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harshavardhan-md/creditworthy
- Repository: https://github.com/harshavardhan-md/creditworthy

## Overview

##### Main Components
- Frontend:
– Source located in the "src" directory (React components, pages, assets, etc.) and "public" assets.
– Built using Vite, with styling (CSS) and JavaScript/JSX files providing the user interface.

- Backend/API Server:
– In the "server" folder, the Node.js server (server.js) handles API requests (e.g., storing contact form data in contactData.db).
– Express.js is likely used as the web framework.

- AI Modeling & Data Processing:
– Python-based AI models in the "AI_Models" directory use libraries like scikit-learn, pandas, and numpy to assess creditworthiness.
– Streamlit is used to provide interactive dashboards for effecting the AI model analyses.
– Supporting JSON files in the "JSON_Files" folder provide example inputs for credit analysis.

- Additional Infrastructure/Tools:
– Clerk Auth for secure, phone number based authentication (as mentioned in the README).
– Integration with external services like Google Cloud and Gemini AI (Gemini 2.0 Flash Experimental) for enhanced insights.
– Dev container configuration (.devcontainer) enables a consistent development environment.

- The Frontend communicates with the Backend over HTTP/REST APIs (for tasks like contact form submission and general data queries).
- The Backend processes these API requests, persists data by interacting with the embedded database (contactData.db), and may trigger or fetch data from the AI Models.
- The AI Modeling components (Python scripts) operate separately – either running on-demand via Streamlit (invoked by commands like “streamlit run Filename.py”) or in a batch process – and use JSON test files to perform credit analysis.
- Authentication is handled by Clerk Auth, which is integrated into the frontend for simple user sign-ins and might also interact with backend APIs for session validation.
- The Flow:
1. User accesses the web app via the React-based frontend.
2. Authentication (via Clerk Auth) validates users.
3. Users interact with pages (such as Dashboard, Loan Analysis, etc.); API calls are made to the backend where necessary (e.g., to store contact data).
4. When initiating credit scoring, the backend or a separate process triggers the Python AI models, which deliver analysis (using machine learning libraries and Gemini 2.0) back to the user interface—either directly through Streamlit dashboards or via API endpoints.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Distinct directories and services for frontend, backend, and AI modeling ensure clear workloads.
- Modular Design: The use of separate directories (src, server, AI_Models) enables modularity.
- Interoperability: The integration of different technologies (React, Express, Python) highlights the use of API-driven communication and potential microservices or loosely coupled components.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User
    User("User"):::user

    %% Frontend (React/Vite)
    subgraph "Frontend (React/Vite)"
        React_Components["React Components"]
        Static_Assets["Static Assets"]
        Index_HTML["Entry (index.html)"]
    end

    %% Backend (Node/Express)
    subgraph "Backend (Node/Express)"
        API_Server["API Server (server.js)"]
        Contact_DB((Contact Database))
    end

    %% AI Modeling & Data Processing
    subgraph "AI Modeling & Data Processing"
        Python_AI["AI Models (Python/Streamlit)"]
        JSON_Files["Input JSON Files"]
    end

    %% External Services
    subgraph "External Services"
        Clerk_Auth["Clerk Auth"]
        Google_Cloud["Google Cloud"]
        Gemini_AI["Gemini AI"]
    end

    %% Dev Infrastructure
    subgraph "Dev Infrastructure"
        Dev_Container["Dev Container (.devcontainer)"]
        Deployment_Config["Deployment (vercel.json)"]
    end

    %% Connections
    User -->|"accesses"| Index_HTML
    Index_HTML -->|"API_Request"| API_Server
    API_Server -->|"Data_Write"| Contact_DB
    API_Server -->|"Trigger_AI"| Python_AI
    Python_AI -->|"Uses_JSON"| JSON_Files
    Python_AI -->|"Results"| Index_HTML
    Index_HTML -->|"Authenticates"| Clerk_Auth
    API_Server -->|"Data_Enrichment"| Google_Cloud
    API_Server -->|"Gemini_Feedback"| Gemini_AI
    Dev_Container -->|"Deploy_Config"| Deployment_Config

    %% Click Events
    click React_Components "https://github.com/harshavardhan-md/creditworthy/tree/main/src"
    click Static_Assets "https://github.com/harshavardhan-md/creditworthy/tree/main/public"
    click Index_HTML "https://github.com/harshavardhan-md/creditworthy/blob/main/index.html"
    click API_Server "https://github.com/harshavardhan-md/creditworthy/blob/main/server/server.js"
    click Contact_DB "https://github.com/harshavardhan-md/creditworthy/blob/main/server/contactData.db"
    click Python_AI "https://github.com/harshavardhan-md/creditworthy/tree/main/AI_Models"
    click JSON_Files "https://github.com/harshavardhan-md/creditworthy/tree/main/JSON_Files"
    click Dev_Container "https://github.com/harshavardhan-md/creditworthy/blob/main/.devcontainer"
    click Deployment_Config "https://github.com/harshavardhan-md/creditworthy/blob/main/vercel.json"

    %% Styles
    classDef user fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef frontend fill:#ccf2ff,stroke:#0066cc,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#339933,stroke-width:2px;
    classDef ai fill:#e6ccff,stroke:#9933ff,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#cc9900,stroke-width:2px;
    classDef dev fill:#e6e6e6,stroke:#666666,stroke-width:2px;

    class User user;
    class React_Components,Static_Assets,Index_HTML frontend;
    class API_Server,Contact_DB backend;
    class Python_AI,JSON_Files ai;
    class Clerk_Auth,Google_Cloud,Gemini_AI external;
    class Dev_Container,Deployment_Config dev;
```
