# manthankk/knowcode-25 architecture

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

- Interactive diagram: https://gitdiagram.com/manthankk/knowcode-25
- Repository: https://github.com/manthankk/knowcode-25

## Overview

##### Project Overview
- This is a multi-module, full-stack application that leverages a microservice architecture.
- The overall system comprises a modern React-based frontend (located in the SKIN-CARE directory) and at least two back-end Spring Boot services:
– The first backend service (“KJ-main”) handles user login, product management, reviews, purchases, and vendor operations.
– The second backend service (“gateway-main”) is dedicated to payment processing and integrating with the Razorpay API.
- The README highlights key pages as “Landing Page”, “Product Page”, “Community”, “Skin Disease Analysis”, and “Payment System”, indicating that the system is rich in UI along with various business functionalities.

##### Main Components and Their Roles
a. SKIN-CARE (Frontend)
- Built with React/Vite as evidenced by files like App.jsx, main.jsx, and various page components.
- Contains separate routing logic (e.g., RetailerRouter.jsx and UserRouter.jsx) to serve different user roles.
- Provides a user interface for accessing all major features (e.g., community interactions, product browsing, and order tracking).

b. KJ-main (Backend Service for User and Business Logic)
- A Spring Boot (Java) service indicated by the pom.xml, mvnw scripts, and the Maven project structure.
- Implements typical Model-View-Controller (MVC) pattern:
- Controller layer: REST controllers (e.g., CustomerController, ProductsController, ReviewController, etc.) for handling HTTP requests.
- Service layer: Business logic encapsulated in various service classes.
- Repository layer: Data persistence via repositories for entities like Customer, Products, Purchase, Review, and Vendor.
- Likely interacts with a database as configured in application.properties, though the physical database isn’t explicitly present in the file tree.

c. gateway-main (Backend Service for Payment Processing)
- Another Spring Boot application focused on payment functionality.
- Follows a similar MVC pattern with controllers (e.g., RazorpayController), services (RazorpayService), and repositories for Payment entities.
- Acts as a dedicated Payment Gateway backend that the frontend might call when processing transactions.

##### Relationships and Data Flow
- The SKIN-CARE frontend communicates with the back-end services via RESTful APIs:
– It routes authentication, product, and order management requests to the KJ-main service.
– Payment-related requests are forwarded to the gateway-main service.
- Within each backend service, controllers receive HTTP requests, invoke business logic in the service layers, and persist or retrieve data via repositories.
- If applicable, there may be cross-service communication (for instance, after a purchase is created, the KJ-main service might need to trigger a payment request to the gateway-main service or vice versa).

