# togethernotes/api architecture

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

- Interactive diagram: https://gitdiagram.com/togethernotes/api
- Repository: https://github.com/togethernotes/api

## Overview

Based on our analysis of the file tree and README, the TogetherNotes API is a .NET Web API project designed as the backend for multiple client platforms (an Android app and a Windows Forms app) that manage user accounts, performances, contracts, messaging, and ratings. The system leverages ASP.NET Web API (with built-in HelpPage areas), Entity Framework for data management, JWT for authentication, and SignalR for real-time communication.

- Client Applications: Represent the Android and Windows Forms apps as separate external components. They are the primary consumers of the API.
- Authentication & Real-Time Communication: Include JWT Authentication as a security layer that intercepts and validates requests coming into the API. Also, represent SignalR separately as a component that handles real-time messaging and notifications.
- Database: Clearly mark the Database (likely SQL Server or another relational database) that the Entity Framework interacts with.

##### Architectural Patterns & Technologies
- MVC/MVCS architecture typical in ASP.NET projects. Even though the API may not have a rich UI, the separation into Controllers, Models (found in the Models directory and the EF context), and Views (for HelpPage and minimal UI) is apparent.
- That the HelpPage area is included for API documentation. Although auxiliary, include it as a subcomponent under the API Gateway to denote its role for developers.

- Inside or adjacent to the API Gateway, list out the various Controllers for user management, performance management, contract handling, messaging, and ratings.
- Finally, illustrate the database as the end point of data operations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications
    subgraph "Client Applications"
        android["Android App"]:::external
        windows["Windows Forms App"]:::external
    end

    %% API Layer
    subgraph "API Layer"
        apiGW["API Gateway (ASP.NET Web API)"]:::api
        auth["Authentication (JWT)"]:::auth
        helpPage["HelpPage (API Documentation)"]:::docs
    end

    %% Business Logic Controllers
    subgraph "Business Logic Controllers"
        usersC["UsersController"]:::controller
        performC["PerformancesController"]:::controller
        contractsC["ContractsController"]:::controller
        messagesC["MessagesController"]:::controller
        ratingsC["RatingsController"]:::controller
    end

    %% Data Access and Real-time Communication
    dataAccess["Entity Framework Data Access"]:::dal
    signalR["Real-time Communication (SignalR)"]:::realtime

    %% Connections from Clients to API
    android -->|"HTTP/HTTPS"| apiGW
    windows -->|"HTTP/HTTPS"| apiGW

    %% API Layer connections
    apiGW -->|"validate"| auth
    apiGW -->|"docAccess"| helpPage

    %% Routing from API Gateway to Controllers
    apiGW -->|"routes-to"| usersC
    apiGW -->|"routes-to"| performC
    apiGW -->|"routes-to"| contractsC
    apiGW -->|"routes-to"| messagesC
    apiGW -->|"routes-to"| ratingsC

    %% Controllers interacting with Data Access Layer
    usersC -->|"CRUD"| dataAccess
    performC -->|"CRUD"| dataAccess
    contractsC -->|"CRUD"| dataAccess
    messagesC -->|"CRUD"| dataAccess
    ratingsC -->|"CRUD"| dataAccess

    %% Real-time messaging through SignalR
    messagesC -->|"push-notify"| signalR

    %% Click Events
    click apiGW "https://github.com/togethernotes/api/tree/master/WebApplicationTgtNotes/Controllers"
    click helpPage "https://github.com/togethernotes/api/tree/master/WebApplicationTgtNotes/Areas/HelpPage"
    click dataAccess "https://github.com/togethernotes/api/tree/master/WebApplicationTgtNotes/Models"
    click auth "https://github.com/togethernotes/api/blob/master/WebApplicationTgtNotes/App_Start/WebApiConfig.cs"

    %% Styles
    classDef external fill:#f9d3a4,stroke:#a52a2a,stroke-width:2px;
    classDef api fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef auth fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef dal fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef realtime fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef docs fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
```
