# omeraqeel/docunest architecture

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

- Interactive diagram: https://gitdiagram.com/omeraqeel/docunest
- Repository: https://github.com/omeraqeel/docunest

## Overview

##### Project type and purpose
- This is a full-stack web application. The front-end is a React single-page application (SPA) bootstrapped with Create React App (Vite + React + Tailwind CSS), and the back-end is a Python service (likely Flask or FastAPI) exposing RESTful endpoints for authentication, file processing, and relevance scoring.
- The README confirms standard CRA scripts; the file tree shows React code under src/, a Python backend under backend/, and JSON/config files at the root.

##### File structure
- Top-level:
- backend/ – Python modules:
– main.py (entry point, API routes)
– jwtAuthentication.py (JWT‐based auth middleware)
– models.py (data models, ORM)
– file_processing.py (file ingestion, parsing)
– relevance_scoring.py (business logic, ranking algorithms)
- src/ – React code:
– Components/ & ui/ – reusable UI components
– Pages/ – route-based pages (Chat, Dashboard, Workspace, Profile, SignIn, SignUp)
– store/ – Redux store slices (userSlice.js)
– hooks/, lib/, layout.jsx – app wiring, utilities, routing
- public/, index.html, package.json, tailwind.config.js, vite.config.js – front-end build/config
- No explicit database config file is shown, but models.py indicates a data persistence layer (could be PostgreSQL, SQLite, etc.).
- JWT auth and CORS will be configured in the Python backend.

##### README
- No mention of WebSocket or external AI services, so assume all logic lives in the Python backend.

a. Main components:
- Client (Web Browser)
- Front-end SPA (React + Vite + Tailwind)
- Back-end API Server (Python app)
- Authentication module (JWT)
- Business logic (file processing, relevance scoring)
- Data persistence (Database, File storage)
b. Relationships & interactions:
1. Client loads index.html → React SPA served (either from static host or backend)
2. SPA dispatches REST calls to the API server over HTTPS
3. User signs up / signs in → SPA calls POST /auth → JWT returned → SPA stores token
4. Subsequent API calls include JWT header → backend middleware validates token
5. For file upload/listing: SPA → backend/file_processing endpoints → files written to storage, metadata in DB
6. For relevance scoring: SPA → backend/relevance_scoring endpoints → backend applies algorithms → response returned
7. Data layer: backend ↔ database (CRUD via models.py)
c. Architectural patterns & design principles:
- SPA architecture with clear separation of concerns (UI components, routing, state management)
- RESTful API pattern in the backend
- JWT‐based stateless authentication
- Modular Python services for business logic (single-responsibility modules)
- Redux or Context for client state
d. Key technologies/frameworks:
- React, Vite, Tailwind CSS on the front end
- Python (Flask or FastAPI), PyJWT, ORM (SQLAlchemy or similar) on the back end
- Redux Toolkit for state management
- JSON config files (jsconfig.json, components.json) for feature flags or metadata

