# strapi/foodadvisor architecture

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

- Interactive diagram: https://gitdiagram.com/strapi/foodadvisor
- Repository: https://github.com/strapi/foodadvisor

## Overview

##### Main Components

A. Frontend Layer (Next.js):
- Client-side application (/client)
- Pages structure (Dynamic routes, Blog, Restaurants)
- Components hierarchy (Blocks, Global, Shared)
- Static assets and public files

B. Backend Layer (Strapi):
- API endpoints
- Content Types (Article, Restaurant, Review, etc.)
- Admin panel
- Authentication system
- Media Library
- Database connection

**[Client Layer]**

- Next.js Frontend
- Pages Router
- Components
- API Routes (Preview/Exit Preview)

- ↕ REST/GraphQL API Calls

**[Backend Layer]**

- Strapi API
- Content Types
- Controllers
- Services
- Routes

- Strapi Admin Panel
- User Management
- Content Management
- Media Library

- Database

##### Key Relationships to Highlight

a. Content Flow:
- How content types (Articles, Restaurants, Reviews) flow from Strapi to Next.js
- Preview functionality between frontend and backend
- Demonstrate media asset handling

b. Authentication Flow:
- User roles (Super Admin, Editor, Author)
- Authentication boundaries
- Permission checks

##### Component Details

Frontend:
- Page structure (/pages)
- Reusable components
- Routing system

Backend:
- Content type structure
- API endpoints
- Admin customizations

##### Additional Elements

- Notes for important configurations
- Environment variable dependencies
- Scaling points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Frontend Layer"]
        direction TB
        NextApp["Next.js Application"]:::frontend
        click NextApp "https://github.com/strapi/foodadvisor/tree/master/client/"
        
        subgraph Pages["Pages Structure"]
            MainPages["Main Pages"]:::frontend
            click MainPages "https://github.com/strapi/foodadvisor/tree/master/client/pages/"
            BlogRoutes["Blog Routes"]:::frontend
            click BlogRoutes "https://github.com/strapi/foodadvisor/tree/master/client/pages/blog/"
            RestaurantRoutes["Restaurant Routes"]:::frontend
            click RestaurantRoutes "https://github.com/strapi/foodadvisor/tree/master/client/pages/restaurants/"
            PreviewAPI["Preview API Routes"]:::frontend
            click PreviewAPI "https://github.com/strapi/foodadvisor/tree/master/client/pages/api/"
        end

        subgraph Components["Components"]
            GlobalComps["Global Components"]:::frontend
            click GlobalComps "https://github.com/strapi/foodadvisor/tree/master/client/components/global/"
            SharedComps["Shared Components"]:::frontend
            click SharedComps "https://github.com/strapi/foodadvisor/tree/master/client/components/shared/"
            BlockComps["Block Components"]:::frontend
            click BlockComps "https://github.com/strapi/foodadvisor/tree/master/client/components/blocks/"
            PageComps["Page Components"]:::frontend
            click PageComps "https://github.com/strapi/foodadvisor/tree/master/client/components/pages/"
            SEOComp["SEO Component"]:::frontend
            click SEOComp "https://github.com/strapi/foodadvisor/blob/master/client/components/seo.js"
            LangSwitch["Language Switch"]:::frontend
            click LangSwitch "https://github.com/strapi/foodadvisor/blob/master/client/components/global/Navbar/localSwitch.js"
        end

        LocalizeUtils["Localization Utils"]:::frontend
        click LocalizeUtils "https://github.com/strapi/foodadvisor/blob/master/client/utils/localize.js"
    end

    subgraph Backend["Backend Layer"]
        direction TB
        StrapiAPI["Strapi API"]:::api
        click StrapiAPI "https://github.com/strapi/foodadvisor/tree/master/api/src/api/"

        subgraph ContentTypes["Content Types"]
            Articles["Articles API"]:::api
            click Articles "https://github.com/strapi/foodadvisor/tree/master/api/src/api/article/"
            Restaurants["Restaurants API"]:::api
            click Restaurants "https://github.com/strapi/foodadvisor/tree/master/api/src/api/restaurant/"
            Reviews["Reviews API"]:::api
            click Reviews "https://github.com/strapi/foodadvisor/tree/master/api/src/api/review/"
            Categories["Categories API"]:::api
            click Categories "https://github.com/strapi/foodadvisor/tree/master/api/src/api/category/"
        end

        subgraph AdminPanel["Admin Panel"]
            AdminConfig["Admin Configuration"]:::admin
            click AdminConfig "https://github.com/strapi/foodadvisor/blob/master/api/config/admin.js"
            AdminExt["Admin Extensions"]:::admin
            click AdminExt "https://github.com/strapi/foodadvisor/tree/master/api/src/admin/extensions/"
            PreviewBtn["Preview Button"]:::admin
            click PreviewBtn "https://github.com/strapi/foodadvisor/tree/master/api/src/admin/extensions/components/PreviewButton/"
        end

        subgraph Config["Backend Configuration"]
            DBConfig["Database Config"]:::config
            click DBConfig "https://github.com/strapi/foodadvisor/blob/master/api/config/database.js"
            ServerConfig["Server Config"]:::config
            click ServerConfig "https://github.com/strapi/foodadvisor/blob/master/api/config/server.js"
            APIConfig["API Config"]:::config
            click APIConfig "https://github.com/strapi/foodadvisor/blob/master/api/config/api.js"
            MiddlewareConfig["Middleware Config"]:::config
            click MiddlewareConfig "https://github.com/strapi/foodadvisor/blob/master/api/config/middlewares.js"
        end

        Auth["Authentication System"]:::security
        click Auth "https://github.com/strapi/foodadvisor/tree/master/api/src/extensions/users-permissions/"
        
        BlockDefs["Block Definitions"]:::api
        click BlockDefs "https://github.com/strapi/foodadvisor/tree/master/api/src/components/blocks/"
        
        SEOJSON["SEO Schema"]:::api
        click SEOJSON "https://github.com/strapi/foodadvisor/blob/master/api/src/components/shared/seo.json"
    end

    Database[(Database)]:::database

    %% Relationships
    NextApp --> Pages
    NextApp --> Components
    NextApp --> LocalizeUtils
    StrapiAPI --> ContentTypes
    StrapiAPI --> AdminPanel
    StrapiAPI --> Auth
    StrapiAPI --> BlockDefs
    StrapiAPI --> Database
    NextApp <-.-> StrapiAPI

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef admin fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        APIComp["API Component"]:::api
        AdminComp["Admin Component"]:::admin
        DBComp["Database"]:::database
        ConfigComp["Configuration"]:::config
        SecurityComp["Security Component"]:::security
    end
```
