# rakkun9/translasite architecture

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

- Interactive diagram: https://gitdiagram.com/rakkun9/translasite
- Repository: https://github.com/rakkun9/translasite

## Overview

Para guiar al ingeniero principal en la creación de un diagrama de arquitectura para TranslaSite, sigue estos pasos, ajustados a la estructura y propósito del proyecto tal como aparecen en el file tree y el README:

##### Identificar el tipo y propósito del proyecto
- TranslaSite es una aplicación web de traducción de texto full-stack (frontend estático generado con Astro y un backend/API de traducción).
- Proporciona una interfaz para que el usuario ingrese texto, seleccione idiomas y obtenga la traducción de la IA de Google Generative AI (GEMINI).

##### Analizar el file tree y el README
- Configuración de Astro: `astro.config.mjs`, TailwindCSS (`tailwind.config.mjs`).
- Dependencias: `package.json`, lockfiles (`npm` y `pnpm`).
- Público: carpeta `public/` con assets.
- Backend/API (según README): debería existir un servidor Express en `server/index.js` (aunque no aparece en el file tree, se asume su implementación o una función serverless en Vercel).
- Deployment: configuración de Vercel en `vercel.json`.

##### Componentes principales a representar
A. Frontend (Cliente)
- Astro Renderer
- Componente de UI: Header, Footer, Card, Forms (Selector de idiomas, área de texto)
- Lógica de cliente: `ExchangeButton.js`, `GeminiTranslate.js` que envían peticiones
B. Backend/API
- Servidor Node.js + Express (o función serverless en Vercel)
- Endpoints CORS habilitados
C. Servicio externo
- Google Generative AI (GEMINI) HTTPS API
D. Infraestructura de hosting
- Vercel Hosting (frontend estático + serverless functions)

##### Relaciones e interacciones
- Flechas que vayan:
Usuario → Astro UI (navegador)
Astro UI (JS) → API Express en Vercel (POST /translate)
API Express → Google GEMINI API (HTTP HTTPS request)
Google GEMINI API → API Express (response)
API Express → Astro UI (JSON con traducción)
Astro UI → Usuario (muestra texto traducido)
- Anotar protocolos: HTTP/HTTPS, CORS, JSON

##### Patrones arquitectónicos relevantes
- Arquitectura cliente-servidor clásica
- Generación de sitio estático + serverless (JAMstack)
- Separación de capas: presentación (Astro), lógica de negocio (Express), servicio de IA (GEMINI)

##### Tecnologías y librerías clave
- Astro (SSG/SSR)
- Node.js, Express (o funciones serverless)
- Tailwind CSS
- JavaScript (módulos en `src/components/scripts`)
- Vercel (hosting + serverless)
- Google Generative AI (GEMINI) API

##### Instrucciones para el diagrama
a. Usa formas distintas (rectángulos para componentes internos, cilindros para servicios externos, nube para hosting)
- Azul para frontend
- Verde para backend/API
- Naranja para servicios externos
- Gris para hosting/infrestructura
c. Flechas direccionales con etiquetas de protocolo y formato de datos (por ejemplo, “POST /translate (JSON)”)
d. Añade etiquetas claras a cada componente (p.ej., “Astro Renderer”, “Express Server”, “GEMINI API”)
e. Incluye notas de configuración críticas (CORS habilitado, variables de entorno con API key)

##### Pautas finales
- Sé detallado: representa cada carpeta o módulo principal si aporta a la arquitectura (por ejemplo, `src/components/scripts/GeminiTranslate.js` como parte de la capa de integración con la API).
- No sobrecargar: agrupa componentes de presentación similares (todos los `.astro` de UI bajo “Astro UI Components”).
- Captura flujo completo: desde la interacción del usuario hasta la respuesta de la IA y renderizado final.

