# dtran421/portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/dtran421/portfolio
- Repository: https://github.com/dtran421/portfolio

## Overview

##### Main Components
a. Frontend (Next.js Client Application)
- Pages & Layouts: Under src/app (e.g., main-layout.tsx, blog pages, portfolio, projects, resume, not-found pages)
- Components: In src/components subdivided into functional groups (Blog, Portfolio, Projects, Resume) that build the user interface.
- Styling & Assets: Global CSS (src/styles), Tailwind configuration (tailwind.config.js), and Storybook (for isolated component development in .storybook).
- State & Hooks: Custom React hooks (src/hooks) and context providers (src/contexts) for theme and possibly other states.

b. Backend/API Layer (Next.js API Routes)
- API Routes: Located under src/app/api where you see endpoints for “alphavantage” (for stock market data) and “blog/draft” management.
- GraphQL Integration: Files under src/graphql indicate that some portions of the site, like blog posts, resumes, or timeline data, are queried using GraphQL.

c. Infrastructure & Tools
- Testing & CI/CD: Cypress for end-to-end tests (cypress/) and GitHub Actions workflows (in the .github/workflows folder) for deployment and previews.
- Developer Tools: ESLint, Prettier, Husky pre-commit hooks, and patch files for specific dependencies.
- External APIs/Services: The alphavantage API endpoint suggests integration with third-party financial data. Additionally, some public files (Excel, PDF) are served from the public directory.

##### Relationships and Interactions
- The Frontend renders pages that fetch data either through Next.js API routes or directly using GraphQL queries.
- API routes serve as an intermediary between the client-side logic and external services (such as alphavantage).
- UI Components (found in src/components) combine with hooks and context to manage state, interactivity, and theme.
- Testing tools (like Cypress) are integrated to simulate user behavior and ensure data flow correctness from frontend to backend.
- GitHub Actions and Husky keep code quality, automated deployment, and code formatting in check.

##### Architectural Patterns
- Separation of concerns: Distinct separation between page layout (src/app) and re-usable components (src/components).
- Next.js File-based Routing: Clearly distinguishes between public pages and API endpoints.
- Component Isolation: Storybook is used to build and test individual UI components outside the full application.
- Dependency Injection & Context: Use of React Context (src/contexts) and custom hooks to manage shared states across components.

##### Additional Details
- Use of patches and configuration files (like next.config.js, tsconfig.json, and postcss.config.js) which indicate careful management of both build-time and runtime environments.
- Modules like src/utils and src/hooks that aid in data formatting, API calls, and general utility functions, tying them into the overall data flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A["Next.js Page Layer"]
        B["UI Components"]
        C["Global Styles"]
        Y["Tailwind Config"]
        Z["Storybook"]
        D["Hooks"]
        E["Contexts"]
    end

    %% Backend Services
    subgraph "Backend Services"
        subgraph "API Endpoints"
            E1["Alphavantage Endpoint"]
            E2["Blog Draft Endpoint"]
        end
        F["GraphQL Integration"]
        K["External Financial Data"]
    end

    %% Infrastructure & Tools
    subgraph "Infrastructure & Tools"
        subgraph "Testing & CI/CD"
            G1["Cypress Tests"]
            G2["GitHub Actions"]
        end
        subgraph "Developer Tooling"
            H1["ESLint"]
            H2["Prettier"]
            H3["Husky"]
        end
        I["Public Assets"]
        J["Utility Functions"]
    end

    %% Connections within Frontend
    A -->|"renders"| B
    A -->|"uses"| C
    A -->|"configures"| Y
    B -->|"developedIn"| Z
    B -->|"utilizes"| D
    B -->|"utilizes"| E

    %% Connections between Frontend and Backend
    A -->|"callsAPI"| E1
    A -->|"callsAPI"| E2
    B -->|"queries"| F
    A -->|"fetchesData"| F

    %% External integration
    E1 -->|"fetches"| K

    %% Utility Functions support
    J -->|"assists"| A
    J -->|"assists"| B
    J -->|"assists"| F
    J -->|"assists"| E1

    %% Infrastructure & Tools connections
    G1 -->|"tests"| A
    G2 -->|"CI/CD"| A
    H1 -->|"lints"| A
    H2 -->|"formats"| A
    H3 -->|"hooksCommit"| A

    %% Styles for Nodes
    class A,B,C,Y,Z,D,E frontend
    class E1,E2,F,K backend
    class G1,G2,H1,H2,H3,I,J infra

    %% Class Definitions
    classDef frontend fill:#cfe2f3,stroke:#0b5394,stroke-width:2px;
    classDef backend fill:#f4cccc,stroke:#cc0000,stroke-width:2px;
    classDef infra fill:#d9ead3,stroke:#38761d,stroke-width:2px;

    %% Click Events
    click A "https://github.com/dtran421/portfolio/tree/main/src/app"
    click B "https://github.com/dtran421/portfolio/tree/main/src/components"
    click C "https://github.com/dtran421/portfolio/tree/main/src/styles"
    click Y "https://github.com/dtran421/portfolio/blob/main/tailwind.config.js"
    click Z "https://github.com/dtran421/portfolio/blob/main/.storybook"
    click D "https://github.com/dtran421/portfolio/tree/main/src/hooks"
    click E "https://github.com/dtran421/portfolio/tree/main/src/contexts"
    click E1 "https://github.com/dtran421/portfolio/tree/main/src/app/api/alphavantage"
    click E2 "https://github.com/dtran421/portfolio/tree/main/src/app/api/blog/draft"
    click F "https://github.com/dtran421/portfolio/tree/main/src/graphql"
    click G1 "https://github.com/dtran421/portfolio/tree/main/cypress"
    click G2 "https://github.com/dtran421/portfolio/tree/main/.github/workflows"
    click H1 "https://github.com/dtran421/portfolio/blob/main/.eslintrc.json"
    click H2 "https://github.com/dtran421/portfolio/blob/main/.prettierrc"
    click H3 "https://github.com/dtran421/portfolio/blob/main/.husky"
    click I "https://github.com/dtran421/portfolio/tree/main/public"
    click J "https://github.com/dtran421/portfolio/tree/main/src/utils"
```
