# riddhidhara/inpost architecture

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

- Interactive diagram: https://gitdiagram.com/riddhidhara/inpost
- Repository: https://github.com/riddhidhara/inpost

## Overview

##### Main Components
- User Interface (UI): Represented by the HTML files (index.html and generatePost.html) along with their matching CSS (index.css and generatePost.css). These form the presentation layer for the application.
- Frontend Logic: The corresponding JavaScript files (index.js and generatePost.js) handle user interactions, trigger API calls, and manage the UI state.
- External Services: Two key external API services are involved:
- Gemini API: Responsible for generating random or custom LinkedIn posts.
- EmailJS API: Manages automated email delivery of generated posts.
- Optional/Supporting Elements: Although not part of the file tree, the README mentions environment variables and a proxy server to securely store API keys. This could be illustrated as an auxiliary component responsible for configuration and security.

##### Relationships and Data Flows
- User Action: A user interacts with the UI (e.g., clicking a button on the “Random Post Generator” or “Custom Post Generator” interface), which is captured by the front-end JavaScript.
- API Integration: The JavaScript layer makes HTTP requests to the Gemini API to fetch generated content based on either random or custom prompts.
- Response Handling: Once a response is received, the content is rendered back into the UI.
- Email Scheduling: For the email scheduling feature, after the user enters their email information and prompt, the JavaScript sends a request to the EmailJS API. The response from EmailJS would confirm the scheduling/delivery process.
- Optional Secure Configuration: Illustrate a component (or note) representing the proxy server/environment variables used to shield API credentials.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project cleanly segregates structure (HTML), styling (CSS), and functionality (JavaScript).
- Modular Design: Different pages (index and generatePost) indicate that the application is modular, with each component handling a specific use case (i.e., standard navigation vs. post generation detail).
- External Service Integration: APIs are used as services, so it’s important to show the external data flow into the application and back out for email scheduling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser Subgraph
    subgraph "Client Browser"
        UI1["index.html + index.css"]:::ui
        UI2["generatePost.html + generatePost.css"]:::ui
        JS1["index.js"]:::js
        JS2["generatePost.js"]:::js
    end

    %% Connections within Client Browser
    UI1 -->|"userClick"| JS1
    UI2 -->|"userClick"| JS2

    %% Configuration/Proxy server for secure API key handling
    Config["Proxy/Configuration"]:::config

    %% External Services Subgraph
    subgraph "External Services"
        Gemini["Gemini API (Post Generation)"]:::api
        Email["EmailJS API (Email Scheduling)"]:::api
    end

    %% JS nodes call external services via Proxy/Configuration
    JS1 -->|"APICall"| Config
    JS2 -->|"APICall"| Config
    
    %% Configuration routes requests to external APIs
    Config -->|"PostGeneration"| Gemini
    Config -->|"EmailScheduling"| Email

    %% Click Events for UI and JS components
    click UI1 "https://github.com/riddhidhara/inpost/blob/master/index.html"
    click UI1 "https://github.com/riddhidhara/inpost/blob/master/index.css"
    click UI2 "https://github.com/riddhidhara/inpost/blob/master/generatePost.html"
    click UI2 "https://github.com/riddhidhara/inpost/blob/master/generatePost.css"
    click JS1 "https://github.com/riddhidhara/inpost/blob/master/index.js"
    click JS2 "https://github.com/riddhidhara/inpost/blob/master/generatePost.js"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef js fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef config fill:#D8BFD8,stroke:#000,stroke-width:1px;
    classDef api fill:#FFC0CB,stroke:#000,stroke-width:1px;
```
