# lorenzopalaia/stackhound architecture

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

- Interactive diagram: https://gitdiagram.com/lorenzopalaia/stackhound
- Repository: https://github.com/lorenzopalaia/stackhound

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (React + TypeScript) that provides:
- A client-side UI for users to enter a GitHub username/repo
- A serverless API endpoint (/api/analyze) that fetches dependency files from GitHub and returns a detected tech stack

##### File structure
- Top level
- app/ – Next.js “App Router” directory
– api/analyze/route.ts → serverless function handling analysis requests
– page.tsx → home page UI
– layout.tsx, globals.css → global layout and styles (exclude per instructions)
- components/ – reusable React UI components (Hero, Header, Footer, ApiUsageSection, DemoSection, plus ui primitives)
- lib/ – core business logic
– techStackParser.ts → parses dependency file content into technology identifiers
– utils.ts → helper routines (e.g., GitHub file fetch)
- dependencies.ts – list of supported languages and file‐pattern mappings
- next.config.ts, tsconfig.json, etc. – configuration and build files

##### Pull key insights from the README
- The API calls the GitHub REST API (requires GITHUB_TOKEN)
- Supports detection across many ecosystems (npm, pip, Maven, RubyGems, Docker, etc.)
- No persistent database; processing is done in memory per request

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client"
        Browser["Browser"]:::external
        subgraph "Next.js UI"
            Page["app/page.tsx"]:::frontend
            Hero["components/Hero.tsx"]:::frontend
            Header["components/Header.tsx"]:::frontend
            Footer["components/Footer.tsx"]:::frontend
            ApiUsage["components/ApiUsageSection.tsx"]:::frontend
            Demo["components/DemoSection.tsx"]:::frontend
            subgraph "UI Primitives"
                Badge["components/ui/badge.tsx"]:::frontend
                Button["components/ui/button.tsx"]:::frontend
                Card["components/ui/card.tsx"]:::frontend
                CodeBlock["components/ui/code-block.tsx"]:::frontend
                Input["components/ui/input.tsx"]:::frontend
                Label["components/ui/label.tsx"]:::frontend
                Select["components/ui/select.tsx"]:::frontend
            end
        end
    end

    subgraph "Server"
        subgraph "API Layer"
            ApiRoute["app/api/analyze/route.ts"]:::backend
        end
        subgraph "Parser Module"
            Parser["lib/techStackParser.ts"]:::library
            Utils["lib/utils.ts"]:::library
            Deps["dependencies.ts"]:::library
        end
        External["GitHub REST API"]:::external
    end

    Browser -->|"navigates to UI"| Page
    Page -->|"submits request to /api/analyze"| ApiRoute
    ApiRoute -->|"fetch files"| External
    ApiRoute -->|"pass files to parser"| Parser
    Parser -->|"returns tech list"| ApiRoute
    ApiRoute -->|"responds JSON"| Page

    click Page "https://github.com/lorenzopalaia/stackhound/blob/main/app/page.tsx"
    click Hero "https://github.com/lorenzopalaia/stackhound/blob/main/components/Hero.tsx"
    click Header "https://github.com/lorenzopalaia/stackhound/blob/main/components/Header.tsx"
    click Footer "https://github.com/lorenzopalaia/stackhound/blob/main/components/Footer.tsx"
    click ApiUsage "https://github.com/lorenzopalaia/stackhound/blob/main/components/ApiUsageSection.tsx"
    click Demo "https://github.com/lorenzopalaia/stackhound/blob/main/components/DemoSection.tsx"
    click Badge "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/badge.tsx"
    click Button "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/button.tsx"
    click Card "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/card.tsx"
    click CodeBlock "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/code-block.tsx"
    click Input "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/input.tsx"
    click Label "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/label.tsx"
    click Select "https://github.com/lorenzopalaia/stackhound/blob/main/components/ui/select.tsx"
    click ApiRoute "https://github.com/lorenzopalaia/stackhound/blob/main/app/api/analyze/route.ts"
    click Parser "https://github.com/lorenzopalaia/stackhound/blob/main/lib/techStackParser.ts"
    click Utils "https://github.com/lorenzopalaia/stackhound/blob/main/lib/utils.ts"
    click Deps "https://github.com/lorenzopalaia/stackhound/blob/main/dependencies.ts"

    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#D0F0D0,stroke:#22863a,color:#22863a
    classDef library fill:#FFF4C1,stroke:#b36b00,color:#b36b00
    classDef external fill:#E0E0E0,stroke:#444,color:#444
```
