# mongodb-developer/genai-showcase architecture

> Architecture diagram of the GitHub repository mongodb-developer/genai-showcase, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mongodb-developer/genai-showcase
- Repository: https://github.com/mongodb-developer/genai-showcase

## Overview

This repository is a multi-faceted GenAI Showcase that provides a rich collection of examples and demos around Retrieval-Augmented Generation (RAG), AI Agents, and many industry-specific use cases—all built with MongoDB as a core component. The repo is organized into three major sections:
- notebooks – Jupyter notebooks that demonstrate experiments, evaluations, and advanced techniques.
- apps – A variety of both JavaScript/TypeScript and Python applications/demos that showcase production-grade implementations (including Next.js apps, standalone Python bots, Terraform configurations, etc.).
- partners – Contributions from AI partners with additional demos.

##### Main Components
a. Frontend/UI Layer: Many demos, such as the Next.js apps (e.g., RT-voice-ts-store-agent, mongo-feed, mongostory, vercel_sdk_hr_agent), include user-facing pages, components (React components, UI controls, theme providers), and layouts.
b. API/Backend Layer: Look at the extensive API subdirectories (e.g., under each app’s “api” folder) which implement endpoints handling orders, products, user authentication, sentiment or analytics processing, etc.
c. Database & Storage: MongoDB is the central persistence layer. It is used as a vector store, operational database, and memory provider for AI tasks.
d. AI/Generative Components: Integration points with generative AI and retrieval pipelines are evident. These include specialized modules for vector embeddings (e.g., in “lib” and “tools”), AI agent implementations, and semantic search components in the notebooks and partner demos.
e. Infrastructure & Deployment: Some demos (like the Terraform module in springai-terraform-rag and the Dockerized “local-bot”) focus on deployment configuration and infrastructure-as-code.
f. Experimentation Environment: The notebooks directory provides experimental environments which, although separate, share similar fundamental interactions (MongoDB, language models, and retrieval pipelines).

##### Relationships & Interactions
c. The generative AI or RAG pipelines often pull in external AI models or tools (such as LangChain integrations, AI agents), so illustrate these connections—and note third-party service calls, if any.
d. Infrastructure components, such as containerization (Docker), deployment scripts (Terraform and compose files), and CI/CD workflows (GitHub Actions) should be shown as elements that support the system’s deployment and lifecycle management.

##### Architectural Patterns and Technologies
a. The separation of concerns between frontend, API, and data persistence follows a common multi-tier/microservices architecture—even when parts are combined in a single repository.
c. Notice recurring use of utility libraries and hooks (e.g., use-mobile, use-toast) and standardized UI components (UI libraries in each app) to enforce a consistent user experience.
d. For AI and RAG implementations, highlight the pipeline: data ingestion → vector embedding generation → retrieval → generative model outputs.

