# hking0o1/cybergeeta-encryption-tool architecture

> Architecture diagram of the GitHub repository hking0o1/cybergeeta-encryption-tool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hking0o1/cybergeeta-encryption-tool
- Repository: https://github.com/hking0o1/cybergeeta-encryption-tool

## Overview

##### Project type and purpose
- SecureVault is a full-stack web application built with Next.js 14.
- It provides client-side and server-side encryption features (symmetric/asymmetric/file hashing), user authentication, and a personal vault backed by a database.

##### File structure
- Top-level “app/” folder holds Next.js 14 server-components and pages:
- app/page.tsx (home)
- app/encrypt/page.tsx & app/decrypt/page.tsx
- app/layout.tsx, app/globals.css
- “components/” contains reusable UI bits (navbar, footer, encryption-type cards) and a “components/ui” subfolder with shadcn/ui primitives.
- “hooks/” holds custom React hooks (use-mobile, use-toast).
- “lib/utils.ts” contains shared helper functions (e.g., crypto wrappers).
- Configuration: next.config.mjs, tailwind.config.ts, postcss.config.mjs, tsconfig.json.
- No visible “prisma/” folder, but README cites Prisma + NextAuth.js API routes for backend.

##### README
- Tech stack:
- Frontend: Next.js, React, Tailwind CSS, shadcn/ui
- Backend: Next.js API Routes, Prisma ORM, NextAuth.js
- DB: SQLite in development, PostgreSQL in production
- Encryption engine: Web Crypto API
- Features: AES-256, RSA, file encryption, SHA-256/512 hashing, vault storage, dark mode.

##### Core components & their interactions
a. Frontend Browser (React)
- Pages rendered via Next.js – SSR/ISR for public pages; CSR for vault interactions.
- Client-side Web Crypto API calls for encryption/decryption before any server call.
- UI components (shadcn/ui) wrapped by ThemeProvider for dark/light mode.
b. Next.js Server
- API Routes (e.g., /api/vault/create, /api/vault/fetch)
- NextAuth.js for session management
- Prisma ORM layer communicating with the database
c. Database
- SQLite (dev) or PostgreSQL (prod) stores user credentials, encrypted payloads, metadata.
d. External services
- Vercel (hosting)
- (Optional) Postgres cloud provider in production

##### Architectural patterns and design principles
- Hybrid rendering: Next.js SSR for initial pages, CSR for encryption-heavy workflows.
- API-route microservice pattern: discrete endpoints for vault CRUD.
- Context pattern for theme and toast notifications.
- Separation of concerns: UI logic in components/, business logic in lib/, data access in Prisma.

