# sirojali/nestar architecture

> Architecture diagram of the GitHub repository sirojali/nestar, 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/sirojali/nestar
- Repository: https://github.com/sirojali/nestar

## Overview

##### Main Components
- A Node.js runtime representing the NestJS ecosystem.
- Two main applications:
- Nestar API (GraphQL-based API server)
- Nestar Batch (a background/batch processing service)
- Within the Nestar API, include key feature modules:
- Core/Global modules: App, database module, configuration libraries, DTO definitions, enums, and interceptors.
- Feature modules: Auth (with decorators and guards), Board Article, Comment, Follow, Like, Member, Property, and View.
- A persistence layer:
- Database module showing connectivity (with references to models/schemas such as BoardArticle.model.ts, Comment.model.ts, etc.)
- External Services/Deployment Platforms:
- Integrations (for example, AWS/Mau deployment as mentioned in the README) and any build/test pipelines.

##### Relationships and Interactions
- That the Nestar API acts as a request entry point where incoming GraphQL requests hit the resolvers. The controllers (like app.resolver.ts) delegate to underlying service logic.
- That each feature module (Auth, Board Article, etc.) has its own module encapsulating its resolvers, services, and related DTOs, following the Domain-Driven Design separation.
- For the Auth module, emphasize decorators and guards (e.g., roles.guard.ts, auth.guard.ts) that control access to various endpoints.

##### Architectural Patterns and Design Principles
- Modular architecture – each feature resides in its own module and is then integrated into a root module.
- Dependency Injection, a core pattern in Nest, showing how services are utilized by resolvers and controllers.
- Layered architecture: presentation (GraphQL resolvers), business logic (services, guards, interceptors), and data layer (database module and schemas).
- If applicable, note any middleware or interceptors (like Logging.interceptor.ts) that provide cross-cutting concerns.

##### Relevant Technologies and Frameworks/Libraries
- NestJS as the Node.js framework.
- TypeScript for language features and strong typing.
- GraphQL (inferred from the numerous .resolver.ts files) as the API query language.
- Testing frameworks (as seen in test/app.e2e-spec.ts and jest-e2e.json).
- Deployment tools indicated in the README (Mau for AWS deployments).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Nestar API"
        %% Core/Global Modules
        subgraph "Core/Global Modules"
            app_module["App Module"]:::core
            app_resolver["GraphQL Resolvers"]:::core
            libs["DTO/Enums & Interceptors"]:::lib
            database["Database Module & Schemas"]:::db
            app_module --> app_resolver
        end

        %% Feature Modules
        subgraph "Feature Modules"
            %% Auth Module
            subgraph "Auth Module"
                auth_module_def["Auth Module Definition"]:::feature
                auth_service["Auth Service"]:::feature
                auth_decorators["Auth Decorators"]:::feature
                auth_guards["Auth Guards"]:::feature
                auth_module_def --> auth_service
                auth_module_def --> auth_decorators
                auth_module_def --> auth_guards
            end

            %% Board Article Module
            subgraph "Board Article Module"
                board_article_resolver["Board Article Resolver"]:::feature
                board_article_service["Board Article Service"]:::feature
                board_article_resolver --> board_article_service
            end

            %% Comment Module
            subgraph "Comment Module"
                comment_resolver["Comment Resolver"]:::feature
                comment_service["Comment Service"]:::feature
                comment_resolver --> comment_service
            end

            %% Follow Module
            subgraph "Follow Module"
                follow_resolver["Follow Resolver"]:::feature
                follow_service["Follow Service"]:::feature
                follow_resolver --> follow_service
            end

            %% Like Module
            subgraph "Like Module"
                like_service["Like Service"]:::feature
            end

            %% Member Module
            subgraph "Member Module"
                member_resolver["Member Resolver"]:::feature
                member_service["Member Service"]:::feature
                member_resolver --> member_service
            end

            %% Property Module
            subgraph "Property Module"
                property_resolver["Property Resolver"]:::feature
                property_service["Property Service"]:::feature
                property_resolver --> property_service
            end

            %% View Module
            subgraph "View Module"
                view_service["View Service"]:::feature
            end
        end

        %% Relationships: GraphQL entry dispatches to feature resolvers/services
        app_resolver -->|"dispatches"| auth_module_def
        app_resolver -->|"dispatches"| board_article_resolver
        app_resolver -->|"dispatches"| comment_resolver
        app_resolver -->|"dispatches"| follow_resolver
        app_resolver -->|"dispatches"| member_resolver
        app_resolver -->|"dispatches"| property_resolver
        app_resolver -->|"dispatches"| like_service
        app_resolver -->|"dispatches"| view_service

        %% Services interacting with Database
        auth_service -->|"queries"| database
        board_article_service -->|"queries"| database
        comment_service -->|"queries"| database
        follow_service -->|"queries"| database
        member_service -->|"queries"| database
        property_service -->|"queries"| database
        like_service -->|"queries"| database
        view_service -->|"queries"| database

        %% Libraries used by services (dependency)
        libs --- auth_service
        libs --- board_article_service
        libs --- comment_service
        libs --- follow_service
        libs --- member_service
        libs --- property_service
        libs --- like_service
        libs --- view_service
    end

    subgraph "Nestar Batch"
        batch["Batch Processing Service"]:::batch
    end

    %% External Deployment/Integration
    deployment["AWS/Mau Deployment"]:::external
    app_module --> deployment
    batch --> deployment

    %% Class Definitions for styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px;
    classDef feature fill:#bbf,stroke:#333,stroke-width:2px;
    classDef lib fill:#bfb,stroke:#333,stroke-width:2px;
    classDef db fill:#fcf,stroke:#333,stroke-width:2px;
    classDef batch fill:#ffb,stroke:#333,stroke-width:2px;
    classDef external fill:#ffa,stroke:#333,stroke-width:2px;

    %% Click Events
    click app_module "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/app.module.ts"
    click app_resolver "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/app.resolver.ts"
    click libs "https://github.com/sirojali/nestar/tree/master/apps/nestar-api/src/libs"
    click database "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/database/database.module.ts"
    click auth_module_def "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/auth/auth.module.ts"
    click auth_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/auth/auth.service.ts"
    click auth_decorators "https://github.com/sirojali/nestar/tree/master/apps/nestar-api/src/components/auth/decorators"
    click auth_guards "https://github.com/sirojali/nestar/tree/master/apps/nestar-api/src/components/auth/guards"
    click board_article_resolver "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/board-article/board-article.resolver.ts"
    click board_article_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/board-article/board-article.service.ts"
    click comment_resolver "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/comment/comment.resolver.ts"
    click comment_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/comment/comment.service.ts"
    click follow_resolver "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/follow/follow.resolver.ts"
    click follow_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/follow/follow.service.ts"
    click like_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/like/like.service.ts"
    click member_resolver "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/member/member.resolver.ts"
    click member_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/member/member.service.ts"
    click property_resolver "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/property/property.resolver.ts"
    click property_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/property/property.service.ts"
    click view_service "https://github.com/sirojali/nestar/blob/master/apps/nestar-api/src/components/view/view.service.ts"
    click batch "https://github.com/sirojali/nestar/tree/master/apps/nestar-batch"
```
