# juaneduardo-dev/blogger-app-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/juaneduardo-dev/blogger-app-frontend
- Repository: https://github.com/juaneduardo-dev/blogger-app-frontend

## Overview

##### Project’s main components
- Frontend Application: Represented by the Next.js “src/app” folder which houses page routes for authentication (/login, /register, /forgot-password, /reset-password) and proposal-related pages (e.g., mis-propuestas, propuesta, temas). This includes the layout components (Navbar, Footer, session provider, UI components with Chakra UI, Shadcn, and others).
- API Layer: The “src/app/api” directory covers endpoints for authentication (NextAuth routes, forgot-password, register, reset-password), proposal operations (create, edit, delete, retrieve), user operations (get, put, delete), and other endpoints for degrees, publications, and reactions.
- Database Layer: The “prisma/schema.prisma” file indicates use of Prisma as an ORM to interact with the underlying database.
- Static Assets and Public Resources: The “public” directory provides static files like images used in the blog posts and other UI elements.
- Utility and Service Components: Directories like “src/lib”, “src/utils”, “src/context”, “src/hooks”, and “src/types” contain supporting code such as authentication helpers, utility functions, UI state management, and type definitions.

##### Relationships and interactions
- The Frontend interacts with the API layer. User-triggered actions (login, post proposal, comment, like, etc.) cause HTTP requests to API endpoints managed under “src/app/api”.
- The API endpoints then utilize Prisma (see “src/lib/prisma.ts” and “prisma/schema.prisma”) to perform database operations—reading and writing user data, proposals, interactions, etc.
- UI components interact with context providers (e.g., UserContext) and hooks for state management, offering a responsive and dynamic user experience.
- Static assets from the “public” folder support visual elements and possibly caching in the deployment configuration.

##### Architectural patterns and design principles
- Separation of Concerns: Clear separation between client-side rendering (React components/pages), server-side API routes, and database logic.
- MVC-like Organization: The Next.js routing structure effectively decouples views (pages) from business logic (API endpoints) and data models (prisma schema).
- Modular Component Design: Use of shared components (layout, UI components, hooks) demonstrates modularity and reuse.
- Secure and Robust Authentication: Dedicated API routes and authentication libraries (NextAuth) indicate attention to secure user sessions and data protection.

##### Relevant technologies, frameworks, and libraries
- Next.js for full-stack rendering and routing.
- Prisma as the ORM to interface with the database.
- NextAuth (via routes in /api/auth) for authentication.
- UI Libraries such as Chakra UI, Shadcn UI, and custom components for a responsive design.
- Tailwind CSS (tailwind.config.ts) for design/custom styles.

- Components with clear labels (e.g., “Frontend – Next.js Pages”, “API Endpoints – Authentication”, “Database – Prisma Schema”, “Static Assets”).
- Modular design by grouping related components (authentication routes, publication management, UI components) and showing dependencies (e.g., which API endpoints interact with which database models).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Legend
    subgraph "Legend"
        LEG1["Rectangle: Presentation/Service Component"]
        LEG2["Cylinder: Database"]
        LEG3["Arrow: Data flow/Dependency"]
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend – Next.js Pages & Components"]:::frontend
        FE_PAGES["Pages (e.g., /login, /register, /forgot-password, /reset-password, mis-propuestas, propuesta, temas)"]:::frontend
        FE_COMPONENTS["Components (Navbar, Footer, Session Provider, UI with Chakra UI, Shadcn)"]:::frontend
        FE --> FE_PAGES
        FE --> FE_COMPONENTS
    end

    %% API Layer
    subgraph "API Layer"
        API["API Endpoints – Next.js API"]:::api
        API_AUTH["Authentication Endpoints (NextAuth, forgot-password, register, reset-password)"]:::api
        API_PROPOSALS["Proposal Endpoints (create, edit, delete, retrieve)"]:::api
        API_USER["User Endpoints (get, put, delete)"]:::api
        API --> API_AUTH
        API --> API_PROPOSALS
        API --> API_USER
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["Prisma ORM – Database"]:::database
    end

    %% Static Assets
    subgraph "Static Assets"
        SA["Static Assets – Public Resources"]:::static
    end

    %% Utility & Service Components
    subgraph "Utility & Service Components"
        UTIL_UTILS["Utilities (Helper functions)"]:::utility
        UTIL_CONTEXT["Context Providers (e.g., UserContext)"]:::utility
        UTIL_HOOKS["Custom Hooks (e.g., publications hooks, use-toast)"]:::utility
        UTIL_TYPES["Type Definitions (e.g., next-auth, publications, user)"]:::utility
    end

    %% Relationships
    FE -->|"sends HTTP Requests"| API
    API -->|"performs CRUD"| DB
    FE -->|"loads resources"| SA
    FE -->|"uses"| UTIL_UTILS
    FE -->|"manages state via"| UTIL_CONTEXT
    FE -->|"leverages"| UTIL_HOOKS
    FE -->|"applies types from"| UTIL_TYPES
    API -->|"uses"| UTIL_UTILS
    API -->|"uses"| UTIL_CONTEXT
    API -->|"uses"| UTIL_HOOKS
    API -->|"uses"| UTIL_TYPES

    %% Click Events
    click FE "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/app"
    click FE_PAGES "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/app"
    click FE_COMPONENTS "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/components"
    click API "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/app/api"
    click DB "https://github.com/juaneduardo-dev/blogger-app-frontend/blob/main/prisma/schema.prisma"
    click DB "https://github.com/juaneduardo-dev/blogger-app-frontend/blob/main/src/lib/prisma.ts"
    click SA "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/public"
    click UTIL_UTILS "https://github.com/juaneduardo-dev/blogger-app-frontend/blob/main/src/lib/utils.ts"
    click UTIL_CONTEXT "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/app/context"
    click UTIL_HOOKS "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/hooks"
    click UTIL_TYPES "https://github.com/juaneduardo-dev/blogger-app-frontend/tree/main/src/types"

    %% Styles
    classDef frontend fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef api fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef database fill:#abebc6,stroke:#1e8449,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef static fill:#f5cba7,stroke:#d35400,stroke-width:2px;
    classDef utility fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
```
