# davilsonjunior/portfolio-experience architecture

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

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

## Overview

##### Main Project Components
- NextJS Application Layer: This includes the React/TypeScript components found in the src/components directory and pages stored in src/pages. Emphasize components like BannerProject, Experiences, Footer, FormContact, Header, HomeHero, Projects, SectionTitle, and knowledges.
- Slicemachine & Prismic Integration: The .slicemachine directory, along with customtypes and slices folders, indicate that content slices are managed by Slicemachine, which then integrate with Prismic (as seen in src/services/prismic.ts).
- API Routes/Server-Side Logic: The src/pages/api/contact.ts endpoint shows a backend layer (albeit simple) handling contact form submissions, potentially involving sendMail.ts in src/services.
- External Services: Prismic functions as the external CMS providing content that populates the portfolio.

##### Relationships and Data Flow
- Clients (web browsers) access the application via NextJS deployed as a web server.
- The presentation layer is composed of React pages and components, rendering the portfolio’s UI.
- When content is needed, the NextJS application will reach out to the Prismic CMS via the prismic service. Meanwhile, Slicemachine-generated slices and custom types serve as configuration/local representations of this content.
- The contact form interacts with a dedicated API route (src/pages/api/contact.ts), which processes and sends emails using the sendMail.ts service.
- The overall flow is: User Request → NextJS Server (page rendering & API calls) → External Prismic CMS (content fetching) / Email service (via contact API).

##### Architectural Patterns & Design Principles
- Modular/Component-Based Structure: Group related components (e.g., all UI pieces under src/components) and highlight the slices (managed by Slicemachine) that contribute to dynamic content rendering.
- Data Flow & Dependency: Illustrate how data flows from Prismic into the NextJS pages and how user interactions (like contact submissions) travel from the client to the API backend.
- The NextJS hybrid model: Emphasize both the server-side aspects (for API endpoints and possibly getStaticProps/getServerSideProps) and the client-side rendering.

- Validate with the file tree: make sure all layers (NextJS front-end, API routes, and external services) are connected logically.

This level of detail will help guide future development, maintenance, and potential enhancements by clearly outlining how components interact within the overall architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    client["Client Browser"]:::client

    subgraph "NextJS Application"
        %% Pages & Components
        subgraph "Pages & Components"
            pages["Pages (src/pages)"]:::frontend
            comps["Components (src/components)"]:::frontend
        end
        %% Slicemachine & Prismic Integration
        subgraph "Slices/Custom Types (Slicemachine)"
            sm[".slicemachine"]:::backend
            ct["Custom Types (customtypes/portfolio-davilsonjunior)"]:::backend
            prismicSvc["Prismic Integration Service (src/services/prismic.ts)"]:::backend
        end
        %% API Endpoints
        subgraph "API Endpoints"
            api["Contact API (src/pages/api/contact.ts)"]:::backend
            mail["Email Service Handler (src/services/sendMail.ts)"]:::backend
        end
    end

    prismicCMS["Prismic CMS"]:::external
    emailSvc["Email Service"]:::external

    %% Connections
    client --> pages
    pages -->|"renders"| comps
    pages -->|"fetchContent"| prismicSvc
    prismicSvc -->|"requestData"| prismicCMS
    sm -->|"defineSlices"| ct
    ct -->|"provideConfig"| prismicSvc
    pages -->|"submitContactForm"| api
    api -->|"processEmail"| mail
    mail -->|"sendEmail"| emailSvc

    %% Click Events
    click comps "https://github.com/davilsonjunior/portfolio-experience/tree/main/src/components"
    click pages "https://github.com/davilsonjunior/portfolio-experience/tree/main/src/pages"
    click sm "https://github.com/davilsonjunior/portfolio-experience/blob/main/.slicemachine"
    click ct "https://github.com/davilsonjunior/portfolio-experience/tree/main/customtypes/portfolio-davilsonjunior"
    click prismicSvc "https://github.com/davilsonjunior/portfolio-experience/blob/main/src/services/prismic.ts"
    click api "https://github.com/davilsonjunior/portfolio-experience/blob/main/src/pages/api/contact.ts"
    click mail "https://github.com/davilsonjunior/portfolio-experience/blob/main/src/services/sendMail.ts"

    %% Styles
    classDef client fill:#AED6F1,stroke:#000,stroke-width:1px;
    classDef frontend fill:#ABEBC6,stroke:#000,stroke-width:1px;
    classDef backend fill:#F9E79F,stroke:#000,stroke-width:1px;
    classDef external fill:#F5CBA7,stroke:#000,stroke-width:1px;
```
