# paulbratslavsky/epic-next-15-strapi-5 architecture

> Architecture diagram of the GitHub repository paulbratslavsky/epic-next-15-strapi-5, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paulbratslavsky/epic-next-15-strapi-5
- Repository: https://github.com/paulbratslavsky/epic-next-15-strapi-5

## Overview

##### Project Type and Purpose
- This is a full-stack web application.
- Purpose: It allows users to upload YouTube videos, generate AI-powered summaries using OpenAI, manage video summaries (CRUD operations), and includes authentication as well as search & pagination features.
- It uses Next.js (frontend) and Strapi CMS (backend) together with integrations to external services like OpenAI’s GPT-4 and the YouTube Transcript API.

##### Analyzing the File Structure
- The top-level directories show three main segments:
- "backend" – Contains full Strapi CMS files including configuration files for API, database, plugins, middlewares, and routes. It is organized into clearly separated API sections for different content types (global, home-page, summary) along with admin and extensions directories.
- "frontend" – Contains Next.js files with app directories, custom components, pages for authentication, dashboard, and API endpoints (like summarization).
- "blog" – Contains blog posts and blog images used to support documentation or tutorial content.
- Presence of configuration files (like .env.example, tsconfig.json, vite.config.example.ts) and clear directory segmentation (src, config, public) points to a modular and layered architecture.

##### Main Components
a. Frontend Component:
- Major services like UI components (custom features, forms, layout), data services for auth, file upload, and summary operations.
- Use of TypeScript, Tailwind CSS, and Shadcn UI components.

b. Backend Component:
- API Modules: Global, Home-Page, Summary (with clearly divided folders, controllers, routes, etc.)
- Admin and Extension modules: e.g., the “users-permissions” extension that handles user management.
- Middlewares: JWT authentication, custom middlewares (e.g., is-owner checks, on-summary-create) built to handle access and data integrity.
- Services: Show controllers and service layers that encapsulate business logic.
- Database: Indicate that PostgreSQL is the datastore with included migration scripts.

c. External Services:
- “OpenAI / AI Integration” component, connected to the backend (for AI-powered summary generation).
- “YouTube Transcript API” for transcript extraction.

d. Blog Component:
- A separate module labeled “Blog Content” (not strictly part of core functionality but part of supporting documentation and content).

e. Deployment:
- “Vercel” for frontend deployment.
- “Strapi Cloud” for backend deployment.
- Environment configurations and deployment settings.

##### Relationships and Interactions
- Authentication flow: Frontend sends login/registration requests to the backend; backend returns a JWT with secure cookie management.
- Between the components, show data flows, such as file uploads from the frontend to the backend and then to storage.

##### Architectural Patterns and Design Principles
- Separation of concerns (frontend vs. backend).
- RESTful or API-based routing and controller-service pattern present in the backend.
- Usage of middleware patterns for authentication and content validation.
- Mention the modular usage of extensions in Strapi to allow for custom content-types like “user.”

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F_Main("Next.js Frontend"):::frontend
        F_App("App (Pages & API Routes)"):::frontend
        F_Com("Components (UI & Layouts)"):::frontend
        F_Main --> F_App
        F_Main --> F_Com
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B_Main("Strapi API Backend"):::backend
        subgraph "API Modules"
            B_Global("Global API"):::backend
            B_Home("Home-Page API"):::backend
            B_Summary("Summary API"):::backend
        end
        B_Main --> B_Global
        B_Main --> B_Home
        B_Main --> B_Summary

        B_Admin("Admin & Extensions (User Management)"):::backend

        subgraph "Middlewares"
            B_MW("General Middleware"):::backend
            B_SMW("Summary Middleware"):::backend
        end

        subgraph "Database"
            B_DBConfig("Database Config"):::backend
            B_DBMigr("Database Migrations"):::backend
        end

        %% Connect backend main with its components
        B_Main -->|"Handles auth, fileupload & content"| B_Admin
        B_Main --> B_MW
        B_Main --> B_SMW
        B_Main -->|"CRUD operations"| B_DBConfig
        B_Main -->|"CRUD operations"| B_DBMigr
    end

    %% External Services
    subgraph "External Services"
        E_OpenAI("AI Integration (OpenAI GPT-4)"):::external
        E_YT("YouTube Transcript API"):::external
    end

    %% Deployment Environment
    subgraph "Deployment"
        D_Vercel("Vercel Deployment"):::deployment
        D_Strapi("Strapi Cloud Deployment"):::deployment
    end

    %% Blog Content Repository
    Blog("Blog Content Repository"):::blog

    %% Interactions
    D_Vercel --> F_Main
    D_Strapi --> B_Main
    F_Main -->|"API communication"| B_Main
    F_Main -->|"authentication"| B_Admin
    F_Main -->|"fileupload"| B_Main
    B_Main -->|"Data storage"| B_DBConfig
    B_Main -->|"Data storage"| B_DBMigr
    B_Main -->|"AI-summary"| E_OpenAI
    B_Main -->|"Transcript extraction"| E_YT
    Blog ---|"Documentation/Content"| F_Main

    %% Click Events for Frontend Components
    click F_App "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/frontend/src/app"
    click F_Com "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/frontend/src/components"

    %% Click Events for Strapi API Modules
    click B_Global "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/src/api/global"
    click B_Home "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/src/api/home-page"
    click B_Summary "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/src/api/summary"

    %% Click Event for Admin & Extensions
    click B_Admin "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/src/extensions/users-permissions"

    %% Click Events for Middleware
    click B_MW "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/src/middlewares"
    click B_SMW "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/src/api/summary/middlewares"

    %% Click Events for Database Components
    click B_DBConfig "https://github.com/paulbratslavsky/epic-next-15-strapi-5/blob/main/backend/config/database.ts"
    click B_DBMigr "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/backend/database/migrations"

    %% Click Event for Blog Content Repository
    click Blog "https://github.com/paulbratslavsky/epic-next-15-strapi-5/tree/main/blog"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef deployment fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef blog fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
