# dinxsh/vnn architecture

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

- Interactive diagram: https://gitdiagram.com/dinxsh/vnn
- Repository: https://github.com/dinxsh/vnn

## Overview

##### Project type and purpose
- VNN is a full-stack web application for “visualizing neural networks in real time.”
- The backend (in Go) implements the neural-network logic and exposes an HTTP API.
- The frontend (Next.js + React + Tailwind) provides the user interface, fetches data from the backend, and renders interactive visualizations.

##### File structure
- Top-level:
– CODE_OF_CONDUCT.md, LICENSE, readme.md
- backend/
– go.mod, go.sum (module definition)
– main.go (server entrypoint, HTTP routing)
– mlp.go (multi-layer perceptron implementation)
- frontend/
– package.json, package-lock.json (Node dependencies)
– next.config.ts, tsconfig.json (Next.js and TS configs)
– app/ (Next.js “App Router” files: layout.tsx, page.tsx)
– globals.css, tailwind.config.ts, postcss.config.mjs (styling)
– public/ (static assets)

##### README insights
- Installation instructions highlight:
- Running Go server in backend/
- Running Next.js dev server in frontend/
- Usage: Backend listens (default port), Frontend runs on port 3000, UI loads models via API calls.

##### Main components and interactions
a. Components
1) Client browser (React UI)
2) Next.js server (serves pages, bundles JS/CSS)
3) Go backend (business logic + neural-network engine)
4) (Optional) Static assets store
b. Relationships
– Browser ↔ Next.js: initial HTML/CSS/JS, hydration, client-side navigation
– Client ↔ Backend: HTTP requests (e.g., “load model,” “compute activations”)
– Next.js ↔ Backend (if using Server-Side Rendering or API routes)
c. Architectural patterns
– Client-server separation
– Component-based UI (React)
– Single binary Go service (monolith)
– Folder convention from Next.js (App Router)
d. Key technologies
– Go (net/http, mlp.go)
– Next.js (app directory, React 18)
– TypeScript, Tailwind CSS
– Node.js build chain (npm, PostCSS)

##### Step-by-step creation
1) Two large columns: “Frontend” and “Backend.”
– Next.js Server (Node.js) → serves React pages
– React Browser Client → renders UI, captures user input
– Public Assets
– HTTP API (main.go)
– Neural-Net Engine (mlp.go)
4) Connect:
– Browser Client → Next.js Server (initial page load)
– Browser Client → HTTP API (model load, compute requests)
– Next.js Server (optional) → HTTP API if SSR fetches data

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Tier
    subgraph "Frontend Tier"
        direction TB
        NextNode["Next.js Server (Node.js) :3000"]:::backendGreen
        ReactClient["React Browser Client"]:::frontendBlue
        StaticAssets["Static Assets Store"]:::staticGray
        GlobalStyles["Global Styles (Tailwind CSS & PostCSS)"]:::staticGray
    end

    %% Backend Tier
    subgraph "Backend Tier"
        direction TB
        APILayer["HTTP API Layer (Go server) :8080"]:::backendGreen
        MLPEngine["Neural Network Engine (mlp.go)"]:::backendGreen
        GoMod["Go Module Definition"]:::backendGreen
    end

    %% Connections
    ReactClient -->|"Initial Page Load"| NextNode
    NextNode -->|"Serve React App"| ReactClient
    ReactClient -->|"HTTP GET/POST"| APILayer
    NextNode -->|"SSR Data Fetch"| APILayer
    StaticAssets -->|"Serve Static Files"| ReactClient
    GlobalStyles -->|"Apply Styles"| ReactClient
    GoMod -->|"Dependencies"| APILayer
    APILayer -->|"Invoke Logic"| MLPEngine

    %% Click Events
    click ReactClient "https://github.com/dinxsh/vnn/blob/main/frontend/app/layout.tsx"
    click ReactClient "https://github.com/dinxsh/vnn/blob/main/frontend/app/page.tsx"
    click NextNode "https://github.com/dinxsh/vnn/tree/main/frontend/app/"
    click NextNode "https://github.com/dinxsh/vnn/blob/main/frontend/next.config.ts"
    click NextNode "https://github.com/dinxsh/vnn/blob/main/frontend/package.json"
    click NextNode "https://github.com/dinxsh/vnn/blob/main/frontend/tsconfig.json"
    click StaticAssets "https://github.com/dinxsh/vnn/tree/main/frontend/public/"
    click GlobalStyles "https://github.com/dinxsh/vnn/blob/main/frontend/globals.css"
    click GlobalStyles "https://github.com/dinxsh/vnn/blob/main/frontend/tailwind.config.ts"
    click GlobalStyles "https://github.com/dinxsh/vnn/blob/main/frontend/postcss.config.mjs"
    click APILayer "https://github.com/dinxsh/vnn/blob/main/backend/main.go"
    click MLPEngine "https://github.com/dinxsh/vnn/blob/main/backend/mlp.go"
    click GoMod "https://github.com/dinxsh/vnn/blob/main/backend/go.mod"
    click GoMod "https://github.com/dinxsh/vnn/blob/main/backend/go.sum"

    %% Styles
    classDef frontendBlue fill:#ADD8E6,stroke:#333,stroke-width:1px,color:#000
    classDef backendGreen fill:#90EE90,stroke:#333,stroke-width:1px,color:#000
    classDef staticGray fill:#D3D3D3,stroke:#333,stroke-width:1px,color:#000
```
