# jameswong3388/notemercy_extension architecture

> Architecture diagram of the GitHub repository jameswong3388/notemercy_extension, 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/jameswong3388/notemercy_extension
- Repository: https://github.com/jameswong3388/notemercy_extension

## Overview

##### Main Components
- Frontend: A Next.js application that uses Tailwind CSS and modern frontend libraries (as seen by the Next.js configuration, pages, and an extensive components library).
- Backend API: A Python FastAPI server (api.py) that provides endpoints for receiving handwriting test cases, communicating with the frontend, and invoking handwriting analysis.
- Analysis Libraries: These consist of both MATLAB/M (“.m”) and Python (“.py”) modules organized under backend/lib, backend/lib_py, and backend/legacy. They represent specific analyzers for different handwriting styles (block lettering, calligraphic, cursive, italic, print, and shorthand).
- Test Datasets: The “backend/atest” directory that holds sample handwriting images for testing various handwriting styles.

##### Relationships and Interactions
- Web Client (Frontend) makes API calls to the Backend.
- The Backend (FastAPI server) handles requests, dispatching them to specific analysis routines by leveraging libraries from lib, lib_py, and legacy.
- The analysis libraries, split by handwriting style, are the computational core. They compute features like angularity, aspect ratio, slant angle, connectivity, and more.
- Test datasets feed into the backend for either training or validating the analysis modules.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear distinctions between the presentation layer (frontend) and processing/logic layer (backend).
- Modular Design: The backend is modularized into multiple analyzers, each dedicated to a specific handwriting style.
- API-Driven Communication: The frontend and backend interact through defined API endpoints (with CORS support mentioned in the README).

- Client: “Next.js Frontend” (include references to Tailwind CSS and any UI components if desired)
- API Server: “FastAPI Backend”
- Analysis Libraries: “Handwriting Analysis Modules” (subdivide into:
· block lettering,
· calligraphic,
· cursive,
· italic,
· print,
· shorthand)
- Test Data: “Test Datasets (atest)”
- From the Frontend to the Backend (indicate API calls, data requests, and responses).
- From the Backend to the Analysis Libraries (indicate function calls or module integrations).
d. Elaborate on any configuration or helper modules if needed (such as helper.py, atest, and legacy modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Next.js Frontend\n(Tailwind CSS)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["FastAPI Backend\n(Python 3.8+)"]:::backend
        
        %% Analysis Modules Group
        subgraph "Analysis Modules"
            MATLAB["MATLAB/M Analysis Libraries"]:::analysis
            PY["Python Analysis Libraries"]:::analysis
            LEGACY["Legacy Handwriting Analysis Modules"]:::analysis
            
            %% Handwriting Styles Subgroup
            subgraph "Handwriting Styles"
                BL["Block Lettering"]:::subanalysis
                CAL["Calligraphic"]:::subanalysis
                CUR["Cursive"]:::subanalysis
                ITA["Italic"]:::subanalysis
                PRI["Print"]:::subanalysis
                SH["Shorthand"]:::subanalysis
            end
        end
    end

    %% Test Data
    DATA["Test Datasets (atest)"]:::dataset

    %% Connections
    FE -->|"API_request"| API
    API -->|"analysis_call"| MATLAB
    API -->|"analysis_call"| PY
    API -->|"analysis_call"| LEGACY
    MATLAB -->|"runs"| BL
    MATLAB -->|"runs"| CAL
    PY -->|"runs"| CUR
    PY -->|"runs"| ITA
    LEGACY -->|"runs"| PRI
    LEGACY -->|"runs"| SH
    DATA -->|"provides"| API

    %% Click Events
    click FE "https://github.com/jameswong3388/notemercy_extension/tree/main/frontend"
    click API "https://github.com/jameswong3388/notemercy_extension/blob/main/backend/api.py"
    click MATLAB "https://github.com/jameswong3388/notemercy_extension/tree/main/backend/lib"
    click PY "https://github.com/jameswong3388/notemercy_extension/tree/main/backend/lib_py"
    click LEGACY "https://github.com/jameswong3388/notemercy_extension/tree/main/backend/legacy"
    click DATA "https://github.com/jameswong3388/notemercy_extension/tree/main/backend/atest"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef analysis fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef subanalysis fill:#fff3cd,stroke:#856404,stroke-width:1px;
    classDef dataset fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