##### Essential Architectural Elements
- The UI Layer: Frontend pages, layouts, and components visible in the Next.js folders.
- The API Layer: Multiple REST (or Next.js API) endpoints handling operations like orders, authentication, content generation, sentiment analysis, etc.
- Data Persistence: MongoDB collections that store both operational data and vector/AI embeddings.
- Generative AI Layer: Integration with LangChain (and possibly other AI libraries) that power the AI agent and RAG capabilities.
- Deployment Mechanisms: Scripts, Dockerfiles, Terraform files, and CI workflows that support building and deploying these components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        UI1["RT-voice-ts-store-agent UI"]:::frontend
        UI2["mongo-feed UI"]:::frontend
        UI3["mongo-mp UI"]:::frontend
        UI4["mongostory UI"]:::frontend
        UI5["vercel_sdk_hr_agent UI"]:::frontend
    end

    %% API/Backend Layer
    subgraph "API/Backend Layer"
        API1["RT-voice-ts-store-agent API"]:::backend
        API2["mongo-feed API"]:::backend
        API3["mongo-mp API"]:::backend
        API4["mongostory API"]:::backend
        API5["vercel_sdk_hr_agent API"]:::backend
        API6["local-bot Service"]:::backend
    end

    %% Database & Storage
    subgraph "Database & Storage"
        DB1["RT-voice-ts-store-agent MongoDB"]:::database
        DB2["mongo-feed MongoDB"]:::database
        DB3["mongo-mp MongoDB"]:::database
        DB4["mongostory MongoDB"]:::database
    end

    %% AI/Generative Components
    subgraph "AI/Generative Components"
        AI_NB["Notebooks & Agents"]:::ai
        AI_Tools["Embeddings Generator"]:::ai
        AI_Module1["mongostory AI Agent"]:::ai
        AI_Module2["vercel_sdk_hr_agent Embeddings"]:::ai
    end

    %% Infrastructure & Deployment
    subgraph "Infrastructure & Deployment"
        INF1["Local Bot Deployments"]:::infrastructure
        INF2["Terraform Deployments"]:::infrastructure
    end

    %% Experimentation Environment
    subgraph "Experimentation Environment"
        EXP["Jupyter Notebooks Sandbox"]:::experimentation
    end

    %% Connections between Frontend and API
    UI1 -->|"calls"| API1
    UI2 -->|"calls"| API2
    UI3 -->|"calls"| API3
    UI4 -->|"calls"| API4
    UI5 -->|"calls"| API5

    %% Connections between API and Database
    API1 -->|"reads/writes"| DB1
    API2 -->|"reads/writes"| DB2
    API3 -->|"reads/writes"| DB3
    API4 -->|"reads/writes"| DB4
    API5 -->|"reads/writes"| DB4
    API6 -->|"reads/writes"| DB1

    %% Connections between API and AI Components
    API1 -->|"integrates"| AI_Tools
    API4 -->|"integrates"| AI_Module1
    API5 -->|"integrates"| AI_Module2

    %% Connection from Experimentation to AI
    EXP -->|"tests"| AI_NB

    %% Infrastructure supports API and Deployment of Services
    INF1 -->|"deploys"| API6
    INF2 -->|"deploys"| API6

    %% Class Definitions for styling
    classDef frontend fill:#f9c74f,stroke:#333,stroke-width:1px;
    classDef backend fill:#90be6d,stroke:#333,stroke-width:1px;
    classDef database fill:#f9844a,stroke:#333,stroke-width:1px;
    classDef ai fill:#277da1,stroke:#333,stroke-width:1px,color:#fff;
    classDef infrastructure fill:#f3722c,stroke:#333,stroke-width:1px,color:#fff;
    classDef experimentation fill:#a9a9a9,stroke:#333,stroke-width:1px;

    %% Click Events
    click UI1 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/RT-voice-ts-store-agent/app"
    click UI2 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/mongo-feed/app"
    click UI3 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/mongo-mp/app"
    click UI4 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/mongostory/app"
    click UI5 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/vercel_sdk_hr_agent/app"

    click API1 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/RT-voice-ts-store-agent/app/api"
    click API2 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/mongo-feed/app/api"
    click API3 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/mongo-mp/app/api"
    click API4 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/mongostory/app/api"
    click API5 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/vercel_sdk_hr_agent/app/api"
    click API6 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/local-bot/app.py"

    click DB1 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/RT-voice-ts-store-agent/lib/mongodb.ts"
    click DB2 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/mongo-feed/lib/mongodb.ts"
    click DB3 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/mongo-mp/lib/mongodb.ts"
    click DB4 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/mongostory/lib/mongodb.ts"

    click AI_NB "https://github.com/mongodb-developer/genai-showcase/tree/main/notebooks/"
    click AI_Tools "https://github.com/mongodb-developer/genai-showcase/blob/main/tools/embeddings_generator/create_embeddings.py"
    click AI_Module1 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/mongostory/lib/ai-agent.ts"
    click AI_Module2 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/vercel_sdk_hr_agent/utils/embeddings.ts"

    click INF1 "https://github.com/mongodb-developer/genai-showcase/tree/main/apps/local-bot/Dockerfile"
    click INF1 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/local-bot/compose.yaml"
    click INF2 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/springai-terraform-rag/main.tf"
    click INF2 "https://github.com/mongodb-developer/genai-showcase/blob/main/apps/springai-terraform-rag/variables.tf"

    click EXP "https://github.com/mongodb-developer/genai-showcase/tree/main/notebooks/"
```
