|
1 | | -```markdown |
2 | | -# NotifyLog |
| 1 | +# 📬 NotifyLog |
3 | 2 |
|
4 | | - |
5 | | - |
6 | | - |
| 3 | +> A microservice-based Notification Logger built with NestJS and Next.js to send, track, and analyze Email, SMS, and Webhook messages. |
7 | 4 |
|
8 | | -**NotifyLog** is a full-stack Node.js/NestJS microservice built with **clean architecture** and **SOLID principles**, designed for sending email/SMS notifications, logging messages/errors, and managing webhooks. It’s portable, modular, and paired with a Next.js/React frontend dashboard for visualizing notification and error log history. Features a **GraphQL API** for flexible querying. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
9 | 9 |
|
10 | | -## Table of Contents |
11 | | -- [Features](#features) |
12 | | -- [Tech Stack](#tech-stack) |
13 | | -- [Clean Architecture](#clean-architecture) |
14 | | -- [Project Structure](#project-structure) |
15 | | -- [Getting Started](#getting-started) |
16 | | -- [Frontend Setup](#frontend-setup) |
17 | | -- [API Documentation](#api-documentation) |
18 | | -- [Testing](#testing) |
19 | | -- [Contributing](#contributing) |
20 | | -- [License](#license) |
| 10 | +--- |
21 | 11 |
|
22 | | -## Features |
23 | | -- Send notifications (email/SMS) with a strategy pattern. |
24 | | -- Centralized logging with Winston and MongoDB transport. |
25 | | -- Webhook subscriptions for real-time event notifications. |
26 | | -- Advanced log filtering and retrieval via GraphQL. |
27 | | -- Next.js/React frontend dashboard for notification and error log history. |
28 | | -- **GraphQL API** for flexible, type-safe queries. |
29 | | -- Extensible and portable for integration into any project. |
| 12 | +## 🌟 Highlights |
30 | 13 |
|
31 | | -## Tech Stack |
32 | | -- **Backend**: Node.js, NestJS, GraphQL, Prisma, MongoDB, Winston, TypeScript |
33 | | -- **Frontend**: Next.js, React, Tailwind CSS, React Query |
34 | | -- **Tools**: Prisma, GraphQL Playground, Prettier, ESLint, Docker |
| 14 | +- 🚀 Microservice architecture using **NestJS** |
| 15 | +- 🌐 Clean and powerful **GraphQL API** |
| 16 | +- ✉️ Supports Email, SMS, and Webhook notifications |
| 17 | +- 📦 Centralized logging using **Winston** + **MongoDB** |
| 18 | +- 🎯 Extensible via plug-and-play notification providers |
| 19 | +- 🧪 Tested with **Jest** and designed for scalability |
| 20 | +- 💻 Lightweight **Next.js** frontend dashboard |
35 | 21 |
|
36 | | -## Clean Architecture |
37 | | -**NotifyLog** follows **clean architecture** and **SOLID principles**, ensuring modularity, testability, and maintainability. Key layers include: |
| 22 | +--- |
38 | 23 |
|
39 | | -- **Domain** (`apps/notifylog-api/src/domain/`): Defines interfaces (e.g., `INotificationRepository`, `IWebhookRepository`) for business logic, independent of frameworks (Single Responsibility). |
40 | | -- **Application** (`apps/notifylog-api/src/application/`): Implements business rules via factories (`NotificationFactory`) and strategies (`EmailNotificationStrategy`, `SMSNotificationStrategy`) (Dependency Inversion). |
41 | | -- **Infrastructure** (`apps/notifylog-api/src/infrastructure/`): Handles persistence (`prisma/schema.prisma`) and repositories (`NotificationRepository`, `WebhookRepository`) (Open/Closed). |
42 | | -- **Presentation** (`apps/notifylog-api/src/presentation/`): Exposes GraphQL APIs through resolvers (`NotificationResolver`, `WebhookResolver`, `LogResolver`) (Interface Segregation). |
| 24 | +## 📖 Overview |
43 | 25 |
|
44 | | -Shared utilities and logging are abstracted into `libs/` for reusability across apps. |
| 26 | +**NotifyLog** is a robust, plug-and-play Node.js-based notification microservice designed to handle multi-channel communication like Email, SMS, and Webhooks, all with centralized logging and GraphQL API support. Built using **NestJS** and **Next.js**, it follows clean architecture principles and is deployable in a distributed, containerized environment. |
45 | 27 |
|
46 | | -## Project Structure |
47 | | -``` |
48 | | -notifylog/ |
49 | | -├── apps/ # Monorepo applications |
50 | | -│ ├── notifylog-api/ # NestJS microservice (GraphQL + Notification logic) |
51 | | -│ │ ├── src/ |
52 | | -│ │ │ ├── application/ # Business logic |
53 | | -│ │ │ │ ├── factories/ |
54 | | -│ │ │ │ │ └── notification.factory.ts |
55 | | -│ │ │ │ └── strategies/ |
56 | | -│ │ │ │ ├── email-notification.strategy.ts |
57 | | -│ │ │ │ └── sms-notification.strategy.ts |
58 | | -│ │ │ ├── domain/ # Core entities/interfaces |
59 | | -│ │ │ │ └── interfaces/ |
60 | | -│ │ │ │ ├── notification-repository.interface.ts |
61 | | -│ │ │ │ └── webhook-repository.interface.ts |
62 | | -│ │ │ ├── infrastructure/ # DB adapters |
63 | | -│ │ │ │ └── repositories/ |
64 | | -│ │ │ │ ├── notification.repository.ts |
65 | | -│ │ │ │ └── webhook.repository.ts |
66 | | -│ │ │ ├── presentation/ # GraphQL resolvers |
67 | | -│ │ │ │ └── resolvers/ |
68 | | -│ │ │ │ ├── notification.resolver.ts |
69 | | -│ │ │ │ ├── webhook.resolver.ts |
70 | | -│ │ │ │ └── log.resolver.ts |
71 | | -│ │ │ ├── dto/ # Data transfer objects |
72 | | -│ │ │ │ └── notification.dto.ts |
73 | | -│ │ │ ├── services/ # Core services |
74 | | -│ │ │ │ └── log.service.ts |
75 | | -│ │ │ ├── app.module.ts |
76 | | -│ │ │ └── main.ts |
77 | | -│ │ ├── package.json |
78 | | -│ │ ├── tsconfig.json |
79 | | -│ │ └── .env.example |
80 | | -│ └── notifylog-ui/ # Next.js frontend dashboard |
81 | | -│ ├── src/ |
82 | | -│ │ ├── app/ |
83 | | -│ │ │ ├── page.tsx |
84 | | -│ │ │ ├── notifications/ |
85 | | -│ │ │ │ └── page.tsx |
86 | | -│ │ │ ├── errors/ |
87 | | -│ │ │ │ └── page.tsx |
88 | | -│ │ │ ├── layout.tsx |
89 | | -│ │ │ └── globals.css |
90 | | -│ │ ├── components/ # UI components |
91 | | -│ │ │ ├── Header.tsx |
92 | | -│ │ │ ├── NotificationTable.tsx |
93 | | -│ │ │ └── ErrorTable.tsx |
94 | | -│ │ └── lib/ |
95 | | -│ │ ├── api.ts # API integration layer |
96 | | -│ │ └── types.ts # Shared types |
97 | | -│ ├── public/ # Static assets |
98 | | -│ ├── package.json |
99 | | -│ └── next.config.js |
100 | | -├── libs/ # Shared libraries |
101 | | -│ ├── logger/ # Winston logger (MongoDB transport) |
102 | | -│ │ ├── src/ |
103 | | -│ │ │ ├── interfaces/ |
104 | | -│ │ │ │ └── log-repository.interface.ts |
105 | | -│ │ │ ├── persistence/ |
106 | | -│ │ │ │ └── logger.schema.ts |
107 | | -│ │ │ ├── repositories/ |
108 | | -│ │ │ │ └── log.repository.ts |
109 | | -│ │ │ └── services/ |
110 | | -│ │ │ ├── logger.service.file.ts |
111 | | -│ │ │ └── logger.service.db.ts |
112 | | -│ │ ├── package.json |
113 | | -│ │ └── tsconfig.json |
114 | | -│ └── utils/ # Shared utilities |
115 | | -│ ├── src/ |
116 | | -│ │ ├── helpers/ |
117 | | -│ │ │ ├── string.utils.ts |
118 | | -│ │ │ └── validation.utils.ts |
119 | | -│ │ ├── interceptors/ |
120 | | -│ │ │ └── logging.interceptor.ts |
121 | | -│ │ └── constants/ |
122 | | -│ │ └── app.constants.ts |
123 | | -│ ├── package.json |
124 | | -│ └── tsconfig.json |
125 | | -├── prisma/ # Database layer |
126 | | -│ ├── schema.prisma # Prisma schema |
127 | | -│ └── migrations/ # DB migration history |
128 | | -├── docker/ # Containerization |
129 | | -│ ├── Dockerfile.api |
130 | | -│ ├── Dockerfile.ui |
131 | | -│ └── docker-compose.yml |
132 | | -├── .github/ # GitHub configurations |
133 | | -│ ├── ISSUE_TEMPLATE/ # Issue templates |
134 | | -│ └── workflows/ |
135 | | -│ └── ci.yml # CI pipeline |
136 | | -├── README.md |
137 | | -├── CONTRIBUTING.md |
138 | | -├── CODE_OF_CONDUCT.md |
139 | | -├── LICENSE |
140 | | -``` |
141 | | -
|
142 | | -## Getting Started (Backend) |
143 | | -### Prerequisites |
144 | | -- Node.js (>=18.x) |
145 | | -- MongoDB (local or Atlas) |
146 | | -- Yarn or npm |
147 | | -- Docker (optional) |
148 | | -
|
149 | | -### Installation |
150 | | -1. Clone the repository: |
151 | | - ```bash |
152 | | - git clone https://github.com/your-username/notifylog.git |
153 | | - cd notifylog |
154 | | - ``` |
155 | | -2. Install dependencies: |
156 | | - ```bash |
157 | | - yarn install |
158 | | - ``` |
159 | | -3. Set up environment variables: |
160 | | - ```bash |
161 | | - cp apps/notifylog-api/.env.example apps/notifylog-api/.env |
162 | | - ``` |
163 | | - Update `apps/notifylog-api/.env`: |
164 | | - ```env |
165 | | - DATABASE_URL=mongodb://localhost:27017/notifylog |
166 | | - ``` |
167 | | -4. Run Prisma migrations: |
168 | | - ```bash |
169 | | - cd apps/notifylog-api |
170 | | - npx prisma migrate dev |
171 | | - ``` |
172 | | -5. Start the backend: |
173 | | - ```bash |
174 | | - yarn workspace notifylog-api start:dev |
175 | | - ``` |
176 | | - |
177 | | -### Docker Setup |
178 | | -Run both backend and frontend with Docker: |
179 | | -```bash |
180 | | -docker-compose up --build |
181 | | -``` |
| 28 | +Use NotifyLog as: |
| 29 | +- A backend service for sending and tracking messages |
| 30 | +- A standalone logger for notification events |
| 31 | +- An integration-ready module in any SaaS or enterprise app |
182 | 32 |
|
183 | | -## Frontend Setup |
184 | | -### Prerequisites |
185 | | -- Node.js (>=18.x) |
186 | | -- Backend running at `http://localhost:3000` |
| 33 | +--- |
187 | 34 |
|
188 | | -### Installation |
189 | | -1. Install frontend dependencies: |
190 | | - ```bash |
191 | | - cd apps/notifylog-ui |
192 | | - yarn install |
193 | | - ``` |
194 | | -2. Run the frontend: |
195 | | - ```bash |
196 | | - yarn dev |
197 | | - ``` |
198 | | -3. Access at `http://localhost:3001`. |
| 35 | +## 📂 Project Structure |
199 | 36 |
|
200 | | -## API Documentation |
201 | | -Explore the **GraphQL API** via **GraphQL Playground** at [http://localhost:3000/graphql](http://localhost:3000/graphql). Example query: |
202 | | -```graphql |
203 | | -mutation SendNotification { |
204 | | - sendNotification(input: { |
205 | | - type: "EMAIL" |
206 | | - to: "example@domain.com" |
207 | | - subject: "Welcome!" |
208 | | - message: "Hello from NotifyLog!" |
209 | | - }) { |
210 | | - success |
211 | | - messageId |
212 | | - } |
213 | | -} |
214 | | -``` |
215 | | - |
216 | | -## Testing |
217 | | -Run tests with Jest: |
218 | | -```bash |
219 | | -yarn test |
220 | | -``` |
221 | | -Generate coverage: |
222 | 37 | ```bash |
223 | | -yarn test:cov |
224 | | -``` |
225 | | - |
226 | | -## Contributing |
227 | | -Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines and [issues](https://github.com/your-username/notifylog/issues) for tasks (`good first issue`, `hacktoberfest`). Use issue templates in `.github/ISSUE_TEMPLATE`. Join our [Discord](https://discord.gg/your-invite-link). |
228 | | - |
229 | | -## License |
230 | | -MIT License. See [LICENSE](LICENSE). |
231 | | -``` |
| 38 | +notifylog/ |
| 39 | +├── apps/ |
| 40 | +│ ├── notifylog-api/ # NestJS microservice (GraphQL + Notification logic) |
| 41 | +│ └── notifylog-ui/ # Next.js frontend dashboard |
| 42 | +├── libs/ |
| 43 | +│ ├── logger/ # Winston logger (MongoDB transport) |
| 44 | +│ └── utils/ # Shared helpers, interceptors, constants |
| 45 | +├── prisma/ # Prisma ORM config & schema |
| 46 | +├── docker/ # Docker & Docker Compose files |
| 47 | +├── .github/ # Issue templates & GitHub Actions |
| 48 | +└── README.md |
0 commit comments