# hyunsdev/opize-calendar2notion-server architecture

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

- Interactive diagram: https://gitdiagram.com/hyunsdev/opize-calendar2notion-server
- Repository: https://github.com/hyunsdev/opize-calendar2notion-server

## Overview

##### Main Components

a) Core Application Layer:
- NestJS Application Core
- Global Exception Filter
- Environment Configuration
- Common Utils & Services

b) External Integration Services:
- Google Calendar API Client
- Notion API Client

c) Main Feature Modules:
- User Module (with Auth)
- Admin Module
- SyncBot Module
- Migration Module

##### Module Breakdown and Relationships

a) User Module Components:
- Authentication Service
- Calendar Management
- Connection Services (Notion/Google)
- Guards & Decorators

b) Admin Module Components:
- Error Management
- Statistics
- Tools (Google Calendar & Notion)
- User Management
- Event Management
- Plan Management

c) SyncBot Module Components:
- Stream Management
- Logging System

- Rectangles: Main modules
- Rounded rectangles: Services
- Hexagons: External APIs
- Diamonds: Decision points/guards

- Blue: Core application components
- Green: External integrations
- Yellow: Authentication/Security
- Gray: Utility services
- Orange: Feature modules

- Double lines: Data flow

##### Specific Implementation Details

a) Core Layer:
**┌─────────────────────────┐**
- NestJS Core App     │
- ┌─────────┬─────────┐  │
- Filters │ Guards  │  │
- ┴─────────┘  │
- ┘

b) Integration Layer:
**┌─────────────────┐    ┌─────────────┐**
- Google Calendar │    │   Notion    │
- Client     │    │   Client    │
- ┘    └─────────────┘

c) Feature Modules:
**┌─────────────────────────────────┐**
- User Module          │
- ┬──────────────────┤
- Auth      │     Calendar     │
- Service    │     Service      │
- ┴──────────────────┘

##### Key Relationships to Highlight

- Auth flow between User Module and external services
- Data flow between SyncBot and calendar integrations
- Admin module's oversight of all other modules
- Migration module's interaction with data stores

**┌─────────────────────────┐**
- ┬─────────────┤
- ►   │ Data Flow   │
- ►   │ Events      │
- ═════►    │ Auth Flow   │
- ┴─────────────┘

##### Data Access Layer

This structure will provide a clear visualization of the application's architecture while maintaining the necessary level of detail for a principal software engineer to understand the system's complete flow and interactions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#333
    classDef external fill:#90EE90,stroke:#333
    classDef auth fill:#FFE5B4,stroke:#333
    classDef utility fill:#D3D3D3,stroke:#333
    classDef feature fill:#FFB366,stroke:#333

    %% External Services Layer
    subgraph ExternalServices
        GC["Google Calendar API"]:::external
        NC["Notion API"]:::external
    end

    %% Core Application Layer
    subgraph CoreLayer
        NestCore["NestJS App Core"]:::core
        ExFilter["Global Exception Filter"]:::core
        EnvConfig["Environment Config"]:::core
    end

    %% Integration Clients
    subgraph IntegrationClients
        GCClient["Google Calendar Client"]:::external
        NClient["Notion Client"]:::external
    end

    %% Feature Modules
    subgraph UserModule
        AuthService["Auth Service"]:::auth
        CalendarMgmt["Calendar Management"]:::feature
        ConnectService["Connection Services"]:::feature
        Guards["Guards & Decorators"]:::auth
    end

    subgraph AdminModule
        ErrorMgmt["Error Management"]:::utility
        Stats["Statistics"]:::utility
        Tools["Admin Tools"]:::utility
        UserMgmt["User Management"]:::feature
        EventMgmt["Event Management"]:::feature
        PlanMgmt["Plan Management"]:::feature
    end

    subgraph SyncBotModule
        StreamMgmt["Stream Management"]:::feature
        LogSystem["Logging System"]:::utility
    end

    subgraph MigrationModule
        MigrationSvc["Migration Service"]:::utility
        MigrationEnt["Migration Entities"]:::utility
    end

    %% Relationships
    NestCore --> ExFilter
    NestCore --> EnvConfig
    
    GCClient --> GC
    NClient --> NC
    
    AuthService --> Guards
    CalendarMgmt --> GCClient
    ConnectService --> NClient
    
    StreamMgmt --> GCClient
    StreamMgmt --> NClient
    StreamMgmt --> LogSystem
    
    UserMgmt --> AuthService
    EventMgmt --> CalendarMgmt
    Tools --> GCClient
    Tools --> NClient

    %% Click Events
    click NestCore "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/app.module.ts"
    click ExFilter "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/app.exceptionFilter.ts"
    click EnvConfig "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/common/env/env.validation.ts"
    click GCClient "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/common/api-client/googleCalendar.client.ts"
    click NClient "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/common/api-client/notion.client.ts"
    click AuthService "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/user/submodules/auth/auth.service.ts"
    click CalendarMgmt "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/user/submodules/calendar/calendar.service.ts"
    click ConnectService "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/user/submodules/connect/connect.service.ts"
    click Guards "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/user/guard/auth.guard.ts"
    click ErrorMgmt "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/admin/submodules/error/error.service.ts"
    click Stats "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/admin/submodules/statistics/statistics.service.ts"
    click Tools "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/admin/submodules/tools/tools.service.ts"
    click UserMgmt "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/admin/submodules/user/admin-user.service.ts"
    click EventMgmt "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/admin/submodules/user/submodules/event/event.service.ts"
    click PlanMgmt "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/admin/submodules/user/submodules/plan/plan.service.ts"
    click StreamMgmt "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/syncbot/submodules/stream/syncbotStream.service.ts"
    click LogSystem "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/syncbot/submodules/log/log.service.ts"
    click MigrationSvc "https://github.com/HyunsDev/opize-calendar2notion-server/blob/main/src/submodules/migration1/migration1.service.ts"
    click MigrationEnt "https://github.com/HyunsDev/opize-calendar2notion-server/tree/main/src/submodules/migration1/entity/"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["External Services"]:::external
        L3["Auth Components"]:::auth
        L4["Utility Services"]:::utility
        L5["Feature Components"]:::feature
    end
```
