# enoquetembe/notifications-service architecture

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

- Interactive diagram: https://gitdiagram.com/enoquetembe/notifications-service
- Repository: https://github.com/enoquetembe/notifications-service

## Overview

##### Project type and purpose
- This is a standalone microservice (“Notification Service”) implemented in Node.js/TypeScript using the Nest.js framework.
- Its responsibility is to expose an HTTP API to send, cancel, read, count, and retrieve notifications, storing them in a database via Prisma.

##### File structure
- Top-level directories and files:
- prisma/ – database schema, migrations, and local SQLite dev.db
- src/
– app/ – domain layer: entities, repository interface, use-case implementations and errors
– infra/
· database/ – Prisma service, mappers, and Prisma-backed repository
· http/ – Nest controllers, DTOs, view models, and HTTP module
– app.module.ts, main.ts – Nest application bootstrap
- test/ – unit and e2e test artifacts
- package.json, nest-cli.json, tsconfig*, .env, config, lint, and build files

##### README for additional insights
- Confirms it’s a microservice, built with Nest.js, Prisma, Jest, TS.
- Usage patterns: typical HTTP/JSON calls, local SQLite in dev, easily extensible to other channels (email/SMS/push).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["API Client"]:::ext

    subgraph "Bootstrap"
        MainTS["main.ts"]:::infra
        AppModule["app.module.ts"]:::infra
    end

    subgraph "HTTP/API Layer"
        HTTPModule["HttpModule"]:::http
        NotificationsController["NotificationsController"]:::http
        CreateNotificationDTO["CreateNotificationBody DTO"]:::http
        NotificationViewModel["NotificationViewModel"]:::http
    end

    subgraph "Application Layer"
        SendNotificationUC["SendNotificationUseCase"]:::app
        CancelNotificationUC["CancelNotificationUseCase"]:::app
        ReadNotificationUC["ReadNotificationUseCase"]:::app
        UnreadNotificationUC["UnreadNotificationUseCase"]:::app
        GetRecipientNotificationsUC["GetRecipientNotificationsUseCase"]:::app
        CountRecipientNotificationsUC["CountRecipientNotificationsUseCase"]:::app
        NotificationNotFoundError["NotificationNotFound Error"]:::app
    end

    subgraph "Domain Layer"
        NotificationEntity["Notification Entity"]:::domain
        ContentEntity["Content Entity"]:::domain
        NotificationsRepositoryIface["NotificationsRepository Interface"]:::domain
    end

    subgraph "Infrastructure Layer"
        DatabaseModule["DatabaseModule"]:::infra
        PrismaService["PrismaService"]:::infra
        PrismaMapper["PrismaNotificationMapper"]:::infra
        PrismaNotificationsRepo["PrismaNotificationsRepository"]:::infra
    end

    subgraph "Persistence"
        PrismaSchema["schema.prisma"]:::db
        Migrations["migrations/"]:::db
        SQLiteDB["dev.db / Production DB"]:::db
    end

    subgraph "External Channels"
        EmailService["Email Gateway"]:::ext
        SMSService["SMS Provider"]:::ext
        PushService["Push Broker"]:::ext
    end

    %% Connections
    MainTS --> AppModule
    AppModule --> HTTPModule
    AppModule --> DatabaseModule

    Client -->|"HTTP Request"| NotificationsController
    HTTPModule --> NotificationsController
    NotificationsController -->|"uses DTO"| CreateNotificationDTO
    NotificationsController -->|"calls UseCase"| SendNotificationUC
    NotificationsController -->|"maps to ViewModel"| NotificationViewModel

    SendNotificationUC --> NotificationsRepositoryIface
    CancelNotificationUC --> NotificationsRepositoryIface
    ReadNotificationUC --> NotificationsRepositoryIface
    UnreadNotificationUC --> NotificationsRepositoryIface
    GetRecipientNotificationsUC --> NotificationsRepositoryIface
    CountRecipientNotificationsUC --> NotificationsRepositoryIface

    NotificationsRepositoryIface --> PrismaNotificationsRepo
    PrismaNotificationsRepo --> PrismaService
    PrismaService -->|"runs queries"| SQLiteDB
    PrismaNotificationsRepo --> PrismaMapper

    SendNotificationUC -->|"throws"| NotificationNotFoundError
    ReadNotificationUC -->|"throws"| NotificationNotFoundError
    UnreadNotificationUC -->|"throws"| NotificationNotFoundError
    CancelNotificationUC -->|"throws"| NotificationNotFoundError

    SendNotificationUC --> EmailService
    SendNotificationUC --> SMSService
    SendNotificationUC --> PushService

    DatabaseModule --> PrismaService
    PrismaService --> PrismaSchema
    PrismaService --> Migrations

    %% Click Events
    click HTTPModule "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/http/http.module.ts"
    click NotificationsController "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/http/controllers/notifications.controller.ts"
    click CreateNotificationDTO "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/http/dtos/create-notification-body.ts"
    click NotificationViewModel "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/http/view-models/notification-view-model.ts"
    click SendNotificationUC "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/send-notification.ts"
    click CancelNotificationUC "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/cancel-notification.ts"
    click ReadNotificationUC "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/read-notification.ts"
    click UnreadNotificationUC "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/unread-notification.ts"
    click GetRecipientNotificationsUC "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/get-recipient-notifications.ts"
    click CountRecipientNotificationsUC "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/count-recipient-notifications.ts"
    click NotificationNotFoundError "https://github.com/enoquetembe/notifications-service/blob/main/src/app/use-cases/errors/notification-not-found.ts"
    click NotificationEntity "https://github.com/enoquetembe/notifications-service/blob/main/src/app/entities/notification.ts"
    click ContentEntity "https://github.com/enoquetembe/notifications-service/blob/main/src/app/entities/content.ts"
    click NotificationsRepositoryIface "https://github.com/enoquetembe/notifications-service/blob/main/src/app/repositories/notifications-repository.ts"
    click DatabaseModule "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/database/database.module.ts"
    click PrismaService "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/database/prisma/prisma.service.ts"
    click PrismaMapper "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/database/prisma/mappers/prisma-notification-mapper.ts"
    click PrismaNotificationsRepo "https://github.com/enoquetembe/notifications-service/blob/main/src/infra/database/prisma/repositories/prisma-notifications-repository.ts"
    click PrismaSchema "https://github.com/enoquetembe/notifications-service/blob/main/prisma/schema.prisma"
    click Migrations "https://github.com/enoquetembe/notifications-service/tree/main/prisma/migrations"
    click AppModule "https://github.com/enoquetembe/notifications-service/blob/main/src/app.module.ts"
    click MainTS "https://github.com/enoquetembe/notifications-service/blob/main/src/main.ts"

    %% Styles
    classDef http fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef app fill:#d4edda,stroke:#333,stroke-width:1px
    classDef domain fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef infra fill:#f8d7da,stroke:#333,stroke-width:1px
    classDef db fill:#d1ecf1,stroke:#333,stroke-width:1px
    classDef ext fill:#ffe5b4,stroke:#333,stroke-width:1px
```
