# raindropstudio/lara-backend architecture

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

- Interactive diagram: https://gitdiagram.com/raindropstudio/lara-backend
- Repository: https://github.com/raindropstudio/lara-backend

## Overview

##### Main Components

a. External Systems:
- Nexon Open API (NXAPI) - External data source
- MySQL Database (indicated by Prisma usage)

b. Application Layers:
- API Layer (Controllers)
- Service Layer
- Repository Layer
- Data Mapping Layer
- Database Layer

##### Client/External Interface
- External client connections

##### Core Application Structure
- NestJS Modules (show the hierarchy):
- AppModule (root)
- ApiModule
- CharacterModule
- NxapiModule
- PrismaModule

##### Data Flow Components
- DTOs (src/common/dto)
- Mappers (src/nxapi/mapper)
- Converters (src/character/converter)
- Repositories (src/character/repository)

##### Database Layer
- Prisma Service
- Database Tables (based on prisma/schema.prisma)

##### Relationships and Interactions

- HTTP requests from clients to API endpoints
- Data flow from NXAPI through mappers to services
- Repository interactions with the database
- Service-to-service communications

##### Specific Implementation Details

Specialized components for:
- Character-related services
- Equipment systems
- Skill systems
- Stats and abilities

##### Technical Specifications to Note

- NestJS as the main framework
- Prisma as ORM
- MySQL as database
- External NXAPI integration
- TypeScript implementation

##### Key Architectural Patterns to Highlight

- Module-based architecture (NestJS)
- Repository pattern
- DTO pattern
- Mapper pattern
- Converter pattern

##### The modular structure of the character-related features

Remember to maintain a balance between showing the overall architecture while including enough detail to understand the data flow and component interactions, particularly around the character data processing which appears to be a core feature of the system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client["Client"]
        NXAPI["Nexon Open API (NXAPI)"]:::external
    end

    subgraph "API Layer"
        APIController["API Controller"]:::api
        APIModule["API Module"]:::api
    end

    subgraph "Core Modules"
        AppModule["App Module"]:::core
        CharModule["Character Module"]:::core
        NXAPIModule["NXAPI Module"]:::core
        PrismaModule["Prisma Module"]:::core
    end

    subgraph "Service Layer"
        CharService["Character Service"]:::service
        NXAPIService["NXAPI Service"]:::service
        PrismaService["Prisma Service"]:::service
    end

    subgraph "Data Transformation"
        direction TB
        Mappers["NXAPI Mappers"]:::mapper
        Converters["Character Converters"]:::mapper
        DTOs["DTOs"]:::mapper
    end

    subgraph "Repository Layer"
        CharRepo["Character Repository"]:::repo
        AbilityRepo["Ability Repository"]:::repo
        ItemEquipRepo["Item Equipment Repository"]:::repo
        SkillRepo["Skill Repository"]:::repo
    end

    subgraph "Database"
        MySQL[(MySQL Database)]:::database
    end

    %% Connections
    Client --> APIController
    APIController --> CharService
    NXAPI --> NXAPIService
    NXAPIService --> Mappers
    Mappers --> CharService
    CharService --> Converters
    Converters --> DTOs
    CharService --> CharRepo
    CharService --> AbilityRepo
    CharService --> ItemEquipRepo
    CharService --> SkillRepo
    CharRepo --> PrismaService
    AbilityRepo --> PrismaService
    ItemEquipRepo --> PrismaService
    SkillRepo --> PrismaService
    PrismaService --> MySQL

    %% Click Events
    click APIController "https://github.com/raindropstudio/lara-backend/blob/master/src/api/api.controller.ts"
    click APIModule "https://github.com/raindropstudio/lara-backend/blob/master/src/api/api.module.ts"
    click AppModule "https://github.com/raindropstudio/lara-backend/blob/master/src/app.module.ts"
    click CharModule "https://github.com/raindropstudio/lara-backend/blob/master/src/character/character.module.ts"
    click NXAPIModule "https://github.com/raindropstudio/lara-backend/blob/master/src/nxapi/nxapi.module.ts"
    click PrismaModule "https://github.com/raindropstudio/lara-backend/blob/master/src/prisma/prisma.module.ts"
    click Mappers "https://github.com/raindropstudio/lara-backend/tree/master/src/nxapi/mapper/"
    click Converters "https://github.com/raindropstudio/lara-backend/tree/master/src/character/converter/"
    click CharService "https://github.com/raindropstudio/lara-backend/blob/master/src/character/character.service.ts"
    click NXAPIService "https://github.com/raindropstudio/lara-backend/blob/master/src/nxapi/nxapi.service.ts"
    click PrismaService "https://github.com/raindropstudio/lara-backend/blob/master/src/prisma/prisma.service.ts"
    click CharRepo "https://github.com/raindropstudio/lara-backend/blob/master/src/character/repository/character.repository.ts"
    click AbilityRepo "https://github.com/raindropstudio/lara-backend/blob/master/src/character/repository/ability.repository.ts"
    click ItemEquipRepo "https://github.com/raindropstudio/lara-backend/blob/master/src/character/repository/item-equipment.repository.ts"
    click SkillRepo "https://github.com/raindropstudio/lara-backend/blob/master/src/character/repository/skill.repository.ts"
    click DTOs "https://github.com/raindropstudio/lara-backend/tree/master/src/common/dto/"

    %% Styling
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef api fill:#1E88E5,stroke:#333,stroke-width:2px,color:white
    classDef core fill:#43A047,stroke:#333,stroke-width:2px,color:white
    classDef service fill:#00ACC1,stroke:#333,stroke-width:2px,color:white
    classDef mapper fill:#FFB300,stroke:#333,stroke-width:2px
    classDef repo fill:#8E24AA,stroke:#333,stroke-width:2px,color:white
    classDef database fill:#E53935,stroke:#333,stroke-width:2px,color:white
```