##### Diagramming guidance
- Client (Browser) – e.g., blue rectangle
- External Services – gray cloud
1. User ↔ Next.js pages (HTTP/SSR)
2. Client-side: Next.js page → Web Crypto API (encrypt/decrypt)
3. Encrypted payload → API Route → Prisma → Database
4. Database → Prisma → API Route → NextAuth session validation
5. Next.js pages display decrypted data after fetching
- UI components under a “shadcn/ui” boundary; group hooks and utils as “client logic.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Browser)" 
        direction TB
        A["User Browser"]:::client

        subgraph "Next.js Frontend/SSR"
            direction TB
            PHome["Home Page"]:::frontend
            PEncrypt["Encrypt Page"]:::frontend
            PDecrypt["Decrypt Page"]:::frontend
            Layout["Global Layout"]:::frontend
            Styles["Global Styles"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            Navbar["Navbar"]:::component
            Footer["Footer"]:::component
            SymCard["Symmetric Encryption Card"]:::component
            AsymCard["Asymmetric Encryption Card"]:::component
            FileCard["File Encryption Card"]:::component
            HashUI["Hashing Utilities UI"]:::component
            PassMeter["Password Strength Meter UI"]:::component
            ThemeProv["Theme Provider Context"]:::component
            ThemeToggle["Theme Toggle Control"]:::component
        end

        subgraph "Client Logic"
            direction TB
            HooksMobile["Custom Hook – Mobile Detection"]:::logic
            HooksToast["Custom Hook – Toast Notifications"]:::logic
            Utils["Shared Utility Functions"]:::logic
            UIPrims["shadcn/ui Primitives"]:::component
        end
    end

    %% Server Side
    subgraph "Server (Next.js API Layer)" 
        direction TB
        API["Next.js API Routes"]:::api
        Auth["NextAuth.js (Session Management)"]:::api
        ORM["Prisma ORM"]:::db
    end

    %% Database
    DB["Database (SQLite/PostgreSQL)"]:::database

    %% External Services
    Cloud["Vercel / Postgres Cloud"]:::external

    %% Configuration
    subgraph "Configuration"
        direction TB
        NextConfig["next.config.mjs"]:::config
        TailwindConfig["tailwind.config.ts"]:::config
        PostCSSConfig["postcss.config.mjs"]:::config
        TSConfig["tsconfig.json"]:::config
        StylesGlobal["Global Tailwind Styles"]:::config
    end

    %% Data Flows
    A -->|"HTTP/SSR"| PHome
    A -->|"HTTP/CSR"| PEncrypt
    A -->|"HTTP/CSR"| PDecrypt

    PEncrypt -->|"Web Crypto API"| Utils
    PDecrypt -->|"Web Crypto API"| Utils

    PEncrypt -->|"POST Encrypted Payload"| API
    PDecrypt -->|"POST Encrypted Payload"| API
    PHome -->|"GET Data"| API

    API -->|"calls"| ORM
    API -->|"validates session"| Auth
    Auth -->|"uses"| ORM
    ORM -->|"reads/writes"| DB

    DB -->|"prod replication"| Cloud

    %% Configuration Links
    NextConfig -->|loaded by| API
    NextConfig -->|loaded by| PHome
    TailwindConfig -->|styling| Styles
    PostCSSConfig -->|styling| Styles
    TSConfig -->|type checking| PHome
    StylesGlobal -->|global styles| Styles

    %% Click Events
    click PHome "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/app/page.tsx"
    click PEncrypt "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/app/encrypt/page.tsx"
    click PDecrypt "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/app/decrypt/page.tsx"
    click Layout "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/app/layout.tsx"
    click Styles "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/app/globals.css"
    click Navbar "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/navbar.tsx"
    click Footer "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/footer.tsx"
    click SymCard "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/symmetric-encryption.tsx"
    click AsymCard "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/asymmetric-encryption.tsx"
    click FileCard "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/file-encryption.tsx"
    click HashUI "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/hashing.tsx"
    click PassMeter "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/password-strength.tsx"
    click ThemeProv "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/theme-provider.tsx"
    click ThemeToggle "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/components/theme-toggle.tsx"
    click HooksMobile "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/hooks/use-mobile.tsx"
    click HooksToast "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/hooks/use-toast.tsx"
    click Utils "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/lib/utils.ts"
    click UIPrims "https://github.com/hking0o1/cybergeeta-encryption-tool/tree/main/components/ui/"
    click NextConfig "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/next.config.mjs"
    click TailwindConfig "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/postcss.config.mjs"
    click TSConfig "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/tsconfig.json"
    click StylesGlobal "https://github.com/hking0o1/cybergeeta-encryption-tool/blob/main/styles/globals.css"

    %% Styles
    classDef client fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px
    classDef frontend fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px
    classDef component fill:#FFF9C4,stroke:#F57F17,stroke-width:2px
    classDef logic fill:#D1C4E9,stroke:#4A148C,stroke-width:2px
    classDef api fill:#FFCCBC,stroke:#BF360C,stroke-width:2px
    classDef db fill:#B2DFDB,stroke:#004D40,stroke-width:2px
    classDef database fill:#80CBC4,stroke:#004D40,stroke-width:2px
    classDef external fill:#ECEFF1,stroke:#37474F,stroke-width:2px
    classDef config fill:#F0F4C3,stroke:#827717,stroke-width:2px
```
