# bamiseomolaso/portfoliowebsite architecture

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

- Interactive diagram: https://gitdiagram.com/bamiseomolaso/portfoliowebsite
- Repository: https://github.com/bamiseomolaso/portfoliowebsite

## Overview

##### Project Type & Purpose
- This is a full-stack, modern, responsive portfolio website built with Next.js that showcases a professional’s expertise.
- It integrates a blog, portfolio sections with tag filtering, an admin dashboard, and robust features such as newsletter subscription, email authentication, performance monitoring, and security measures (e.g., rate limiting, reCAPTCHA, sanitization).
- External systems like Supabase (for database and authentication), Resend (for email notifications), Upstash Redis (for rate limiting), and Google reCAPTCHA (for form protection) are core to its operation.

##### File Structure
- The top-level structure includes configuration files (.babelrc, eslint, prettier, etc.), a public folder for static assets (including the PDF CV), and a robust “src” directory which houses the application’s code.
- The “src/app” directory (using Next.js App Router) is segmented into multiple areas: pages for about, blog, contact, admin, newsletter, portfolio, and privacy-policy.
- The “src/app/api” folder contains key API routes, e.g., for contact forms, newsletter subscriptions, performance monitoring, subscriber/export endpoints, and email authentication.
- Additional directories such as “components”, “lib”, “types”, and “database” illustrate how the project modularizes reusable elements, utility functions (security, rate limiting, caching), and the database schema.
- There is also support for server-side scripts and Supabase migrations (in the “supabase” folder) that define and manage the back-end database schemas.

##### Main Components & Their Relationships
a. Frontend:
- Next.js Application:
- Containing page components (e.g., home, about, blog, portfolio, contact) and layout components (Navbar, Footer, global layout).
- Admin dashboard pages in “src/app/admin” manage newsletters, performance, projects, and email authentication.
- Client-Side Components:
- Shared components such as ContactForm, Newsletter, CookieConsent, ErrorBoundary, etc.
- Integration with libraries like Framer Motion for animations and Tailwind CSS for styling.

b. Backend/API:
- API Routes:
- Located under “src/app/api”, these include endpoints to handle contact requests, email authentication, newsletter subscriptions and distribution, performance data collection, and subscriber management.
- Each API route may involve middleware for rate limiting, IP/security checks, and input sanitization.
- Utility Libraries:
- Functions in “src/lib” manage core logic for email sending (using Resend), security tasks, rate limiting (using Upstash Redis), Supabase client interactions, caching, and sanitization.

c. External Services:
- Supabase:
- Provides the database (with migrations detailed in the “supabase/migrations” folder) and authentication services.
- Resend:
- Handles email notifications and sending functions (code found in lib/resend.ts).
- Upstash Redis:
- Implements rate limiting policies for API calls.
- Google reCAPTCHA:
- Secures forms (as indicated in the README and environment configuration).

d. Database:
- Managed by Supabase with a schema SQL file in “src/database/schema.sql” and explicit migration files in the “supabase/migrations” folder.
- Supports tables for newsletters, subscribers, performance metrics, and security improvements.

##### Architectural Patterns / Design Principles
- Modular Design: Separation of concerns between client components, API endpoints, and backend libraries.
- API-driven Communication: The frontend communicates with the backend through well-defined API routes.
- Security & Performance: Emphasis on input sanitization, cookie management, rate limiting, and security middleware.
- Organized Folder Structure: Clear categorization which separates presentation (pages and components), logic (lib and hooks), types, and static assets.
- Utilization of modern React/Next.js capabilities and CSS frameworks for a responsive, dynamic user experience.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U("User"):::client

    %% Client Layer
    subgraph "Client Layer"
        F("Next.js Pages"):::client
        CP("UI Components (src/app/components)"):::client
        CS("Shared Components (src/components)"):::client
    end

    %% Application/Server Layer
    subgraph "Application Layer"
        AD("Admin Dashboard"):::server
        API("API Endpoints"):::server
        UL("Utility Libraries"):::server
    end

    %% Data & External Services Layer
    subgraph "Data & External Layer"
        subgraph "Database"
            DS("SQL Schema"):::data
            DM("Migrations"):::data
        end
        subgraph "External Services"
            ES1("Supabase Auth&DB"):::external
            ES2("Resend Email"):::external
            ES3("Upstash Redis"):::external
            ES4("Google reCAPTCHA"):::external
        end
    end

    %% Connections
    U -->|"interacts"| F
    F -->|"navigatesTo"| AD
    F -->|"requests"| API
    F -->|"renders"| CP
    F -->|"renders"| CS

    AD -->|"adminCalls"| API
    API -->|"invokes"| UL

    UL -->|"sendsEmail"| ES2
    UL -->|"rateLimits"| ES3
    UL -->|"dbAuthCalls"| ES1
    UL -->|"validatesCaptcha"| ES4

    ES1 -->|"readsWrites"| DS
    ES1 -->|"applies"| DM

    %% Click Events
    click F "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/src/app"
    click AD "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/src/app/admin"
    click API "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/src/app/api"
    click CP "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/src/app/components"
    click CS "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/src/components"
    click UL "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/src/lib"
    click DS "https://github.com/bamiseomolaso/portfoliowebsite/blob/main/src/database/schema.sql"
    click DM "https://github.com/bamiseomolaso/portfoliowebsite/tree/main/supabase/migrations"
    click ES1 "https://github.com/bamiseomolaso/portfoliowebsite/blob/main/src/lib/supabase.ts"
    click ES2 "https://github.com/bamiseomolaso/portfoliowebsite/blob/main/src/lib/resend.ts"
    click ES3 "https://github.com/bamiseomolaso/portfoliowebsite/blob/main/src/lib/rate-limit.ts"
    click ES4 "https://github.com/bamiseomolaso/portfoliowebsite/blob/main/src/config/env.ts"

    %% Styles
    classDef client fill:#a1c4fd,stroke:#333,stroke-width:2px;
    classDef server fill:#c1e1c5,stroke:#333,stroke-width:2px;
    classDef data fill:#f9d423,stroke:#333,stroke-width:2px;
    classDef external fill:#ffb3ba,stroke:#333,stroke-width:2px;
```
