# sandeshprasai/smartinvoice architecture

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

- Interactive diagram: https://gitdiagram.com/sandeshprasai/smartinvoice
- Repository: https://github.com/sandeshprasai/smartinvoice

## Overview

##### Project Type and Purpose
- This is a full-stack MEVN (MongoDB, Express, Vue, Node) cloud-based invoicing application (“Smart Invoice”).
- Frontend: Vue.js SPA for user authentication, dashboard, invoice CRUD, PDF download.
- Backend: Express.js REST API, MongoDB persistence, OTP & email workflows, scheduled tasks, file-upload handling.

##### File Structure Analysis
- Top-level folders:
- Backend/ – Express app source
- vue-frontend/ – Vue.js client
- Backend substructure:
- config/db.js – Mongo connection config
- models/ – Mongoose schemas: users, invoices, OTPs
- routes/index.js – API entrypoints
- userController/ – Controllers for auth, invoice operations, OTP, reset flows
- util/ – Helpers (validation, OTP generation, mailSender, logger, PDF helper)
- scheduler.js – Cron job or periodic tasks
- uploads/ – Persisted invoice PDFs
- Frontend substructure:
- public/ – index.html
- src/ – Vue entry (main.js, App.vue), router.js, Pinia store, reusable components, pages (dashboard, login, signup, reset password)
- utills/ – token checker, PDF utilities

##### Key README Insights
- Emphasizes user authentication, invoice management, due-date tracking, discounts/shipping.
- Describes tech stack, setup steps, environment variables (.env).

