# vikramchavan888/prevoyance-solutions architecture

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

- Interactive diagram: https://gitdiagram.com/vikramchavan888/prevoyance-solutions
- Repository: https://github.com/vikramchavan888/prevoyance-solutions

## Overview

##### Main Components
- Frontend Client:
- Built with React (using Vite as the build tool).
- Contains multiple pages such as Home, Login, Register, Profile, Admin Dashboard, and Add User.
- Uses libraries like React Router for routing, Axios for HTTP requests, and Tailwind CSS for styling.
- Backend Server:
- Developed using Node.js and Express.
- Provides endpoints for user authentication (JWT based), user data retrieval, and bulk Excel file upload.
- Implements middleware for file uploads (using Multer) and processing Excel files (using the XLSX library).
- Contains modules like bcrypt for password hashing and JWT for secure token management.
- Database:
- MySQL is used to store user details including profile pictures, with a users table as outlined in the README.
- Static File Handling:
- Server serves static files (e.g., locally stored profile pictures and uploaded Excel files from the “uploads” folder).

##### Relationships and Interactions
- The Frontend communicates with the Backend via HTTP/HTTPS APIs to perform actions like registration, login, and data retrieval.
- The backend authenticates users using JWT tokens, processes requests, and interacts with the MySQL database for CRUD operations.
- The backend handles bulk uploads by accepting an Excel file, parsing its contents using the XLSX library, and inserting the data into the database.
- Static files (profile images, Excel examples) are stored and served from designated directories within the server structure.

##### Architectural Patterns & Design Principles
- Client-Server model: There is a clear separation between the frontend (client) and backend (server), facilitating modular development and deployment.
- REST API design: The server exposes RESTful endpoints for user management and file uploads.
- Security practices: JWT-based authentication and encryption (using bcrypt) enforce secure access.
- Separation of concerns: The project cleanly divides presentation (frontend) from business logic (backend) and data persistence (MySQL database).

##### Technologies and Frameworks
- Frontend: React, React Router, Axios, Tailwind CSS, Vite.
- Backend: Node.js, Express, JWT, Multer, XLSX, bcrypt.
- Database: MySQL.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FC["Frontend Client"]:::frontend
        Home["Home Page"]:::frontend
        Login["Login Page"]:::frontend
        Register["Register Page"]:::frontend
        Profile["Profile Page"]:::frontend
        Admin["Admin Dashboard"]:::frontend
        AddUser["Add User Page"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend Server"]:::backend
        AUTH["Authentication Module (JWT, bcrypt)"]:::backend
        BULK["Bulk Upload Module (Multer, XLSX)"]:::backend
    end

    %% Database and Static Storage
    DB["MySQL Database (users table)"]:::database
    STATIC["Uploads Directory"]:::static

    %% Relationships
    FC -->|"HTTP Request"| BE
    BE -->|"Authentication"| AUTH
    BE -->|"Process Excel"| BULK
    AUTH -->|"Database Query"| DB
    BULK -->|"Data Insertion"| DB
    BE -->|"ServeStaticFiles"| STATIC
    STATIC -->|"ProvideContent"| FC

    %% Click Events
    click FC "https://github.com/vikramchavan888/prevoyance-solutions/tree/main/frontend/"
    click Home "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/frontend/src/pages/Home.jsx"
    click Login "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/frontend/src/pages/Login.jsx"
    click Register "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/frontend/src/pages/Register.jsx"
    click Profile "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/frontend/src/pages/Profile.jsx"
    click Admin "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/frontend/src/pages/Admin.jsx"
    click AddUser "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/frontend/src/pages/Adduser.jsx"
    click BE "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/server/index.js"
    click AUTH "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/server/routes/authRoutes.js"
    click DB "https://github.com/vikramchavan888/prevoyance-solutions/blob/main/server/lib/db.js"
    click BULK "https://github.com/vikramchavan888/prevoyance-solutions/tree/main/server/uploads/excel/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef static fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
