# zaidmukaddam/miniperplx architecture

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

- Interactive diagram: https://gitdiagram.com/zaidmukaddam/miniperplx
- Repository: https://github.com/zaidmukaddam/miniperplx

## Overview

##### Main Components Identification

The system should be divided into these primary layers:
- Client Layer (Next.js Frontend)
- API Layer (Route Handlers)
- External Services Integration Layer
- UI Component Layer

##### Component Breakdown

Frontend Layer:
- To the UI components library (/components/ui/*)
- Specialized components (flight-tracker, interactive-maps, weather-chart)

API Layer:
- Main API routes:
- /api/chat
- /api/cohere
- /api/trending
- /api/upload
- /api/clean_images

External Services Layer:
- LLM providers:
- OpenAI (GPT-4o mini, GPT-4o)
- Anthropic (Claude 3.5 Sonnet, Haiku)
- xAI (Grok)
- Other API integrations:
- Tavily
- OpenWeather
- E2B
- Google Maps
- Mapbox
- TripAdvisor
- Microsoft Translator
- AviationStack

##### Connection Flows

- User requests flowing from frontend to API routes
- API routes connecting to external services
- Data flow returning to the frontend
- Component interactions within the frontend

##### Technical Stack Highlights

- Next.js framework
- Vercel AI SDK
- Tailwind CSS
- Shadcn/UI components
- Server-side API routes

**┌─ Client Layer ─────────────────┐**
- Pages                        │
- UI Components               │
- Interactive Features        │
- ┘
- ↕
**┌─ API Layer ──────────────────┐**
- Route Handlers             │
- Data Processing           │
- Model Selection          │
- ┘
- ↕
**┌─ External Services ──────────┐**
- LLM Providers             │
- Utility APIs             │
- Data Sources            │
- ┘

##### Additional Details

- Error handling paths
- Caching mechanisms
- Demonstrate the search engine integration flow
- Real-time data processing paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        direction TB
        FPages[Frontend Pages]
        UIComp[UI Components]
        Hooks[Custom Hooks]
        Animata[Animation Components]
    end

    subgraph APILayer
        direction TB
        Chat["Chat Service"]:::api
        Upload["Upload Handler"]:::api
        Trending["Trending Data"]:::api
        ImgProc["Image Processing"]:::api
    end

    subgraph ExternalServices
        direction TB
        AI[xAI Grok]:::external
        Search[Tavily]:::external
        Maps["Mapping Services"]:::external
        Weather[OpenWeather]:::external
        CodeExec[E2B]:::external
        Trans["Microsoft Translator"]:::external
        Flight[AviationStack]:::external
    end

    subgraph CoreFeatures
        direction TB
        FlightTrack[Flight Tracking]:::core
        InterMaps[Interactive Maps]:::core
        WeatherDisp[Weather Display]:::core
        SearchInt[Search Interface]:::core
        MovieInfo[Movie Information]:::core
        MarkdownRend[Markdown Rendering]:::core
        LocServices[Location Services]:::core
    end

    subgraph UILib
        direction TB
        Button[Button]:::ui
        Card[Card]:::ui
        Form[Form]:::ui
        Dialog[Dialog]:::ui
        NavMenu["Navigation Menu"]:::ui
    end

    %% Relationships
    FPages --> UIComp
    FPages --> CoreFeatures
    UIComp --> UILib
    APILayer --> ExternalServices
    CoreFeatures --> APILayer
    Hooks --> FPages
    Animata --> FPages

    %% Click Events
    click FPages "https://github.com/zaidmukaddam/miniperplx/tree/main/app"
    click Chat "https://github.com/zaidmukaddam/miniperplx/blob/main/app/api/chat/route.ts"
    click Upload "https://github.com/zaidmukaddam/miniperplx/blob/main/app/api/upload/route.ts"
    click Trending "https://github.com/zaidmukaddam/miniperplx/blob/main/app/api/trending/route.ts"
    click ImgProc "https://github.com/zaidmukaddam/miniperplx/blob/main/app/api/clean_images/route.ts"
    click FlightTrack "https://github.com/zaidmukaddam/miniperplx/blob/main/components/flight-tracker.tsx"
    click InterMaps "https://github.com/zaidmukaddam/miniperplx/blob/main/components/interactive-maps.tsx"
    click WeatherDisp "https://github.com/zaidmukaddam/miniperplx/blob/main/components/weather-chart.tsx"
    click SearchInt "https://github.com/zaidmukaddam/miniperplx/blob/main/components/multi-search.tsx"
    click MovieInfo "https://github.com/zaidmukaddam/miniperplx/blob/main/components/movie-info.tsx"
    click MarkdownRend "https://github.com/zaidmukaddam/miniperplx/blob/main/components/markdown-render.tsx"
    click LocServices "https://github.com/zaidmukaddam/miniperplx/blob/main/components/nearby-search-map-view.tsx"
    click Button "https://github.com/zaidmukaddam/miniperplx/blob/main/components/ui/button.tsx"
    click Card "https://github.com/zaidmukaddam/miniperplx/blob/main/components/ui/card.tsx"
    click Form "https://github.com/zaidmukaddam/miniperplx/blob/main/components/ui/form-component.tsx"
    click Dialog "https://github.com/zaidmukaddam/miniperplx/blob/main/components/ui/dialog.tsx"
    click NavMenu "https://github.com/zaidmukaddam/miniperplx/blob/main/components/ui/navigation-menu.tsx"
    click Hooks "https://github.com/zaidmukaddam/miniperplx/tree/main/hooks"
    click Animata "https://github.com/zaidmukaddam/miniperplx/tree/main/components/animata"

    %% Styling
    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef external fill:#a855f7,color:white
    classDef core fill:#f97316,color:white
    classDef ui fill:#6b7280,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend Components]:::frontend
        API[API Routes]:::api
        External[External Services]:::external
        Core[Core Features]:::core
        UI[UI Components]:::ui
    end
```
