# anjali76codes/doculens---automatic_document_verification architecture

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

- Interactive diagram: https://gitdiagram.com/anjali76codes/doculens---automatic_document_verification
- Repository: https://github.com/anjali76codes/doculens---automatic_document_verification

## Overview

##### Project Overview & Key Components
- Recognize that Doculens is a full-stack, MERN application whose primary purpose is to verify documents (Aadhar, additional documents) by extracting text and matching facial data via the Microsoft Face API.
- The system includes a clearly segregated frontend (React using Vite) and backend (Node.js/Express.js) structure, with a MongoDB database (as per the README) and external integration with Microsoft Face API.

##### Analyzing the File Structure
- The top-level directories “frontend” and “backend” make the separation obvious.
- The backend directory contains:
- Controllers: Business logic for details and user management.
- Models: Schema definitions for Details, Document, and User.
- Routes: HTTP endpoints segregated by concerns (detailsRoutes, document, user.route).
- An “uploads” folder for storing document files.
- An “extract_text.py” which hints at Python-based text extraction – possibly running OCR or leveraging some external library.
- The frontend directory features:
- A React codebase with components (FaceDetection, Navbar, OCRComponent) and pages (AdminReview, DocumentUpload, Home, LandingPage, etc.).
- Configuration files for ESLint, Tailwind, and Vite suggesting modern front-end tooling.
- A Firebase.js file, implying possible Firebase integration (for notifications or storage).

a. Main Components:
- Backend (Express.js): Represent components (routes, controllers, models). Label subcomponents clearly for user-related operations, document management, and text extraction.
- Additional (Firebase): If applicable, mark any real-time feature (e.g., notifications) or configuration that connects with Firebase.

b. Relationships & Interactions:
- File upload process – how documents from the Frontend are sent to the Backend, stored in the "uploads" directory, and processed (with text extraction via Python and subsequent face matching).

c. Architectural Patterns & Design Principles:
- Model-View-Controller (MVC) approach on the backend.
- Separation of concerns: clearly delineate where validation, business logic, and data storage occurs.
- Asynchronous/control flow involved in external API interactions.

d. Technologies & Tools:
- Additional important files that hint at configuration (like ESLint, Tailwind, and Vite configurations on the frontend) though they are less central to the high-level architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        FE["React Frontend"]:::frontend
        FD["Face Detection Component"]:::frontend
        OCR["OCR Component"]:::frontend
        FP["Frontend Pages"]:::frontend
        FI["Firebase Integration"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        BE["Express Backend"]:::backend
        AR["API Routes"]:::backend
        CT["Controllers"]:::backend
        MD["Models"]:::backend
        FU["File Upload Handling"]:::backend
        TE["Text Extraction Service"]:::backend
    end

    %% External Services and Database
    MDB[("MongoDB Database")]:::external
    MFA["Microsoft Face API"]:::external

    %% Connections - Frontend to Backend
    FE -->|"apiRequest"| BE
    FP -->|"submitDoc"| AR

    %% Connections - Backend internal flow
    AR -->|"invokeController"| CT
    CT -->|"accessData"| MD
    MD -->|"updateData"| MDB
    BE -->|"handleUpload"| FU
    FU -->|"triggerOCR"| TE
    TE -->|"processText"| MD
    BE -->|"faceMatch"| MFA
    BE -->|"notifyUser"| FI

    %% Click Events
    click FE "https://github.com/anjali76codes/doculens---automatic_document_verification/tree/main/frontend/src"
    click FD "https://github.com/anjali76codes/doculens---automatic_document_verification/blob/main/frontend/src/components/FaceDetection.jsx"
    click OCR "https://github.com/anjali76codes/doculens---automatic_document_verification/blob/main/frontend/src/components/OCRComponent.jsx"
    click FP "https://github.com/anjali76codes/doculens---automatic_document_verification/tree/main/frontend/src/pages"
    click BE "https://github.com/anjali76codes/doculens---automatic_document_verification/blob/main/backend/index.js"
    click AR "https://github.com/anjali76codes/doculens---automatic_document_verification/tree/main/backend/routes"
    click CT "https://github.com/anjali76codes/doculens---automatic_document_verification/tree/main/backend/controllers"
    click MD "https://github.com/anjali76codes/doculens---automatic_document_verification/tree/main/backend/models"
    click FU "https://github.com/anjali76codes/doculens---automatic_document_verification/tree/main/backend/uploads"
    click TE "https://github.com/anjali76codes/doculens---automatic_document_verification/blob/main/backend/extract_text.py"
    click FI "https://github.com/anjali76codes/doculens---automatic_document_verification/blob/main/frontend/Firebase.js"

    %% Styles
    classDef frontend fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef backend fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef external fill:#c2f0c2,stroke:#333,stroke-width:2px;
```