##### Architectural Patterns and Design Principles
- Microservices: The clear separation between the login/product service (KJ-main) and the payment service (gateway-main) promotes modularity.
- MVC in the backend: Both backend services organize code logically into controllers, services, and repositories.
- Separation of concerns: The frontend (SKIN-CARE) is isolated from back-end business logic, highlighting a clear API-driven design.
- Extensibility: With distinct services (one handling user/business logic and one focusing on payment), it is easier to maintain and scale specific parts of the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph (React/Vite)
    subgraph "Frontend (React/Vite)"
        FE_App["App Component"]:::frontend
        FE_Main["Main Entry"]:::frontend
        FE_Retailer["Retailer Router"]:::frontend
        FE_User["User Router"]:::frontend
        FE_Pages["Pages (Various)"]:::frontend
    end

    %% Backend Service: KJ-main (User & Business Logic Service)
    subgraph "User & Business Logic Service (Spring Boot: KJ-main)"
        KJ_App["Application Entry"]:::backend
        KJ_Config["Configuration"]:::backend

        subgraph "Controllers"
            KJ_Controller["REST Controllers (Customer,Products,Purchase,Review,Vendor)"]:::controller
        end

        subgraph "Services"
            KJ_Service["Service Layer"]:::service
        end

        subgraph "Repositories"
            KJ_Repo["Data Repositories"]:::repository
        end

        subgraph "Entities"
            KJ_Entity["Domain Entities"]:::entity
        end

        KJ_DB["User DB"]:::database
    end

    %% Backend Service: gateway-main (Payment Gateway Service)
    subgraph "Payment Gateway Service (Spring Boot: gateway-main)"
        GW_App["Application Entry"]:::backend
        GW_Config["Configuration"]:::backend

        subgraph "Controllers"
            GW_Controller["Razorpay & Cors Controllers"]:::controller
        end

        subgraph "Services"
            GW_Service["Payment Processing Service"]:::service
        end

        subgraph "Repositories"
            GW_Repo["Payment Repository"]:::repository
        end

        subgraph "Entities"
            GW_Entity["Payment Entity"]:::entity
        end

        GW_DB["Payment DB"]:::database
    end

    %% Interactions between Frontend and Backend Services
    FE_App -->|"API_Call"| KJ_Controller
    FE_Retailer -->|"API_Call"| KJ_Controller
    FE_User -->|"API_Call"| KJ_Controller
    FE_Pages -->|"DataFetch"| KJ_Controller
    FE_Pages -->|"PaymentInit"| GW_Controller

    %% Internal flows within KJ-main
    KJ_Controller -->|"Calls"| KJ_Service
    KJ_Service -->|"Executes"| KJ_Repo
    KJ_Repo -->|"Persists"| KJ_DB

    %% Internal flows within gateway-main
    GW_Controller -->|"Calls"| GW_Service
    GW_Service -->|"InteractsWith"| GW_Repo
    GW_Repo -->|"Persists"| GW_DB

    %% Cross-service flow: Payment triggered from KJ-main to Payment Gateway
    KJ_Service -->|"TriggersPayment"| GW_Controller

    %% Click Events for SKIN-CARE Frontend
    click FE_App "https://github.com/manthankk/knowcode-25/blob/main/SKIN-CARE/src/App.jsx"
    click FE_Main "https://github.com/manthankk/knowcode-25/blob/main/SKIN-CARE/src/main.jsx"
    click FE_Retailer "https://github.com/manthankk/knowcode-25/blob/main/SKIN-CARE/src/RetailerRouter.jsx"
    click FE_User "https://github.com/manthankk/knowcode-25/blob/main/SKIN-CARE/src/UserRouter.jsx"
    click FE_Pages "https://github.com/manthankk/knowcode-25/tree/main/SKIN-CARE/src/pages/"

    %% Click Events for KJ-main Service
    click KJ_Controller "https://github.com/manthankk/knowcode-25/tree/main/KJ-main/KJ-main/src/main/java/com/v4/login/controller/"
    click KJ_Service "https://github.com/manthankk/knowcode-25/tree/main/KJ-main/KJ-main/src/main/java/com/v4/login/service/"
    click KJ_Repo "https://github.com/manthankk/knowcode-25/tree/main/KJ-main/KJ-main/src/main/java/com/v4/login/repository/"
    click KJ_Entity "https://github.com/manthankk/knowcode-25/tree/main/KJ-main/KJ-main/src/main/java/com/v4/login/entity/"
    click KJ_App "https://github.com/manthankk/knowcode-25/blob/main/KJ-main/KJ-main/src/main/java/com/v4/login/LoginApplication.java"
    click KJ_Config "https://github.com/manthankk/knowcode-25/blob/main/KJ-main/KJ-main/src/main/resources/application.properties"

    %% Click Events for gateway-main Service
    click GW_Controller "https://github.com/manthankk/knowcode-25/tree/main/gateway-main/gateway-main/src/main/java/com/payment/gateway/controller/"
    click GW_Service "https://github.com/manthankk/knowcode-25/tree/main/gateway-main/gateway-main/src/main/java/com/payment/gateway/service/"
    click GW_Repo "https://github.com/manthankk/knowcode-25/tree/main/gateway-main/gateway-main/src/main/java/com/payment/gateway/repositiory/"
    click GW_Entity "https://github.com/manthankk/knowcode-25/tree/main/gateway-main/gateway-main/src/main/java/com/payment/gateway/entity/"
    click GW_App "https://github.com/manthankk/knowcode-25/blob/main/gateway-main/gateway-main/src/main/java/com/payment/gateway/GatewayApplication.java"
    click GW_Config "https://github.com/manthankk/knowcode-25/blob/main/gateway-main/gateway-main/src/main/resources/application.properties"

    %% Class Definitions for Styling
    classDef frontend fill:#aee1f9,stroke:#0277bd,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef controller fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef service fill:#f8bbd0,stroke:#c2185b,stroke-width:2px;
    classDef repository fill:#d7ccc8,stroke:#5d4037,stroke-width:2px;
    classDef entity fill:#e1bee7,stroke:#8e24aa,stroke-width:2px;
    classDef database fill:#ffcc80,stroke:#ef6c00,stroke-width:2px;
```
