# joji-iba/2025_next.js_approuter_portfolio architecture

> Architecture diagram of the GitHub repository joji-iba/2025_next.js_approuter_portfolio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joji-iba/2025_next.js_approuter_portfolio
- Repository: https://github.com/joji-iba/2025_next.js_approuter_portfolio

## Overview

##### Project Type and Purpose
- This project is a single-page application (SPA) portfolio built with React and Next.js, written in TypeScript, and styled using TailwindCSS.
- It serves as a personal portfolio with several interactive components such as dark mode switching, animated transitions (via framer-motion), and specific functionalities like an inquiry form (using react-hook-form and zod for validation), email sending (using an API route with nodemailer), and authentication (with Firebase). There’s also mention of planned enhancements like dynamic routing via microCMS.

##### File Structure Analysis
- The top-level structure shows configuration files (ESLint, Prettier, Tailwind, Jest, etc.), a public directory, and a src folder.
- The public directory holds static assets like images, PDFs, and email templates used for nodemailer.
- The src/app directory contains pages and components split by feature (about, contact, projects) as well as an API folder with routes (for example, the API for contact form handling).
- The src/components folder holds reusable UI components (e.g., NavBar, Footer, Layout) and even some hooks (like useThemeSwitcher for dark mode).
- The organization closely follows Next.js 13+ app directory patterns, ensuring clear separation between routes, components, and API endpoints.

##### Extracted Architectural Insights from the README
- The project leverages Next.js features for both frontend rendering and API route building.
- Major features involve state management (e.g., dark mode), form handling with validation, API integration for email (via nodemailer), and third-party authentication (Firebase).
- Use of libraries like framer-motion for animations, react-hook-form and zod for form handling and validation, which indicates attention to user interaction and feedback.

(a) Identify the main components:
- Browser Client: Represents the user interface running in the user’s web browser.
- Next.js Frontend: Includes all pages (about, projects, contact) and reusable UI components along with layout and state management (dark mode, animation effects).
- API Layer: Next.js API routes (like the /api/contact-form) which handle backend processes such as mailing.
- External/Third-party Services:
- Firebase for authentication.
- Nodemailer integration for sending email via the configured API.
- (Planned) microCMS for dynamic page routing or content management.
- Static Assets: Public directory contents (images, PDFs, email templates) which are directly served and used by the application.
- Utility Layers: Testing (Jest), styling (TailwindCSS), and configuration files (ESLint, Prettier, etc.) forming the development infrastructure.

(b) Determine the interactions:
- User actions on the UI trigger data flows. For instance, submitting a contact form on the Contact page results in an API call to the /api/contact-form route.
- The API endpoint processes the form, validates (potentially using zod), and then uses nodemailer to send email notifications.
- User authentication interactions are managed via Firebase; this is integrated in the frontend and may exchange data with Firebase servers.
- All pages and components rely on static assets (CSS, images, templates) served from the public folder.
- Planned integrations (like microCMS) would connect to these layers to dynamically fetch content or route pages.

(c) Highlight Architectural Patterns and Design Principles:
- Separation of Concerns: The UI components (React/Next.js pages) are clearly separated from backend API logic.
- Modular Structure: The use of feature-based directories (about, contact, projects) and separate reusable components.
- Client/Server Separation: Server-side API endpoints versus client-side UI rendering.
- Use of third-party libraries and services (Firebase, nodemailer, framer-motion) to handle specialized functionality.

(d) Relevant Technologies and Frameworks:
- Next.js (React framework with SSR and API routes)
- TypeScript for type safety.
- TailwindCSS for styling.
- Framer-motion for animations.
- React-Hook-Form and zod for form handling and validations.
- Firebase for authentication.
- Nodemailer for handling email sending within API routes.

##### Elements
- Use clear labels for each component (e.g., "Client UI", "Next.js API", "Firebase Auth", "Nodemailer Email Service", "Static Assets").
- From the Browser Client to the Frontend pages.
- From user interactions (e.g., form submissions on the Contact page) to the API endpoints.
- From the API endpoints to external services (Firebase, nodemailer).
- Annotations indicating libraries or frameworks used (e.g., framer-motion for animations, react-hook-form for form handling).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Node
    Browser["User Browser"]:::ui

    %% Frontend Pages Subgraph
    subgraph "Frontend Pages"
        MainPage["Main Layout & Home"]:::frontend
        About["About Page"]:::frontend
        Contact["Contact Page"]:::frontend
        Projects["Projects Page"]:::frontend
    end

    %% Reusable UI Components Subgraph
    subgraph "Reusable UI Components"
        NavBar["Navigation"]:::ui
        Footer["Footer"]:::ui
        LayoutComp["Layout (Component)"]:::ui
        Transition["TransitionEffect"]:::ui
        ThemeHook["useThemeSwitcher Hook"]:::ui
        AnimatedText["AnimatedText"]:::ui
    end

    %% API Layer
    API["Contact Form API"]:::api

    %% Utility / Validation
    Validation["Validation Schema"]:::util

    %% External Services Subgraph
    subgraph "External Services"
        Firebase["Firebase Auth"]:::external
        Nodemailer["Nodemailer Email Service"]:::external
    end

    %% Static Assets
    Assets["Static Assets"]:::assets

    %% Relationships
    Browser -->|"loads"| MainPage
    Browser -->|"loads"| About
    Browser -->|"loads"| Contact
    Browser -->|"loads"| Projects

    MainPage -->|"includes"| NavBar
    MainPage -->|"includes"| Footer
    MainPage -->|"applies"| LayoutComp
    MainPage -->|"uses"| Transition
    MainPage -->|"switches"| ThemeHook
    MainPage -->|"enhances"| AnimatedText

    About -->|"composes"| NavBar
    About -->|"composes"| Footer

    Projects -->|"composes"| NavBar
    Projects -->|"composes"| Footer

    Contact -->|"triggers"| API
    API -->|"validates"| Validation
    API -->|"sends mail via"| Nodemailer

    MainPage -->|"integrates"| Firebase
    About -->|"integrates"| Firebase
    Projects -->|"integrates"| Firebase
    Contact -->|"integrates"| Firebase

    Assets -->|"supplies"| MainPage
    Assets -->|"supplies"| About
    Assets -->|"supplies"| Projects
    Assets -->|"supplies"| Contact

    %% Click Events for Client UI Pages
    click MainPage "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/app/page.tsx"
    click MainPage "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/app/layout.tsx"
    click About "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/app/about/page.tsx"
    click Contact "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/app/contact/page.tsx"
    click Projects "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/app/projects/page.tsx"

    %% Click Events for Reusable UI Components & Client-Side Logic
    click NavBar "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/components/NavBar.tsx"
    click Footer "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/components/Footer.tsx"
    click LayoutComp "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/components/Layout.tsx"
    click Transition "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/components/TransitionEffect.tsx"
    click ThemeHook "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/components/hooks/useThemeSwitcher.tsx"
    click AnimatedText "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/components/AnimatedText.tsx"

    %% Click Event for API Layer
    click API "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/app/api/contact-form/route.ts"

    %% Click Event for External Integration
    click Firebase "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/firebase.js"

    %% Click Event for Static Assets
    click Assets "https://github.com/joji-iba/2025_next.js_approuter_portfolio/tree/main/public"

    %% Click Event for Validation Schema
    click Validation "https://github.com/joji-iba/2025_next.js_approuter_portfolio/blob/main/src/utils/validationSchema.ts"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef assets fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef util fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef ui fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
```
