# lighteko/infoscribe architecture

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

- Interactive diagram: https://gitdiagram.com/lighteko/infoscribe
- Repository: https://github.com/lighteko/infoscribe

## Overview

##### Project Type & Purpose
- This is a full-stack, AI-powered newsletter platform (“Infoscribe”) built with a Next.js frontend, an Express.js API backend, and AWS serverless components.
- It curates and summarizes articles via LangChain/OpenAI, schedules jobs with EventBridge, stores newsletters in S3, delivers emails via SES, and persists user/content data in RDS (MySQL).

##### Key Directories & Their Roles
– next/: Next.js React-based frontend (mobile-first UI, Zustand)
– express/: Express.js REST API (containerized via Docker, hosted on EC2)
– lambda/: AWS Lambda functions (LangChain summarization & other automation tasks)

##### Main Components
a. User (browser or mobile)
b. Next.js Frontend (next/)
c. Express API (express/ in Docker on EC2)
d. AWS EventBridge (scheduler)
e. AWS Lambda functions (lambda/)
f. OpenAI API (external LangChain dependency)
g. Amazon RDS (MySQL content & user database)
h. Amazon S3 (newsletter storage)
i. Amazon SES (email delivery)

##### Relationships & Data Flows
1) User → Next.js Frontend:
– UI requests (e.g., login, preferences, newsletter preview)
2) Frontend → Express API:
– REST calls for CRUD operations on users, keywords, newsletter triggers
3) Express API ↔ RDS:
– Reads/writes user data, content metadata, scheduling info
4) Express API → EventBridge:
– Registers or updates scheduled jobs (e.g., daily newsletter run)
5) EventBridge → Lambda:
– Triggers summarization & generation workflow at scheduled times
6) Lambda → OpenAI (via LangChain):
– Pulls articles, generates summaries
7) Lambda → S3:
– Saves compiled newsletter HTML/PDF
8) Lambda → SES:
– Sends out newsletter emails to subscribers

##### Architectural Patterns & Principles
- Separation of concerns:
– UI layer (Next.js), API layer (Express), compute layer (Lambda), persistence (RDS/S3), delivery (SES).
- Serverless event-driven scheduling: EventBridge → Lambda.
- Micro-services style: lightweight API + isolated lambdas.
- Containerization for the Express API (Docker on EC2).
- Use of external AI service (OpenAI) abstracted by LangChain.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    subgraph "Client Zone"
        U["User"]:::external
        F["Next.js Frontend"]:::frontend
    end

    %% AWS Cloud
    subgraph "AWS Account/Region"
        direction TB
        API["Express API (Docker/EC2)"]:::backend
        EB["AWS EventBridge\n(Scheduler)"]:::compute
        LAMBDA["AWS Lambda Functions"]:::compute
        RDS["Amazon RDS (MySQL)"]:::datastore
        S3["Amazon S3\n(Newsletter Storage)"]:::datastore
        SES["Amazon SES\n(Email Delivery)"]:::datastore
    end

    %% External Services
    OA["OpenAI API\n(via LangChain)"]:::external

    %% Documentation
    subgraph "Project Docs"
        README["README.md"]:::doc
        GITMOD[".gitmodules"]:::doc
        GITIGN[".gitignore"]:::doc
    end

    %% Connections
    U -->|"HTTP/HTTPS"| F
    F -->|"REST API (HTTP)"| API
    API -->|"SQL (AWS SDK)"| RDS
    API -->|"Register Jobs\n(AWS SDK)"| EB
    EB -.->|"Event Trigger"| LAMBDA
    LAMBDA -->|"LangChain HTTP"| OA
    LAMBDA -->|"PutObject (AWS SDK)"| S3
    LAMBDA -->|"SendEmail (AWS SDK)"| SES

    %% Click Events
    click F "https://github.com/lighteko/infoscribe/tree/main/next/"
    click API "https://github.com/lighteko/infoscribe/tree/main/express/"
    click LAMBDA "https://github.com/lighteko/infoscribe/tree/main/lambda/"
    click README "https://github.com/lighteko/infoscribe/blob/main/README.md"
    click GITMOD "https://github.com/lighteko/infoscribe/blob/main/.gitmodules"
    click GITIGN "https://github.com/lighteko/infoscribe/blob/main/.gitignore"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#2E86C1,color:#0B5345;
    classDef backend fill:#A9DFBF,stroke:#27AE60,color:#145A32;
    classDef compute fill:#F5CBA7,stroke:#E67E22,color:#873600;
    classDef datastore fill:#D7BDE2,stroke:#8E44AD,color:#512E5F;
    classDef external fill:#E5E7E9,stroke:#7F8C8D,color:#2C3E50;
    classDef doc fill:#F9E79F,stroke:#F1C40F,color:#7D6608;
```
