# stsvift/hive architecture

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

- Interactive diagram: https://gitdiagram.com/stsvift/hive
- Repository: https://github.com/stsvift/hive

## Overview

1. Backend – A .NET-based API server that manages authentication, user management, task management, notes, folders, and dashboard functions.
2. Frontend – A React application written in TypeScript that serves as the client interface for interacting with the system.

- Main Components to Include:
- Frontend Client: Represented as the “frontend” component that includes pages (e.g., Auth, Dashboard, Memory, etc.), components (e.g., Header, Navigation, Modal), API service layers, context, hooks, and routing.
- Backend API Server: Represented as the “backend” component with submodules such as Controllers (e.g., AuthController, DashboardController, etc.), Models (e.g., Folder, Note, UserTask), Services (e.g., AuthService, FolderService), and the Data layer (with AppDbContext).
- Database: A MySQL database (as indicated by the system requirements) that stores the persistent data for tasks, notes, users, etc.
- External Dependencies: Node.js (for the frontend build environment) and the .NET environment (for backend).

- Relationships and Interactions:
- Within the backend, data flow should be represented from Controllers to Services (business logic) and then to the Data layer (managed by Entity Framework’s AppDbContext).

- Architectural Patterns and Design Principles:
- Separation of Concerns: The clear division between frontend and backend illustrates a boundary between the client-side (user interface and UX management, state management via React’s context and hooks) and the server-side (data, business logic, and API management).
- MVC Style Approach: The structure inside the backend (Controllers, Models, and Services) reflects typical MVC (or more precisely, a layered architecture).
- API-first Communication: All frontend interactions occur via structured RESTful API calls as represented by the numerous API service files in the frontend.

- Technologies, Frameworks, and Tools:
- Frontend: React, TypeScript, Vite for bundling, and Axios for API calls (as inferred from the presence of axios.config.ts).
- Backend: .NET (version 9.0 as per the README), with controllers, models, data context for MySQL (implied by system requirements), and REST API endpoints.
- Supporting Tools: Node.js (18+), MySQL database, and development tooling as defined in the respective documentation.

- A “Frontend” block showing components such as pages, components, context, and API service layers.
- A “Backend” block showing Controllers, Services, Models, and Data (with AppDbContext).
- A “Database” block representing the MySQL database.
- API calls flowing from the frontend to different backend endpoints.
- Data operations flowing from the backend’s Service/Controller layers to the Database.
- “AuthController”, “DashboardController”, etc., on the backend.
- “Auth API Service”, “Notes API Service” in the frontend.
- How incoming API requests are processed by Controllers, invoke logic in Services, interact with Models, and then use the AppDbContext to update or query the Database.

- Final Tips for the Principal Software Engineer:
- Be as detailed as possible. Aim to capture every essential component represented in the file tree.
- Work top-down from high-level components (frontend, backend, database) and then expand into finer details like internal routing, context handling in React, and service layers in .NET.
- Source the details from the provided API.md and the README files in both frontend and backend for any additional architectural insights.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend"
        FE["Frontend Client"]:::frontend
        FE_Pages["Pages"]:::frontend
        FE_Components["UI Components"]:::frontend
        FE_API["API Service Layers"]:::frontend
        FE_API_Services["API Services"]:::frontend
        FE_Context["Context Providers"]:::frontend
        FE_Hooks["Hooks"]:::frontend
        FE_Router["Routing"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        BE["Backend API Server"]:::backend
        BE_Ctrl["Controllers"]:::backend
        BE_Services["Services"]:::backend
        BE_Models["Models"]:::backend
        BE_Data["Data Layer (AppDbContext)"]:::backend
    end

    %% Database Subgraph
    subgraph "Database"
        DB["MySQL Database"]:::database
    end

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        EXTDotNet[".NET Environment"]:::external
        EXTNode["Node.js Environment"]:::external
    end

    %% Internal Frontend Connections
    FE --> FE_Pages
    FE_Pages --> FE_API
    FE_API --> FE_API_Services
    FE_API --> FE_Context
    FE_API --> FE_Hooks
    FE_Pages --> FE_Router
    FE_Components --> FE_Pages

    %% Frontend to Backend Communication
    FE_API_Services -->|"RESTcalls"| BE_Ctrl

    %% Internal Backend Connections
    BE_Ctrl -->|"Invokes"| BE_Services
    BE_Services -->|"Processes"| BE_Models
    BE_Services -->|"Databaseops"| BE_Data
    BE_Data -->|"PersistsData"| DB

    %% External Dependencies Connections
    FE -->|"Buildwith"| EXTNode
    BE -->|"Runson"| EXTDotNet

    %% Click Events for Frontend
    click FE "https://github.com/stsvift/hive/tree/main/frontend/"
    click FE_Pages "https://github.com/stsvift/hive/tree/main/frontend/src/pages/"
    click FE_Components "https://github.com/stsvift/hive/tree/main/frontend/src/components/"
    click FE_API "https://github.com/stsvift/hive/tree/main/frontend/src/api/"
    click FE_API_Services "https://github.com/stsvift/hive/tree/main/frontend/src/api/services/"
    click FE_Context "https://github.com/stsvift/hive/tree/main/frontend/src/context/"
    click FE_Hooks "https://github.com/stsvift/hive/tree/main/frontend/src/hooks/"
    click FE_Router "https://github.com/stsvift/hive/blob/main/frontend/src/router.tsx"

    %% Click Events for Backend
    click BE "https://github.com/stsvift/hive/tree/main/backend/"
    click BE_Ctrl "https://github.com/stsvift/hive/tree/main/backend/Controllers/"
    click BE_Services "https://github.com/stsvift/hive/tree/main/backend/Services/"
    click BE_Models "https://github.com/stsvift/hive/tree/main/backend/Models/"
    click BE_Data "https://github.com/stsvift/hive/blob/main/backend/Data/AppDbContext.cs"

    %% Styles
    classDef frontend fill:#8FBC8F,stroke:#333,stroke-width:2px;
    classDef backend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
