# dante-ferr/circuito-do-saber architecture

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

- Interactive diagram: https://gitdiagram.com/dante-ferr/circuito-do-saber
- Repository: https://github.com/dante-ferr/circuito-do-saber

## Overview

##### Project Type and Purpose
- This is a full-stack, content-driven web application bootstrapped with Next.js (via create-next-app).
- It has clearly defined public pages (blog, quiz, calculators, simulators, “sobre”), an admin interface, and integration with Sanity (a headless CMS) for content management.
- The README emphasizes Next.js features and deployment tips, while the file structure indicates that the project combines server-side rendering with static generation, dynamic routing, and CMS integration.

##### File Structure
- Top-level directories/files (like .eslintrc.json, next.config.mjs, package.json, tsconfig.json) denote project configuration.
- The src/app directory contains:
- Separate “(publicPages)” subfolders organizing public site sections (blog, calculadoras, quiz, simuladores, sobre). This strongly suggests a routing and layout pattern typical of Next.js.
- An “admin” directory that uses a catch-all route ([[...tool]]), which suggests a dynamic admin panel.
- A shared “components” folder with UI elements (cards, layout – header and footer – and SVGs) to compose the interface.
- Global styling files and SCSS modules indicate a component-based styling strategy.
- The src/sanity and related files hold client configuration, schema types, and helper libraries. These components are essential for defining the content models for blog posts, authors, simulators, etc.
- The dist/ and public/ folders contain built assets and static resources. The existence of runtime files in the .sanity folder suggests that Sanity Studio (or runtime) might be embedded or used for content previewing.

##### Considered System Components
- Client Browser: Represent the end-user interface where pages load and interact.
- Next.js Frontend:
- Pages & Routing: Include groups for “publicPages” (blog, calculators, quiz, simulators, about) and admin routes.
- Layout & Components: Show how pages use shared components like Header, Footer, Cards, and SVG assets.
- API Layer/Actions: Illustrate action files (e.g., authorActions, postActions, simulatorActions) which likely encapsulate data fetching and state management.
- Sanity CMS Integration:
- Relationship with Frontend: Emphasize how Next.js pages and actions utilize the Sanity client to fetch content, enabling features like dynamic blog posts and simulators.
- Build/Deployment Pipeline:
- Production “dist” folder that collects optimized bundles and assets.
- Optionally, include configuration elements (e.g., next.config.mjs, package.json scripts) that drive the build and deployment process, especially to Vercel.
- External Dependencies/Services:
- Although not a separate microservice, note that external services like Vercel or other hosting platforms for deployment are part of the operational ecosystem.

##### Guiding Principles
- Use clear, self-explanatory labels for each component:
- “Client Browser”
- “Next.js Frontend” broken into Public Pages, Admin Section, Layout Components, and API/Actions.
- “Sanity CMS” with its Client, Schemas, and Configuration.
- From the Client Browser to the Frontend (via HTTP requests).
- From the Frontend to the Sanity client for content fetching.
- Data flow back from Sanity to specific Next.js pages.
- Patterns and design principles:
- Component-based architecture (React/Next.js) with separation of layout and UI (in src/app/components).
- Modular structure for routes (clear separation between public and admin areas).
- Integration of a headless CMS (Sanity) to manage dynamic content.
- Use of CSS Modules and SCSS for styling components, showing maintainability and scoped styles.

##### Specific Elements
- Clear labels for every architectural component (e.g., “Next.js Public Pages”, “Sanity CMS Client”, “Admin Interface”).
- User interaction (HTTP/Web requests) going to Next.js routes.
- Data fetching interactions between Next.js and Sanity (for content such as blog posts, calculator data, etc.).
- The build process from source files to the distribution output.
- Annotations for indicating key integrations (like use of Next.js routing, dynamic catch-all routes for admin, and asset pipelines with Vercel deployments).

- The Next.js frontend (including distinct routing groups for public pages and admin),
- The integration with Sanity CMS (content models, client configuration), and
- The build/deployment process (asset bundling in the “dist” folder and Next.js configurations).

This approach will not only communicate clear boundaries and interactions but will also be easily extensible should the project grow further in complexity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client Browser"]:::browser

    subgraph "Next.js Frontend"
        direction TB
        PublicPages["Public Pages"]:::frontend
        subgraph "Admin Interface"
            direction TB
            AdminRoute["Dynamic Route: [[...tool]]"]:::admin
            AdminLayout["Admin Layout (layout.tsx)"]:::admin
        end
        Components["Layout & Shared UI Components"]:::components
        API["API/Action Handlers"]:::api
    end

    subgraph "Sanity CMS Integration"
        direction TB
        SanityClient["Sanity Client & Config"]:::cms
        SanitySchema["Sanity Schema Types"]:::cms
    end

    subgraph "Build / Deployment Artifacts"
        direction TB
        Build["Production Build (dist)"]:::build
        NextConfig["Next Config (next.config.mjs)"]:::build
    end

    Client -->|"UserRequest"| PublicPages
    Client -->|"AdminRequest"| AdminRoute
    PublicPages -->|"FetchData"| API
    AdminRoute -->|"FetchData"| API
    API -->|"QueryContent"| SanityClient
    SanityClient -->|"ReturnContent"| API
    API -->|"ProvideContent"| PublicPages
    PublicPages -->|"RenderUI"| Components
    AdminLayout -->|"UsesLayout"| Components
    PublicPages -->|"BuildAssets"| Build
    API -->|"BuildAssets"| Build
    Build -->|"ConfigApplied"| NextConfig
    SanityClient -->|"DefinesSchema"| SanitySchema

    click PublicPages "https://github.com/dante-ferr/circuito-do-saber/tree/main/src/app/(publicPages)"
    click AdminRoute "https://github.com/dante-ferr/circuito-do-saber/blob/main/src/app/admin/[[...tool]]"
    click AdminLayout "https://github.com/dante-ferr/circuito-do-saber/blob/main/src/app/admin/layout.tsx"
    click Components "https://github.com/dante-ferr/circuito-do-saber/tree/main/src/app/components"
    click API "https://github.com/dante-ferr/circuito-do-saber/tree/main/src/app/actions"
    click SanityClient "https://github.com/dante-ferr/circuito-do-saber/tree/main/src/sanity"
    click SanitySchema "https://github.com/dante-ferr/circuito-do-saber/tree/main/src/sanity/schemaTypes"
    click Build "https://github.com/dante-ferr/circuito-do-saber/tree/main/dist/"
    click NextConfig "https://github.com/dante-ferr/circuito-do-saber/blob/main/next.config.mjs"

    classDef browser fill:#ffe6cc,stroke:#cc6600,stroke-width:2px;
    classDef frontend fill:#ccffcc,stroke:#00cc00,stroke-width:2px;
    classDef admin fill:#cce6ff,stroke:#007acc,stroke-width:2px;
    classDef components fill:#ffefdb,stroke:#ff9900,stroke-width:2px;
    classDef api fill:#e0ffff,stroke:#008b8b,stroke-width:2px;
    classDef cms fill:#fff2cc,stroke:#e6b800,stroke-width:2px;
    classDef build fill:#e6ccff,stroke:#8000ff,stroke-width:2px;
```
