This monorepo project aims to generate personalized newsletters through AI algorithms. It consists of frontend and backend subsystems. The backend is built in a Node.js environment and utilizes Prisma for Object-Relational Mapping (ORM). The frontend is developed using React and incorporates Auth0 for secure authentication.
This section details the relationships and constraints among the database models—Admin, Newsletter, UsedArticle, and ContentHistory.
-
Admin
id: UUID-based unique identifier.email: Unique email.name: Optional name.newsletters: Array of authored newsletters.mailingList: Array of strings (email addresses) to send newsletters.
-
Newsletter
id: Auto-incremented unique identifier.regenerateCount: Regeneration attempts counter.title,content,sentDate,adminID,topic,reason,searchQuery: Various attributes.contentHistory: Array of historical contents.usedArticles: Array of used articles.admin: Foreign key toAdmin.
-
UsedArticle
id: Auto-incremented unique identifier.url,newsletterId,createdAt,adminID,topic,reason: Various attributes.summary: Relation toArticleSummary.summaryID: Foreign key toArticleSummary.newsletter: Foreign key toNewsletter.
-
ContentHistory
id: Auto-incremented unique identifier.newsletterId,content,createdAt: Various attributes.newsletter: Foreign key toNewsletter.
-
ArticleSummary
id: UUID-based unique identifier.- `url: Unique URL.
summary: Summary text.usedBy: Array ofUsedArticlethat used this summary.
- Admin -> Newsletter: One-to-Many
- Newsletter -> ContentHistory: One-to-Many
- Newsletter -> UsedArticle: One-to-Many
- UsedArticle -> ArticleSummary: One-to-One
- ArticleSummary -> UsedArticle: One-to-Many
- Cascade Delete: Enabled with
onDelete: Cascade. - Field Defaults: Specified using Prisma directives.
- Uniqueness and IDs: Ensured through unique fields.
For further reading, consider Prisma's Relations and PostgreSQL's Referential Integrity.
importEmailList: Bulk email import.addSingleEmail: Singular email addition.
processArticles: Article filtering.sortArticles: Article ranking.
The server-side logic is modularized into an MVC-like architecture comprising routes, controllers, and utility functions. The entry point of the backend is index.ts.
Acts as the backend entry point, orchestrating the routes, controllers, and middleware configurations. Initializes the Express.js server, and sets it to listen on a specified port or default to 3001.
Located in the src/controllers directory. Responsible for handling business logic, they interact with the database and return responses.
adminController.ts: Handles admin-related functionalities.newsletterController.ts: Manages newsletter generation and sending.
Located in the src/routes directory. Define the API endpoints and associate them with their corresponding controllers.
adminRoutes.ts: Routes related to admin functionalities.newsletterRoutes.ts: Routes for newsletter operations.
Middleware configurations are located in the server/config/middleware.ts file.
express.json(): For JSON parsing.cors: For CORS handling.
Middleware is initialized and configured in the index.ts entry point.
GET /unsubscribePOST /api/update-adminPOST /api/create-newsletterGET /api/get-newslettersGET /api/get-emailsPOST /api/delete-selected-emailsDELETE /api/delete-newsletter/:idPOST /api/add-emailsPOST /api/send-newsletterPOST /api/regenerate-newsletter
generateOptimalBingSearchQuerygenerateSummaryWithGPTgenerateNewsletterWithGPT
- React, Auth0, Emotion, Material-UI
- Authentication and routing.
- Backend API utilities.
- Authenticated segment management.
ConfirmDeleteDialogConfirmSendDialogEmailListLoginButtonLogoutButtonNewsletterDetailDialogNewsletterFormNewsletterList
- Auth0 authentication configurations.
- Bing Search API
- AWS SES
DATABASE_URLAWS_REGION,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYBING_API_KEYGPT_API_KEY