# sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network architecture

> Architecture diagram of the GitHub repository sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network
- Repository: https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network

## Overview

##### Project Type and Purpose
- The project is a blockchain-based, autonomous, decentralized online social network. Its purpose is to offer a social networking platform where features like user posts, friend recommendations, profile management, and authentication are implemented using web technologies. The decentralized/blockchain twist implies that some core features (such as post publishing, transaction tracking, or decentralization of user data) might integrate blockchain principles even if the implementation is spread across JSP pages and Java libraries.

##### Analyzing the File Structure
- Top-Level Structure & Presentation:
- Numerous JSP files prefixed with “a_” (likely administrative views) and “u_” (user views) indicate a separation of user and administrative functionality.
- Files like index.html, connect.jsp, and separate JSP pages for login, authentication, friend requests, and posts.
- Server-Side/Backend:
- The WEB-INF directory, with the lib folder, contains key Java libraries (servlet-api, MySQL connector, mail, security libraries like bouncycastle) necessary for core application logic, database connectivity, file uploads, and secure transactions. This indicates that the web application runs on a Java EE (or similar) container.
- Data Layer:
- The DATABASE directory houses a Database.sql file, which is likely used to initialize or manage the relational database (probably MySQL as suggested by the connector library).
- Assets and Static Content:
- Directories such as css, js, images, and sources hold client-side resources (stylesheets, scripts, images, and additional JavaScript libraries such as jscharts.js for graphing).
- Tech Stack Documentation:
- Files like techstack.md and techstack.yml provide additional context about the technologies used.

##### Core Components
a. Main Components to Highlight:
- Client Layer:
- Web browsers or client applications that load HTML, CSS, and JavaScript.
- Web Frontend Layer:
- JSP Pages (“a_*” for admin views, “u_*” for user interactions, and other shared JSP files). Consider grouping these as the presentation layer.
- Application Server/Middleware:
- The Java web container (such as Tomcat) where the JSPs are executed.
- Business logic and controller functions are likely implemented implicitly across various JSP pages with supporting libraries.
- Blockchain-related logic: Although not isolated in a separate directory, key JSPs such as u_publish_tweet.jsp or u_publish_tweet_ins.jsp might include blockchain transaction handling and consensus logic. You might illustrate this as a dedicated blockchain service/module for clarity.
- Data Storage Layer:
- The SQL database (set up using Database.sql) which stores user data, posts, friend relations, etc.
- External Services and Libraries:
- External Java libraries for security (BCrypt, BouncyCastle), email integration (mail.jar), and file uploads.

b. Relationships and Interactions:
- From the JSP pages, illustrate interactions with the Application Server where the core operations (like authentication, friend recommendations, posting, graphing for analytics) are handled.
- Data flow from the Application Server to the SQL Database.
- How external libraries and components (like external mail services, security checks, and any blockchain modules) are integrated into the application server layer.
- Optionally, if the blockchain aspect is implemented as a peer-to-peer network or module, indicate interactions from the application server towards a blockchain network node or distributed ledger service.

c. Architectural Patterns & Design Principles:
- MVC Separation: Although not explicitly divided into a Model, View, Controller directory structure, the JSP files reflect a View-oriented approach with business logic embedded or delegated. Highlighting this separation aids comprehension.
- Decentralization/Blockchain Element: Emphasize how blockchain principles might be employed, even if partially integrated in the code. A dedicated blockchain module (or a conceptual block) could represent the consensus, immutable logging of certain social network transactions.
- Integration of Third-Party Libraries as support components in data security, email handling, and file management.

d. Technologies, Frameworks, or Libraries:
- Java/JSP for the view and server layers.
- MySQL (via the mysql-connector) for database operations.
- Servlets and possibly additional Java EE components.
- BouncyCastle libraries for cryptographic operations which could be central for blockchain-based security.
- JavaScript libraries (jscharts.js, cufon scripts) for client-side dynamic behavior.
- The presence of mail.jar indicates integration for email (for authentication or notifications).

##### Detailed Elements
- Component is clearly labeled (for example, “Client Browser”, “Web Frontend (JSP Views)”, “Java Web Container – Business Logic”, “SQL Database”, and “Blockchain Network Module”).
- Notable security or data transmission protocols, particularly if the blockchain implementation ensures data immutability or decentralized consensus.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        CB["Client Browser"]:::client
        C1["index.html"]:::client
        C2["CSS Assets"]:::client
        C3["JS Assets"]:::client
        C4["Images"]:::client
        C5["Charts Library"]:::client
    end

    %% Web Frontend (JSP Views)
    subgraph "Web Frontend (JSP Views)"
        JSP_Admin["Admin JSP Views"]:::frontend
        JSP_User["User JSP Views"]:::frontend
        JSP_Other["Other JSP Views"]:::frontend
    end

    %% Application Server/Middleware
    subgraph "Application Server"
        AS["Java Web Container"]:::backend
        Lib["Libraries (WEB-INF/lib)"]:::library
    end

    %% Data Storage and Blockchain Module
    DB["SQL Database"]:::database
    BC["Blockchain Transaction Module"]:::blockchain

    %% Connections from Client Layer to Web Frontend
    CB -->|"HTTP Request"| JSP_Admin
    CB -->|"HTTP Request"| JSP_User
    CB -->|"HTTP Request"| JSP_Other

    %% Connections from Web Frontend (JSP Views) to Application Server
    JSP_Admin -->|"Server Call"| AS
    JSP_User -->|"Server Call"| AS
    JSP_Other -->|"Server Call"| AS

    %% Application Server connections
    AS -->|"Database Query"| DB
    AS -->|"Invokes"| Lib
    AS <-->|"Blockchain Tx"| BC

    %% Click Events for Client Assets
    click C1 "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/index.html"
    click C2 "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/tree/master/css"
    click C3 "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/tree/master/js"
    click C4 "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/tree/master/images"
    click C5 "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/sources/jscharts.js"

    %% Click Events for Web Frontend (JSP Views)
    click JSP_Admin "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/a_all_posts.jsp"
    click JSP_User "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/u_main.jsp"
    click JSP_Other "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/connect.jsp"

    %% Click Events for Application Server/Middleware
    click AS "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/tree/master/WEB-INF"
    click Lib "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/tree/master/WEB-INF/lib"

    %% Click Events for Data Storage and Blockchain Module
    click DB "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/DATABASE/Database.sql"
    click BC "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/u_publish_tweet.jsp"
    click BC "https://github.com/sidduganeshsid/a-blockchain-based-autonomous-decentralized-online-social-network/blob/master/u_publish_tweet_ins.jsp"

    %% Styles
    classDef client fill:#e3f2fd,stroke:#0d47a1,stroke-width:2px;
    classDef frontend fill:#fce4ec,stroke:#ad1457,stroke-width:2px;
    classDef backend fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px;
    classDef database fill:#fff3e0,stroke:#ef6c00,stroke-width:2px;
    classDef blockchain fill:#ede7f6,stroke:#4527a0,stroke-width:2px;
    classDef library fill:#e0f7fa,stroke:#006064,stroke-width:2px;
```
