# eniolaademola/llm-app-with-lcel architecture

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

- Interactive diagram: https://gitdiagram.com/eniolaademola/llm-app-with-lcel
- Repository: https://github.com/eniolaademola/llm-app-with-lcel

## Overview

##### Project Type and Purpose
- This is a lightweight full-stack LLM application.
- Purpose: expose a RESTful translation/processing endpoint via FastAPI and provide a minimal Streamlit client UI to consume it.
- Core use-case: accept user text + target language, run it through a Langchain expression (LCEL) chain backed by Groq, and return the result.

##### File Structure
- Top level:
- server/
– server.py (FastAPI app defining POST /chain/invoke, wiring in Langchain components, loading .env)
- client/
– client.py (Streamlit app making HTTP calls with requests to the FastAPI endpoint)
- requirements.txt (lists FastAPI, uvicorn, streamlit, requests, python-dotenv, langchain_core, langchain_groq)
- simpleLLMAppWithLCEL.ipynb (demo notebook)
- No database layer; external dependency on Groq API for model inference.
- Deployment entrypoints: “python server/server.py” (uvicorn inside), “streamlit run client/client.py”.

##### Extract Architecture Insights from README
- FastAPI + uvicorn host API
- python-dotenv for secrets
- langchain_groq + langchain_core for prompt templating & API calls
- Streamlit UI front-end
- Optional testing via Postman hitting /chain/invoke

##### Main Components and Interactions
a. Components
- Streamlit Client (client.py)
- HTTP Layer (requests library)
- FastAPI Server (server.py with uvicorn)
- Environment Loader (.env via python-dotenv)
- Langchain Core & Groq Adapter (in-process libraries)
- External Groq LLM Service (cloud API)
b. Relationships / Data Flows
1. User interacts with Streamlit UI → fills text + selects language.
2. Streamlit sends POST request to FastAPI /chain/invoke.
3. FastAPI server loads env vars, constructs LCEL chain (langchain_core + langchain_groq).
4. Server calls Groq API over HTTPS, receives LLM response.
5. Server returns JSON to Streamlit client.
6. Client displays result.
c. Architectural Patterns
- Client–Server separation
- RESTful API layer
- Dependency injection/config loading via python-dotenv
- External service integration pattern
d. Key Technologies
- FastAPI / uvicorn (ASGI web server)
- Streamlit + requests
- python-dotenv
- Langchain Core & Groq adapter
- Groq external LLM API

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    subgraph "Client"
        SLUI["Streamlit UI\n(Streamlit + requests)"]:::frontend
        HTTP["HTTP Client Layer\n(requests)"]:::frontend
        POSTMAN["Postman (Optional)"]:::frontend
    end

    SLUI --> HTTP
    POSTMAN -->|"POST /chain/invoke\n(JSON)"| API

    %% Backend Zone
    subgraph "Backend"
        ENV["Env Loader\n(python-dotenv)"]:::backend
        API["FastAPI Endpoint\n/chain/invoke"]:::backend
        LC["LCEL Chain Composition\n(langchain_core + langchain_groq)"]:::backend
    end

    HTTP -->|"POST /chain/invoke\n(JSON)"| API
    ENV --> API
    API --> LC
    LC -->|"HTTPS API Call\n(GROQ_API_KEY)"| GROQ
    GROQ["External Groq LLM Service"]:::external
    GROQ -->|"LLM Response\n(JSON)"| LC
    LC -->|"Processed Response\n(JSON)"| API
    API -->|"Response JSON"| HTTP

    %% Supporting Artifacts
    REQ["Requirements Definition\n(requirements.txt)"]:::docs
    NOTE["Demo Notebook\n(simpleLLMAppWithLCEL.ipynb)"]:::docs

    %% Click Events
    click SLUI "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/client/client.py"
    click HTTP "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/client/client.py"
    click API "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/server/server.py"
    click ENV "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/server/server.py"
    click LC "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/server/server.py"
    click REQ "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/requirements.txt"
    click NOTE "https://github.com/eniolaademola/llm-app-with-lcel/blob/main/simpleLLMAppWithLCEL.ipynb"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#D3F9D8,stroke:#2F855A,color:#2F855A
    classDef external fill:#FFE0B2,stroke:#ED8936,color:#DD6B20
    classDef docs fill:#E2E8F0,stroke:#4A5568,color:#2D3748,stroke-dasharray:5 5
```