- Backend modules: config/db.js, models, routes, controllers, utils, scheduler.
- Vue pages and components (LoginPage, Dash_Board, OtpInput).
- Flow: sign-up/login → receive OTP → JWT stored in Pinia → token validated on each API call.
- Where PDF utilities generate and download invoice files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend App" 
        direction TB
        Browser["User's Browser (Vue.js SPA)"]:::frontend
        Router["Vue Router"]:::frontend
        Pinia["Pinia Store"]:::frontend
        TokenUtil["Token Checker Util"]:::frontend
        PdfUtilClient["PDF Utilities (client-side)"]:::frontend
        subgraph "Pages & Components"
            direction TB
            LoginPage["LoginPage"]:::frontend
            SignUp["SignUp"]:::frontend
            ResetPass["Reset Password"]:::frontend
            OtpInput["OTP Input Component"]:::frontend
            Dashboard["Dashboard Page"]:::frontend
            InvoiceGuide["Invoice Guide Page"]:::frontend
            SettingsPage["Settings Page"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Service"
        direction TB
        API["Express API Server"]:::backend
        ConfigDB["MongoDB Config"]:::backend
        Routes["API Routes"]:::backend
        subgraph Models
            direction TB
            UserModel["User Model"]:::backend
            InvoiceModel["Invoice Model"]:::backend
            OTPModel["OTP Model"]:::backend
        end
        subgraph Controllers
            direction TB
            VerifyOtp["verifyOtp"]:::backend
            RefreshToken["refresh-token"]:::backend
            VerifyResetEmail["verifyResetEmail"]:::backend
            ResetPassword["resetPassword"]:::backend
            InsertInvoice["insertInvoice"]:::backend
            LoadInvoices["loadInvoices"]:::backend
            UpdateInvoice["updateInvoiceStatus"]:::backend
            DownloadInvoice["DownloadInvoice"]:::backend
        end
        UploadHelper["File Upload Helper"]:::backend
        subgraph Utils
            direction TB
            MailSender["Email Sender"]:::backend
            OTPGen["OTP Generation"]:::backend
            InvoiceHelper["Invoice PDF Helper"]:::backend
            ValidateInputs["validateInputs"]:::backend
            ValidateOtpInputs["validateOtp-inputs"]:::backend
            ValidateToken["validateToken"]:::backend
            ValidateUser["validateuser"]:::backend
            Logger["Logging Utility"]:::backend
        end
        Scheduler["Scheduler (cron)"]:::backend
        Uploads["Uploaded Invoice Storage"]:::storage
    end

    %% External Services
    subgraph "External Services"
        SMTP["SMTP Email Provider"]:::external
        MongoDB["MongoDB Database"]:::db
    end

    %% Relationships
    Browser --> Router
    Browser -->|"HTTP REST"| API
    Router -->|navigates| LoginPage
    Router --> SignUp
    Router --> ResetPass
    Router --> Dashboard
    Router --> InvoiceGuide
    Router --> SettingsPage
    LoginPage -->|dispatch| Pinia
    SignUp --> Pinia
    ResetPass --> Pinia
    OtpInput -->|uses| TokenUtil
    Dashboard -->|fetch data| API
    InvoiceGuide -->|download PDF| PdfUtilClient
    API --> Routes
    Routes --> Controllers
    Controllers --> Models
    API -->|connects| ConfigDB
    API -->|CRUD| MongoDB
    API -->|store/retrieve| Uploads
    Uploads -->|filesystem| UploadHelper
    API -->|send email| SMTP
    Controllers -->|use| MailSender
    Controllers -->|use| OTPGen
    Controllers -->|use| InvoiceHelper
    Controllers -->|validate| ValidateInputs
    Controllers -->|validate| ValidateOtpInputs
    Controllers -->|auth| ValidateToken
    Controllers -->|auth| ValidateUser
    Controllers -->|log| Logger
    Scheduler -->|jobs| Controllers
    Scheduler -->|read/write| MongoDB

    %% Click Events - Frontend
    click Browser "https://github.com/sandeshprasai/smartinvoice/tree/master/vue-frontend/src"
    click Router "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/router.js"
    click Pinia "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/stores/userNameStore.js"
    click TokenUtil "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/utills/checkTokenStatus.js"
    click PdfUtilClient "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/utills/pdfUtils.js"
    click LoginPage "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/pages/LoginPage.vue"
    click SignUp "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/pages/SignUp.vue"
    click ResetPass "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/pages/Reset_Password.vue"
    click OtpInput "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/components/OtpInput.vue"
    click Dashboard "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/pages/Dash_Board.vue"
    click InvoiceGuide "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/pages/InvoiceGuide.vue"
    click SettingsPage "https://github.com/sandeshprasai/smartinvoice/blob/master/vue-frontend/src/pages/SettingsPage.vue"

    %% Click Events - Backend
    click API "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/index.js"
    click ConfigDB "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/config/db.js"
    click Routes "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/routes/index.js"
    click UserModel "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/models/usermodels.js"
    click InvoiceModel "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/models/InvoiceModel.js"
    click OTPModel "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/models/otpModel.js"
    click VerifyOtp "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/verifyOtp.js"
    click RefreshToken "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/refresh-token.js"
    click VerifyResetEmail "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/verifyResetEmail.js"
    click ResetPassword "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/resetPassword.js"
    click InsertInvoice "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/insertInvoice.js"
    click LoadInvoices "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/loadInvoices.js"
    click UpdateInvoice "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/updateInvoiceStatus.js"
    click DownloadInvoice "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/userController/DownloadInvoice.js"
    click UploadHelper "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/Helper/uploadFile.js"
    click Scheduler "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/scheduler.js"
    click MailSender "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/mailSender.js"
    click OTPGen "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/otpGeneration.js"
    click InvoiceHelper "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/InvoiceHelper.js"
    click ValidateInputs "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/validateInputs.js"
    click ValidateOtpInputs "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/validateOtp-inputs.js"
    click ValidateToken "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/validateToken.js"
    click ValidateUser "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/validateuser.js"
    click Logger "https://github.com/sandeshprasai/smartinvoice/blob/master/Backend/util/logger.js"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#2980B9,color:#1B4F72
    classDef backend fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef db fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
    classDef storage fill:#FEF9E7,stroke:#F39C12,color:#7E5109
    classDef external fill:#FADBD8,stroke:#E74C3C,color:#641E16
```
