# aa846301/negativeproverb architecture

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

- Interactive diagram: https://gitdiagram.com/aa846301/negativeproverb
- Repository: https://github.com/aa846301/negativeproverb

## Overview

##### Main Components
- Frontend/API Layer – Represented by the NegativeProverb folder which holds controllers (LoginController, PostController, TagController, UserClockController, UserinfoController) along with startup (Program.cs) and configuration files.
- Business Logic Layer – Represented by the BusinessRule folder. It includes business services (LoginService, PostService, TagService, UserClockService, UserinfoService) and interfaces (e.g., IPostService.cs). This layer encapsulates application-specific rules and operations.
- Data Access Layer – Represented by the DataAccess folder. This includes:
- Business models for different domain operations (Login, Post, UserClock, Userinfo, etc.).
- The EF Core setup (ProjectContext and entity files such as Post_Post, Post_PostTag, etc.).
- LINQ-based data queries are used between the DataAccess layer and EF Core.
- Common Utilities – Represented by the Common folder. This contains elements like utility classes (EncryptionHelper, MailHelper, RandomHelper), attributes (ServiceAttribute), and extension helpers (ServiceCollectionExtension), which can be used across the other components.
- External Dependencies – Include MsSQL (as defined in the README) and potential external integrations indicated for future features like social sharing and notifications.

##### Relationships and Interactions
- The API Layer (controllers) interacts with the Business Logic Layer (services) to process user requests. For example, the LoginController calls the LoginService for handling user registration or login functionality.
- The Business Layer encapsulates core business rules and communicates with the Data Access Layer to perform CRUD operations against the database.
- The DataAccess layer uses Entity Framework Core to map business models to the underlying database (MsSQL) and to perform LINQ queries.
- Common components support various layers by providing utility functions, helper methods, and extension methods that standardize aspects of application behavior.

##### Architectural Patterns/Principles
- Layered Architecture: Separate concerns into API, Business, and Data Access Layers.
- Dependency Injection: Evident by the use of ServiceCollectionExtension in the Common folder.
- Separation of Concerns: Distinct projects/layers handling business rules, data access, and common utilities.
- Modular Design: The project is split into multiple components making it easier to extend (e.g., future features such as social sharing, multi-language support).
- Use of Interfaces: For abstraction of services (e.g., IPostService) which promotes loose coupling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "API Layer"
        APICtrl("Controllers"):::api
        APIStartup("Program.cs"):::api
    end

    subgraph "Business Logic Layer"
        Services("Business Services"):::business
        Interfaces("Business Interfaces"):::business
    end

    subgraph "Data Access Layer"
        EFCore("ProjectContext & Entity Models"):::data
    end

    Common("Common Utilities"):::common
    DB("MsSQL Database"):::db

    APICtrl -->|"calls"| Services
    APIStartup -->|"configures"| Services
    Interfaces ---|"defines"| Services
    Services -->|"invokes"| EFCore
    EFCore -->|"persists"| DB

    Common ---|"supports"| Services
    Common ---|"supports"| EFCore

    click APICtrl "https://github.com/aa846301/negativeproverb/tree/master/NegativeProverb/Controllers"
    click APIStartup "https://github.com/aa846301/negativeproverb/blob/master/NegativeProverb/Program.cs"
    click Services "https://github.com/aa846301/negativeproverb/tree/master/BusinessRule/Service"
    click Interfaces "https://github.com/aa846301/negativeproverb/tree/master/BusinessRule/Interface"
    click EFCore "https://github.com/aa846301/negativeproverb/tree/master/DataAccess/ProjectContext"
    click Common "https://github.com/aa846301/negativeproverb/tree/master/Common"

    classDef api fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef business fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef data fill:#ffa500,stroke:#333,stroke-width:2px;
    classDef common fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef db fill:#dda0dd,stroke:#333,stroke-width:2px;
```
