# sritechprojects/cavista_hackathon architecture

> Architecture diagram of the GitHub repository sritechprojects/cavista_hackathon, 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/sritechprojects/cavista_hackathon
- Repository: https://github.com/sritechprojects/cavista_hackathon

## Overview

##### Main Components
- Frontend (Client):
- Located in the “client” directory.
- Built using a modern JavaScript framework (React, based on file naming like App.jsx and component structure).
- Organized around several pages and layouts for different user roles (auditor, seller, supplier, and general forms).
- Contains assets, utilities, contexts (AuthContext, UserContext), and state management modules.

- Backend (Server):
- Resides in the “server” directory.
- Likely implemented in Node.js (evidenced by files like app.js and usage of packages via package.json).
- Organized into controllers based on domains (HealthCareInventory, Suppliers, admin, orders, products, seller) and includes configuration files (TokenVerify.js, authorize.js, emailSender.js).
- Uses Prisma as an ORM for database interactions (found in server/prisma and server/lib/prisma.js).

- Filtering/Recommendation API:
- Housed in the “api” directory containing Python scripts (collab_filtering.py and content_filtering.py).
- These components are likely used as specialized modules that offer recommendation or filtering functionality to the main backend.

- Supporting Documents & Configurations:
- “documents” directory contains JSON files (customer.json, product.json, seller.json) which might be used as seed data or test data.
- Other configuration files (e.g., .gitignore, environment variables in server/.env) set up the deployment and build environment.

##### Relationships and Data Flow
- The Client interacts with the Backend via RESTful API calls (or possibly other API protocols), sending user actions (logins, product reviews, etc.) and receiving responses that update the UI.
- The Backend acts as the central orchestrator:
- It handles API calls from the frontend.
- It processes requests by routing them through various controllers (for authentication, order processing, product management, etc.).
- It interacts with the database (via Prisma) for CRUD operations.
- It may invoke the Python scripts from the “api” folder to perform recommendation filtering tasks.
- The Filtering API (Python scripts) can be depicted as a specialized service that the backend calls to enhance the recommendation and content filtering functionality.

##### Architectural Patterns and Technologies
- Modular Separation: The project shows a clean separation by isolating the frontend, backend, and filtering components. This modular setup follows common microservices or service-oriented architecture patterns, though all parts are maintained in one code repository.
- Role-based Layouts and Components: In the client, multiple layouts and page components are designed for different user roles (auditor, seller, supplier) indicating a role-based access design.
- ORM and Database Abstraction: The use of Prisma indicates that the system relies on an abstraction layer for robust database operations.
- API Integration: The presence of distinct API folders (one in Python for filtering and one in Node.js for typical REST endpoints) shows a polyglot approach—leveraging the strengths of different languages for specific tasks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Client)"
        F1["Main Client"]:::frontend
        F2["UI Pages"]:::frontend
        F3["Layouts"]:::frontend
        F4["State Management & Contexts"]:::frontend
        F5["Shared Assets"]:::frontend
    end

    subgraph "Backend (Server)"
        B1["Backend App"]:::backend
        B2["Controllers"]:::backend
        B3["Middleware & Config"]:::backend
        B4["Database (Prisma)"]:::database
    end

    subgraph "Filtering Service"
        FT1["Collaborative Filtering"]:::filtering
        FT2["Content Filtering"]:::filtering
    end

    subgraph "Supporting Data"
        S1["Documents & Seed Data"]:::doc
    end

    F1 -->|"REST_API"| B1
    F2 -->|"UI_Actions"| F1
    F3 -->|"UI_Actions"| F1
    F4 -->|"State_Updates"| F1
    F5 -->|"Assets"| F1

    B1 -->|"Routes"| B2
    B1 -->|"Auth_Config"| B3
    B1 -->|"CRUD"| B4
    B1 -->|"FilterCalls"| FT1
    B1 -->|"FilterCalls"| FT2

    S1 -->|"Seed_Data"| B4

    click F1 "https://github.com/sritechprojects/cavista_hackathon/tree/main/client/"
    click F2 "https://github.com/sritechprojects/cavista_hackathon/tree/main/client/src/pages"
    click F3 "https://github.com/sritechprojects/cavista_hackathon/tree/main/client/src/layouts"
    click F4 "https://github.com/sritechprojects/cavista_hackathon/tree/main/client/src/contexts"
    click F5 "https://github.com/sritechprojects/cavista_hackathon/tree/main/client/src/assets"
    click B1 "https://github.com/sritechprojects/cavista_hackathon/blob/main/server/app.js"
    click B2 "https://github.com/sritechprojects/cavista_hackathon/tree/main/server/controllers"
    click B3 "https://github.com/sritechprojects/cavista_hackathon/tree/main/server/config"
    click B4 "https://github.com/sritechprojects/cavista_hackathon/tree/main/server/prisma"
    click B4 "https://github.com/sritechprojects/cavista_hackathon/blob/main/server/lib/prisma.js"
    click FT1 "https://github.com/sritechprojects/cavista_hackathon/blob/main/api/collab_filtering.py"
    click FT2 "https://github.com/sritechprojects/cavista_hackathon/blob/main/api/content_filtering.py"
    click S1 "https://github.com/sritechprojects/cavista_hackathon/tree/main/documents/"

    classDef frontend fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef backend fill:#F8CECC,stroke:#B85450,stroke-width:2px;
    classDef filtering fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef database fill:#DAE8FC,stroke:#6C8EBF,stroke-width:2px;
    classDef doc fill:#E1D5E7,stroke:#9673A6,stroke-width:2px;
```