Con este esquema podrás elaborar un diagrama lo más fiel posible a la arquitectura real de TranslaSite, destacando claramente las capas, las relaciones y las tecnologías involucradas.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors and Infrastructure
    User(["User"]):::external
    subgraph "Vercel Hosting" 
        direction TB
        VercelCloud(["Vercel Hosting\n(Static + Serverless)"]):::infra
    end

    %% Frontend Layer
    subgraph "Frontend Layer" 
        direction TB
        AstroRenderer(["Astro Renderer"]):::frontend
        LayoutComponent(["Layout Component"]):::frontend
        subgraph "Astro Pages"
            direction TB
            IndexPage["index.astro"]:::frontend
            TranslaPage["TranslaSite.astro"]:::frontend
            ContactPage["Contact.astro"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            HeaderComp["Header.astro"]:::frontend
            FooterComp["Footer.astro"]:::frontend
            CardComp["Card.astro"]:::frontend
            ContainerTS["ContainerTranslaSite.astro"]:::frontend
            InfoComp["Information.astro"]:::frontend
            OptionsComp["Options.astro"]:::frontend
            SectionComp["SectionContainer.astro"]:::frontend
            TranslateComp["Translate.astro"]:::frontend
            ImgComp["TranslateImage.astro"]:::frontend
        end
        subgraph "Client Logic"
            direction TB
            ExchangeBtn["ExchangeButton.js"]:::frontend
            GeminiTrans["GeminiTranslate.js"]:::frontend
            GeminiImg["GeminiImage.js"]:::frontend
        end
        IconsLib(["Icons Library\n(src/icons)"]):::frontend
        Styling(["Tailwind & Tooling\n(tailwind.config.mjs, package.json)"]):::frontend
    end

    %% Backend Layer
    subgraph "Backend/API Layer"
        direction TB
        ExpressServer(["Express Server\n(POST /translate)"]):::backend
    end

    %% External Service
    subgraph "External AI Service"
        direction TB
        GeminiAPI(["Google GEMINI API"]):::externalService
    end

    %% Connections
    User -->|"interacts via browser"| IndexPage
    User -->|"interacts via browser"| TranslaPage
    User -->|"interacts via browser"| ContactPage
    IndexPage -->|renders with| AstroRenderer
    TranslaPage -->|renders with| AstroRenderer
    ContactPage -->|renders with| AstroRenderer
    AstroRenderer -->|uses| LayoutComponent
    LayoutComponent -->|composes| HeaderComp
    LayoutComponent -->|composes| FooterComp
    PagesComponents(Layout UI):::frontend --- UIComponents
    UIComponents -->|includes| OptionsComp
    UIComponents -->|includes| TranslateComp
    TranslateComp -->|binds scripts| ExchangeBtn
    ExchangeBtn -->|calls| ExpressServer
    ExchangeBtn -.->|CORS/JSON| ExpressServer
    ExchangeBtn -->|"POST /translate (JSON)"| ExpressServer
    ExpressServer -->|"HTTPS request"| GeminiAPI
    GeminiAPI -->|"JSON response"| ExpressServer
    ExpressServer -->|"JSON response"| GeminiTrans
    GeminiTrans -->|updates UI| TranslateComp
    GeminiImg -->|fetches images| GeminiAPI
    TranslateComp -->|displays| User

    %% Hosting Connections
    IndexPage -->|deployed on| VercelCloud
    TranslaPage -->|deployed on| VercelCloud
    ExpressServer -->|serverless on| VercelCloud

    %% Click Events
    click AstroRenderer "https://github.com/rakkun9/translasite/blob/master/astro.config.mjs"
    click LayoutComponent "https://github.com/rakkun9/translasite/blob/master/src/layouts/Layout.astro"
    click IndexPage "https://github.com/rakkun9/translasite/blob/master/src/pages/index.astro"
    click TranslaPage "https://github.com/rakkun9/translasite/blob/master/src/pages/TranslaSite.astro"
    click ContactPage "https://github.com/rakkun9/translasite/blob/master/src/pages/Contact.astro"
    click HeaderComp "https://github.com/rakkun9/translasite/blob/master/src/components/Header.astro"
    click FooterComp "https://github.com/rakkun9/translasite/blob/master/src/components/Footer.astro"
    click CardComp "https://github.com/rakkun9/translasite/blob/master/src/components/Card.astro"
    click ContainerTS "https://github.com/rakkun9/translasite/blob/master/src/components/ContainerTranslaSite.astro"
    click InfoComp "https://github.com/rakkun9/translasite/blob/master/src/components/Information.astro"
    click OptionsComp "https://github.com/rakkun9/translasite/blob/master/src/components/Options.astro"
    click SectionComp "https://github.com/rakkun9/translasite/blob/master/src/components/SectionContainer.astro"
    click TranslateComp "https://github.com/rakkun9/translasite/blob/master/src/components/Translate/Translate.astro"
    click ImgComp "https://github.com/rakkun9/translasite/blob/master/src/components/Translate/TranslateImage.astro"
    click ExchangeBtn "https://github.com/rakkun9/translasite/blob/master/src/components/scripts/ExchangeButton.js"
    click GeminiTrans "https://github.com/rakkun9/translasite/blob/master/src/components/scripts/GeminiTranslate.js"
    click GeminiImg "https://github.com/rakkun9/translasite/blob/master/src/components/scripts/GeminiImage.js"
    click IconsLib "https://github.com/rakkun9/translasite/tree/master/src/icons"
    click Styling "https://github.com/rakkun9/translasite/blob/master/tailwind.config.mjs"
    click Styling "https://github.com/rakkun9/translasite/blob/master/package.json"
    click VercelCloud "https://github.com/rakkun9/translasite/blob/master/vercel.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,stroke-width:2px
    classDef backend fill:#D4F4DD,stroke:#228B22,stroke-width:2px
    classDef externalService fill:#FFE4B5,stroke:#FF8C00,stroke-width:2px
    classDef infra fill:#E8E8E8,stroke:#696969,stroke-width:2px
    classDef external fill:#F0F0F0,stroke:#999999,stroke-width:2px
```
