# krnsa/aura architecture

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

- Interactive diagram: https://gitdiagram.com/krnsa/aura
- Repository: https://github.com/krnsa/aura

## Overview

##### Project Type and Purpose
- This is a full-stack social media and e-commerce platform.
- The frontend is built on vanilla HTML, CSS, and JavaScript (using ES Modules) and operates as a Multi-Page Application (MPA).
- The backend uses Node.js with a REST API and integrates with Supabase for the database (PostgreSQL), authentication, and storage.
- It uses JWT-based authentication to secure user management, post management, and notifications.

##### Main Components
- Frontend Application
- Components: HTML pages (index.html, profile.html, etc.), CSS and JavaScript modules (e.g., login.js, profile.js, shop.js).
- Special aspects: Hot-reload capability provided through the frontend-server.js using WebSocket.
- Backend Application
- Components: The Node.js server (server.js), API endpoints (files in backend/src/api such as createPost.js, deletePost.js, getPosts.js, etc.), authentication (backend/src/auth/auth.js), and business logic/implementations for posts and notifications.
- Routing: The router defined in backend/src/router.js that ties the REST API together.
- External Integration – Supabase
- Components: Database operations, authentication services, and storage (files in backend/src/supabase/supabaseClient.js).
- Role: Acts as the data store and authentication provider.

##### Relationships and Interactions
- Backend validates user requests (using JWT authentication) and performs business logic steps such as creating posts, deleting posts, and managing notifications.
- Optionally, illustrate the Hot-Reload connection between the frontend (via frontend-server.js) and the browser, using WebSocket connections to show real-time updates during development.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly distinguish between frontend and backend responsibilities.
- Modularization: Show how the backend code is organized into API endpoints, authentication modules, and implementations, while the frontend splits functionality across different pages and JS modules.
- RESTful Design: Highlight the API endpoints and their RESTful nature.
- Integration with Third-Party Services: Emphasize the Supabase integration for handling persistent data and storage.

##### Technologies, Frameworks, and Libraries
- Frontend: HTML, CSS, JavaScript with ES Modules, and the Fetch API.
- Backend: Node.js, Express-like routing (custom router in this case), nodemon for hot reload.
- External: Supabase for database, auth, and storage; JWT for authentication.
- Deployment: Frontend is deployed on Vercel; backend can be hosted on platforms like Railway or Heroku.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser/Client
    Browser["Browser/Client"]:::browser

    %% Frontend Layer
    subgraph "Frontend Layer"
        FEApp["Frontend Application (HTML, CSS, JS)"]:::frontend
        FEHot["Hot-Reload Server (WebSocket)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BSrv["Node.js Server"]:::backend
        API["API Endpoints (REST)"]:::backend
        Auth["Authentication Module (JWT)"]:::backend
        Router["Router"]:::backend
        Biz["Business Logic"]:::backend
    end

    %% External Services
    subgraph "External Services"
        Sup["Supabase Integration"]:::external
    end

    %% Connections
    Browser -->|"HTTP_Request"| FEApp
    FEApp -->|"REST_API_Call"| API
    API -->|"Validates_with"| Auth
    API -->|"Routes_via"| Router
    API -->|"Executes"| Biz
    BSrv -->|"Manages"| API
    BSrv -->|"Communicates_with"| Sup
    Biz -->|"Handles_Data"| Sup
    FEApp -->|"LiveUpdate_via_WebSocket"| FEHot

    %% Click Events
    click FEApp "https://github.com/krnsa/aura/tree/main/frontend/"
    click FEHot "https://github.com/krnsa/aura/blob/main/frontend/frontend-server.js"
    click BSrv "https://github.com/krnsa/aura/blob/main/backend/server.js"
    click API "https://github.com/krnsa/aura/tree/main/backend/src/api/"
    click Auth "https://github.com/krnsa/aura/blob/main/backend/src/auth/auth.js"
    click Router "https://github.com/krnsa/aura/blob/main/backend/src/router.js"
    click Biz "https://github.com/krnsa/aura/tree/main/backend/src/implementations/"
    click Sup "https://github.com/krnsa/aura/blob/main/backend/src/supabase/supabaseClient.js"

    %% Styles
    classDef frontend fill:#a6cee3,stroke:#1f78b4,stroke-width:2px;
    classDef backend fill:#b2df8a,stroke:#33a02c,stroke-width:2px;
    classDef external fill:#cccccc,stroke:#999999,stroke-width:2px;
    classDef browser fill:#ffcc99,stroke:#ff9933,stroke-width:2px;
```
