# sylvesterkwon/recrit architecture

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

## Overview

##### Main System Components

a) External Services Layer (Top)
- TMDB API Integration
- Kafka Message Broker
- Elasticsearch
- Neo4j Graph Database

b) Application Layer (Middle)
- API Gateway/Controllers
- Application Services
- Domain Services
- Event Manager

c) Data Layer (Bottom)
- Repositories
- Entities
- Database Connections

##### Component Relationships

- User Module (Authentication & Authorization)
- Movie Module
- Comparable Module
- Comparison Module
- Graph Module
- Elasticsearch Module

- Common Layer (Decorators, Filters, Exceptions)
- Event Management System
- Authentication/Authorization

##### Specific Implementation Details

Important architectural patterns:

a) Data Flow Patterns:
- REST API endpoints (Controllers)
- Event-driven communication (Kafka)
- Graph-based relationships (Neo4j)
- Search functionality (Elasticsearch)

b) Security Layer:
- JWT Authentication
- Permission-based authorization
- Guards and strategies

##### Key Relationships to Highlight

- User Authentication Flow
- Movie Synchronization with TMDB
- Comparison Creation and Storage
- Event Processing Pipeline
- Search and Graph Relationships

##### The modular architecture following NestJS patterns

This will provide a clear understanding of how the system components interact while maintaining the scalability and maintainability of the application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        TMDB[TMDB API]
        Kafka[Kafka Message Broker]
        ES[Elasticsearch]
        Neo4j[(Neo4j Graph DB)]
    end

    subgraph Application
        subgraph Core_Modules
            UserMod[User Module]:::module
            MovieMod[Movie Module]:::module
            CompMod[Comparable Module]:::module
            CmpMod[Comparison Module]:::module
            GraphMod[Graph Module]:::module
            ESMod[Elasticsearch Module]:::module
        end

        subgraph Security
            JWT[JWT Auth]:::security
            Local[Local Auth]:::security
            Guards[Guards]:::security
            AuthSvc[Auth Service]:::security
        end

        subgraph Common
            BaseApp[Base Application]:::common
            ExceptionFilter[Exception Handler]:::common
            Decorators[Decorators]:::common
            BaseEntity[Base Entities]:::common
        end

        subgraph EventSystem
            EventMgr[Event Manager]:::event
            EventSvc[Event Service]:::event
            BaseEvent[Base Event]:::event
        end

        subgraph Config
            AuthCfg[Auth Config]:::config
            ESCfg[ES Config]:::config
            Neo4jCfg[Neo4j Config]:::config
            TMDBCfg[TMDB Config]:::config
            KafkaCfg[Kafka Config]:::config
        end

        subgraph Repositories
            MovieRepo[Movie Repository]:::repo
            UserRepo[User Repository]:::repo
            CompRepo[Comparison Repository]:::repo
            GraphRepo[Graph Repository]:::repo
        end
    end

    %% Relationships
    TMDB --> TMDBCfg
    ES --> ESCfg
    Neo4j --> Neo4jCfg
    Kafka --> KafkaCfg

    UserMod --> AuthSvc
    AuthSvc --> JWT
    AuthSvc --> Local
    AuthSvc --> Guards

    MovieMod --> MovieRepo
    UserMod --> UserRepo
    CmpMod --> CompRepo
    GraphMod --> GraphRepo

    EventMgr --> EventSvc
    EventSvc --> BaseEvent
    EventSvc --> Kafka

    %% Click Events
    click UserMod "https://github.com/SylvesterKwon/recrit/blob/develop/src/user/user.module.ts"
    click MovieMod "https://github.com/SylvesterKwon/recrit/blob/develop/src/movie/movie.module.ts"
    click CompMod "https://github.com/SylvesterKwon/recrit/blob/develop/src/comparable/comparable.module.ts"
    click CmpMod "https://github.com/SylvesterKwon/recrit/blob/develop/src/comparison/comparison.module.ts"
    click GraphMod "https://github.com/SylvesterKwon/recrit/blob/develop/src/graph/graph.module.ts"
    click ESMod "https://github.com/SylvesterKwon/recrit/blob/develop/src/elaticsearch/elasticserach-wrapper.module.ts"
    click JWT "https://github.com/SylvesterKwon/recrit/blob/develop/src/user/strategies/jwt.strategy.ts"
    click Local "https://github.com/SylvesterKwon/recrit/blob/develop/src/user/strategies/local.strategy.ts"
    click Guards "https://github.com/SylvesterKwon/recrit/blob/develop/src/user/guards/permission.guards.ts"
    click AuthSvc "https://github.com/SylvesterKwon/recrit/blob/develop/src/user/services/auth.service.ts"
    click EventMgr "https://github.com/SylvesterKwon/recrit/blob/develop/src/event-manager/event-manager.module.ts"
    click EventSvc "https://github.com/SylvesterKwon/recrit/blob/develop/src/event-manager/event-manager.service.ts"
    click BaseEvent "https://github.com/SylvesterKwon/recrit/blob/develop/src/common/events/base.event.ts"
    click BaseApp "https://github.com/SylvesterKwon/recrit/blob/develop/src/common/applications/base.applicaiton.ts"
    click ExceptionFilter "https://github.com/SylvesterKwon/recrit/blob/develop/src/common/filters/exception.filter.ts"
    click Decorators "https://github.com/SylvesterKwon/recrit/tree/develop/src/common/decorators"
    click BaseEntity "https://github.com/SylvesterKwon/recrit/blob/develop/src/common/entities/timestamped-entity.entity.ts"
    click MovieRepo "https://github.com/SylvesterKwon/recrit/tree/develop/src/movie/repositories"
    click UserRepo "https://github.com/SylvesterKwon/recrit/tree/develop/src/user/repositories"
    click CompRepo "https://github.com/SylvesterKwon/recrit/blob/develop/src/comparison/repositories/comparison.repository.ts"
    click GraphRepo "https://github.com/SylvesterKwon/recrit/blob/develop/src/graph/repositories/graph.repository.ts"
    click AuthCfg "https://github.com/SylvesterKwon/recrit/blob/develop/src/config/auth.config.ts"
    click ESCfg "https://github.com/SylvesterKwon/recrit/blob/develop/src/config/elasticsearch.config.ts"
    click Neo4jCfg "https://github.com/SylvesterKwon/recrit/blob/develop/src/config/neo4j.config.ts"
    click TMDBCfg "https://github.com/SylvesterKwon/recrit/blob/develop/src/config/tmdb-client.config.ts"
    click KafkaCfg "https://github.com/SylvesterKwon/recrit/blob/develop/src/config/kafka.config.ts"

    %% Styles
    classDef module fill:#a8d1ff,stroke:#333
    classDef security fill:#ffeb99,stroke:#333
    classDef common fill:#d3d3d3,stroke:#333
    classDef event fill:#ffc6c6,stroke:#333
    classDef config fill:#c2f0c2,stroke:#333
    classDef repo fill:#d8bfd8,stroke:#333

    %% Legend
    subgraph Legend
        ModuleL[Module]:::module
        SecurityL[Security]:::security
        CommonL[Common]:::common
        EventL[Event]:::event
        ConfigL[Config]:::config
        RepoL[Repository]:::repo
    end
```