##### Elements
- Browser → Frontend (initial load)
- Frontend → Backend (REST calls with JWT)
- Backend → Database (ORM calls)
- Backend → Frontend (JSON responses)
- Green for API endpoints/business logic
- Orange for data stores

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Browser/Client"]:::infra

    %% Frontend Layer
    subgraph "Frontend (React + Vite + Tailwind)"
        direction TB
        pkgJson["package.json"]:::infra
        viteConfig["vite.config.js"]:::infra
        tailwindConfig["tailwind.config.js"]:::infra
        indexHtml["index.html"]:::infra
        jsconfig["jsconfig.json"]:::infra
        componentsJson["components.json"]:::infra

        entryIndex["src/index.jsx"]:::ui
        appJsx["src/App.jsx"]:::ui

        layoutJsx["src/layout.jsx"]:::ui
        protected["src/ProtectedRoute.jsx"]:::ui

        subgraph "Pages"
            direction TB
            signIn["src/Pages/SignIn.jsx"]:::ui
            signUp["src/Pages/SignUp.jsx"]:::ui
            dashboard["src/Pages/Dashboard.jsx"]:::ui
            profile["src/Pages/Profile.jsx"]:::ui
            chat["src/Pages/Chat.jsx"]:::ui
            workspace["src/Pages/Workspace.jsx"]:::ui
            fileViewer["src/Pages/FileViewer.jsx"]:::ui
            workspacesContainer["src/Pages/WorkspacesContainer.jsx"]:::ui
        end

        componentsDir["src/Components/"]:::ui
        uiPrimitives["src/Components/ui/"]:::ui

        storeStore["src/store/store.js"]:::ui
        userSlice["src/store/userSlice.js"]:::ui

        hookMobile["src/hooks/use-mobile.jsx"]:::ui
        utilsLib["src/lib/utils.js"]:::ui
    end

    %% Backend Layer
    subgraph "Backend (Python API)"
        direction TB
        BE_main["backend/main.py"]:::api
        BE_jwt["backend/jwtAuthentication.py"]:::api
        BE_models["backend/models.py"]:::api
        BE_fileProc["backend/file_processing.py"]:::api
        BE_score["backend/relevance_scoring.py"]:::api
    end

    %% Data Layer
    Database[(Database)]:::db

    %% Connections
    Browser -->|Loads SPA| entryIndex
    entryIndex -->|"renders"| appJsx
    appJsx -->|"uses routing"| layoutJsx
    layoutJsx -->|"protects routes"| protected
    layoutJsx -->|"renders pages"| signIn
    layoutJsx -->|"renders pages"| signUp
    layoutJsx -->|"renders pages"| dashboard
    layoutJsx -->|"renders pages"| profile
    layoutJsx -->|"renders pages"| chat
    layoutJsx -->|"renders pages"| workspace
    layoutJsx -->|"renders pages"| fileViewer
    layoutJsx -->|"renders pages"| workspacesContainer

    signIn -->|POST /api/auth/login| BE_main
    signUp -->|POST /api/auth/signup| BE_main
    dashboard -->|GET /api/files| BE_main
    workspace -->|POST /api/files/upload| BE_main
    workspace -->|GET /api/files| BE_main
    fileViewer -->|GET /api/files/:id| BE_main
    chat -->|POST /api/score| BE_main

    BE_main -->|uses| BE_jwt
    BE_main -->|routes| BE_fileProc
    BE_main -->|routes| BE_score
    BE_fileProc -->|CRUD| BE_models
    BE_score -->|uses| BE_models
    BE_models -->|ORM calls| Database

    %% Click Events
    click pkgJson "https://github.com/omeraqeel/docunest/blob/main/package.json"
    click viteConfig "https://github.com/omeraqeel/docunest/blob/main/vite.config.js"
    click tailwindConfig "https://github.com/omeraqeel/docunest/blob/main/tailwind.config.js"
    click indexHtml "https://github.com/omeraqeel/docunest/blob/main/index.html"
    click jsconfig "https://github.com/omeraqeel/docunest/blob/main/jsconfig.json"
    click componentsJson "https://github.com/omeraqeel/docunest/blob/main/components.json"
    click entryIndex "https://github.com/omeraqeel/docunest/blob/main/src/index.jsx"
    click appJsx "https://github.com/omeraqeel/docunest/blob/main/src/App.jsx"
    click layoutJsx "https://github.com/omeraqeel/docunest/blob/main/src/layout.jsx"
    click protected "https://github.com/omeraqeel/docunest/blob/main/src/ProtectedRoute.jsx"
    click signIn "https://github.com/omeraqeel/docunest/blob/main/src/Pages/SignIn.jsx"
    click signUp "https://github.com/omeraqeel/docunest/blob/main/src/Pages/SignUp.jsx"
    click dashboard "https://github.com/omeraqeel/docunest/blob/main/src/Pages/Dashboard.jsx"
    click profile "https://github.com/omeraqeel/docunest/blob/main/src/Pages/Profile.jsx"
    click chat "https://github.com/omeraqeel/docunest/blob/main/src/Pages/Chat.jsx"
    click workspace "https://github.com/omeraqeel/docunest/blob/main/src/Pages/Workspace.jsx"
    click fileViewer "https://github.com/omeraqeel/docunest/blob/main/src/Pages/FileViewer.jsx"
    click workspacesContainer "https://github.com/omeraqeel/docunest/blob/main/src/Pages/WorkspacesContainer.jsx"
    click componentsDir "https://github.com/omeraqeel/docunest/tree/main/src/Components/"
    click uiPrimitives "https://github.com/omeraqeel/docunest/tree/main/src/Components/ui/"
    click storeStore "https://github.com/omeraqeel/docunest/blob/main/src/store/store.js"
    click userSlice "https://github.com/omeraqeel/docunest/blob/main/src/store/userSlice.js"
    click hookMobile "https://github.com/omeraqeel/docunest/blob/main/src/hooks/use-mobile.jsx"
    click utilsLib "https://github.com/omeraqeel/docunest/blob/main/src/lib/utils.js"
    click BE_main "https://github.com/omeraqeel/docunest/blob/main/backend/main.py"
    click BE_jwt "https://github.com/omeraqeel/docunest/blob/main/backend/jwtAuthentication.py"
    click BE_models "https://github.com/omeraqeel/docunest/blob/main/backend/models.py"
    click BE_fileProc "https://github.com/omeraqeel/docunest/blob/main/backend/file_processing.py"
    click BE_score "https://github.com/omeraqeel/docunest/blob/main/backend/relevance_scoring.py"

    %% Styles
    classDef ui fill:#8ecae6,stroke:#0366d6,color:#000
    classDef api fill:#a5d6a7,stroke:#2e7d32,color:#000
    classDef db fill:#ffd166,stroke:#e09f3e,color:#000
    classDef infra fill:#ffadad,stroke:#d62828,color:#000
```
