# elopes-sv/front-end-challenge architecture

> Architecture diagram of the GitHub repository elopes-sv/front-end-challenge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elopes-sv/front-end-challenge
- Repository: https://github.com/elopes-sv/front-end-challenge

## Overview

1. **Overall shape**
   This is a **Next.js / React** front-end focused on consuming the Apiki WordPress REST API as a headless blog. The architecture is split into a small set of route-level pages, reusable UI components, and a `lib` layer that centralizes API/formatting/SEO concerns.

2. **Routing and page boundaries**
   The app uses the **Next.js App Router** under `src/app`:
   - `src/app/page.jsx` = home page
   - `src/app/post/[slug]/page.jsx` = dynamic post detail page
   - `src/app/not-found.jsx` = fallback 404 page
   - `src/app/layout.jsx` = shared application shell  
   This creates a clear boundary between route composition and reusable UI.

3. **Data source and external dependency**
   All content comes from the WordPress API at `https://blog.apiki.com/wp-json/wp/v2/`. The app is built around two REST patterns:
   - list posts for category `518` on the home page
   - fetch a single post by `slug` on the detail page  
   The home page also depends on response headers like `X-WP-Total` and `X-WP-TotalPages` to know whether more pages exist.

4. **API/data access layer**
   `src/lib/api.js` is the main boundary for fetching and interpreting API responses. This is where the app likely centralizes:
   - list fetching for the feed
   - single-post fetching by slug
   - handling pagination metadata from headers  
   Keeping this logic out of components makes the UI easier to reuse and the data flow easier to diagram.

5. **Content normalization and presentation helpers**
   `src/lib/formatPost.js` suggests a small transformation layer for turning raw WordPress JSON into something UI-friendly, likely extracting:
   - title
   - slug/link
   - featured image from `_embedded.wp:featuredmedia`
   - post excerpts/content or date-related formatting  
   `src/lib/seo.js` isolates page metadata concerns, which matters for a blog because SEO is part of the product requirements.

6. **Home page composition**
   The home page is organized as a feed of post cards with progressive loading:
   - `PostsFeed.jsx` likely owns the list rendering and feed state
   - `PostCard.jsx` renders each post item
   - `LoadMoreButton.jsx` triggers the next page request  
   This reflects the core user flow from the README: initial 10 posts, then additional pages loaded on demand.

7. **Post detail composition**
   The detail route is split into semantic sections:
   - `PostHero.jsx` for the featured image/title header area
   - `PostContent.jsx` for the body content  
   This is a good boundary because the page can combine layout/branding with content rendering while keeping the article presentation reusable and focused.

8. **Shared chrome and navigation**
   `Header.jsx` and `Footer.jsx` are shared layout components used across routes through `layout.jsx`. They form the persistent shell around the routed content and are part of the site-wide identity rather than page-specific behavior.

9. **Styling system**
   CSS is organized by scope rather than a single monolith:
   - `src/styles/globals.css` for base reset/global rules
   - `src/styles/home.css` and `src/styles/post.css` for route-specific styling
   - `src/styles/components/*` for component-level styles  
   This matches the challenge’s emphasis on CSS organization and keeps the visual system aligned with component boundaries.

10. **Static assets**
   `public/images` and `public/icons` hold non-code assets such as logos, decorative images, and UI icons. These are consumed by the header, cards, hero, or other presentation components without going through the API layer.

11. **Page flow on the home screen**
   The home route follows a simple but important sequence:
   API fetch for the first page of category `518` posts → normalize/format data → render cards → allow pagination with “Carregar mais...” based on total pages.  
   That makes the home page a data-driven list with incremental loading, not a static landing page.

12. **Page flow on the post screen**
   The post detail route follows a slug-based fetch:
   URL slug from the list → API request for the matching post → render hero + content.  
   This creates a direct coupling between the home page’s post links and the internal page route structure.

13. **Project constraints reflected in the architecture**
   The repository is intentionally compact: no backend, no database, and no custom state management library. The main complexity lives in **API integration, pagination, reusable UI composition, and SEO metadata**, which matches the challenge’s requirements.

14. **What to diagram**
   A clear architecture diagram for this repo should show:
   - browser/user interaction
   - Next.js route layer (`/`, `/post/[slug]`, 404)
   - shared layout
   - component layer for feed/card/detail
   - `lib` layer for API/formatting/SEO
   - external WordPress REST API
   - static assets from `public/`  
   The most important boundary is between **route components** and **data-fetching helpers**, with the WordPress API as the external system.

Main entry points: [`src/app/post/[slug]/page.jsx`](https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/post/[slug]/page.jsx) (Post page), [`src/styles/components`](https://github.com/elopes-sv/front-end-challenge/tree/master/src/styles/components) (Component CSS), [`src/app/page.jsx`](https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/page.jsx) (Home page), [`src/components/PostsFeed.jsx`](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostsFeed.jsx) (Posts feed)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App Router"]
  node_layout["App shell<br/>next layout<br/>[layout.jsx]"]
  node_home_page["Home page<br/>route<br/>[page.jsx]"]
  node_post_page["Post page<br/>route<br/>[page.jsx]"]
  node_not_found["404 page<br/>route<br/>[not-found.jsx]"]
end

subgraph group_group_components["Components"]
  node_header["Header<br/>ui chrome<br/>[Header.jsx]"]
  node_footer["Footer<br/>ui chrome<br/>[Footer.jsx]"]
  node_posts_feed["Posts feed<br/>list view<br/>[PostsFeed.jsx]"]
  node_post_card["Post card<br/>list item<br/>[PostCard.jsx]"]
  node_load_more["Load more<br/>action<br/>[LoadMoreButton.jsx]"]
  node_post_hero["Post hero<br/>article hero<br/>[PostHero.jsx]"]
  node_post_content["Post content<br/>article body<br/>[PostContent.jsx]"]
end

subgraph group_group_lib["Lib"]
  node_api["API client<br/>data access<br/>[api.js]"]
  node_format_post["Format post<br/>transform<br/>[formatPost.js]"]
  node_seo["SEO<br/>metadata<br/>[seo.js]"]
end

subgraph group_group_styles["Styles"]
  node_globals_css["Global CSS<br/>style sheet<br/>[globals.css]"]
  node_home_css["Home CSS<br/>style sheet<br/>[home.css]"]
  node_post_css["Post CSS<br/>style sheet<br/>[post.css]"]
  node_component_css["Component CSS<br/>style sheets"]
end

subgraph group_group_assets["Static assets"]
  node_assets[("Public assets<br/>static files")]
end

subgraph group_group_external["External"]
  node_wp_api{{"WordPress API<br/>external REST"}}
end

node_user(("User<br/>actor"))

node_user -->|"visits"| node_home_page
node_user -->|"opens"| node_post_page
node_layout -->|"includes"| node_header
node_layout -->|"includes"| node_footer
node_home_page -->|"renders"| node_posts_feed
node_posts_feed -->|"maps"| node_post_card
node_posts_feed -->|"uses"| node_load_more
node_posts_feed -->|"fetches"| node_api
node_posts_feed -->|"normalizes"| node_format_post
node_post_page -->|"renders"| node_post_hero
node_post_page -->|"renders"| node_post_content
node_post_page -->|"fetches"| node_api
node_post_page -->|"normalizes"| node_format_post
node_home_page -->|"metadata"| node_seo
node_post_page -->|"metadata"| node_seo
node_api -->|"requests"| node_wp_api
node_layout -->|"styles"| node_globals_css
node_home_page -->|"styles"| node_home_css
node_post_page -->|"styles"| node_post_css
node_header -->|"styles"| node_component_css
node_footer -->|"styles"| node_component_css
node_post_card -->|"styles"| node_component_css
node_post_hero -->|"styles"| node_component_css
node_post_content -->|"styles"| node_component_css
node_load_more -->|"styles"| node_component_css
node_home_page -->|"loads"| node_assets
node_post_page -->|"loads"| node_assets
node_header -->|"loads"| node_assets
node_post_hero -->|"loads"| node_assets

click node_layout "https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/layout.jsx"
click node_home_page "https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/page.jsx"
click node_post_page "https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/post/[slug]/page.jsx"
click node_not_found "https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/not-found.jsx"
click node_header "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/Header.jsx"
click node_footer "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/Footer.jsx"
click node_posts_feed "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostsFeed.jsx"
click node_post_card "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostCard.jsx"
click node_load_more "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/LoadMoreButton.jsx"
click node_post_hero "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostHero.jsx"
click node_post_content "https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostContent.jsx"
click node_api "https://github.com/elopes-sv/front-end-challenge/blob/master/src/lib/api.js"
click node_format_post "https://github.com/elopes-sv/front-end-challenge/blob/master/src/lib/formatPost.js"
click node_seo "https://github.com/elopes-sv/front-end-challenge/blob/master/src/lib/seo.js"
click node_globals_css "https://github.com/elopes-sv/front-end-challenge/blob/master/src/styles/globals.css"
click node_home_css "https://github.com/elopes-sv/front-end-challenge/blob/master/src/styles/home.css"
click node_post_css "https://github.com/elopes-sv/front-end-challenge/blob/master/src/styles/post.css"
click node_component_css "https://github.com/elopes-sv/front-end-challenge/tree/master/src/styles/components"
click node_assets "https://github.com/elopes-sv/front-end-challenge/tree/master/public"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_layout,node_home_page,node_post_page,node_not_found toneBlue
class node_header,node_footer,node_posts_feed,node_post_card,node_load_more,node_post_hero,node_post_content toneAmber
class node_api,node_format_post,node_seo toneMint
class node_globals_css,node_home_css,node_post_css,node_component_css toneRose
class node_assets toneIndigo
class node_wp_api toneTeal
class node_user toneNeutral
```

## Components

### App Router

Route-level pages and shared shell

- [App shell](https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/layout.jsx): next layout · Shared site frame for routed pages · `src/app/layout.jsx`
- [Home page](https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/page.jsx): route · Lists posts and supports incremental loading · `src/app/page.jsx`
- [Post page](https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/post/[slug]/page.jsx): route · Dynamic post detail route by slug · `src/app/post/[slug]/page.jsx`
- [404 page](https://github.com/elopes-sv/front-end-challenge/blob/master/src/app/not-found.jsx): route · Fallback page for missing routes · `src/app/not-found.jsx`

### Components

Reusable UI building blocks

- [Header](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/Header.jsx): ui chrome · Shared top navigation and branding · `src/components/Header.jsx`
- [Footer](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/Footer.jsx): ui chrome · Shared site footer · `src/components/Footer.jsx`
- [Posts feed](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostsFeed.jsx): list view · Fetches and renders the post list with pagination · `src/components/PostsFeed.jsx`
- [Post card](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostCard.jsx): list item · Renders a single post preview · `src/components/PostCard.jsx`
- [Load more](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/LoadMoreButton.jsx): action · Triggers fetching the next page of posts · `src/components/LoadMoreButton.jsx`
- [Post hero](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostHero.jsx): article hero · Featured image and title header for a post · `src/components/PostHero.jsx`
- [Post content](https://github.com/elopes-sv/front-end-challenge/blob/master/src/components/PostContent.jsx): article body · Renders the main post content · `src/components/PostContent.jsx`

### Lib

Data access, formatting, and metadata helpers

- [API client](https://github.com/elopes-sv/front-end-challenge/blob/master/src/lib/api.js): data access · WordPress REST requests and pagination metadata · `src/lib/api.js`
- [Format post](https://github.com/elopes-sv/front-end-challenge/blob/master/src/lib/formatPost.js): transform · Normalizes WordPress post data for the UI · `src/lib/formatPost.js`
- [SEO](https://github.com/elopes-sv/front-end-challenge/blob/master/src/lib/seo.js): metadata · Page metadata helpers · `src/lib/seo.js`

### Styles

Global, route, and component CSS

- [Global CSS](https://github.com/elopes-sv/front-end-challenge/blob/master/src/styles/globals.css): style sheet · Base and shared site styles · `src/styles/globals.css`
- [Home CSS](https://github.com/elopes-sv/front-end-challenge/blob/master/src/styles/home.css): style sheet · Styles for the home route · `src/styles/home.css`
- [Post CSS](https://github.com/elopes-sv/front-end-challenge/blob/master/src/styles/post.css): style sheet · Styles for the post route · `src/styles/post.css`
- [Component CSS](https://github.com/elopes-sv/front-end-challenge/tree/master/src/styles/components): style sheets · Scoped styles for shared components · `src/styles/components`

### Static assets

Public images and icons

- [Public assets](https://github.com/elopes-sv/front-end-challenge/tree/master/public): static files · Icons and images used by the UI · `public`

### External

Remote API dependency

- **WordPress API**: external REST · Headless content source at blog.apiki.com

### Other components

- **User**: actor · Browser visitor using the blog

## Connections

- User → Home page: visits · Opens the blog homepage
- User → Post page: opens · Navigates to a post detail page
- App shell → Header: includes · Shared shell renders the header
- App shell → Footer: includes · Shared shell renders the footer
- Home page → Posts feed: renders · Home page delegates list behavior to the feed
- Posts feed → Post card: maps · Renders each post preview as a card
- Posts feed → Load more: uses · Adds pagination control for additional pages
- Posts feed → API client: fetches · Loads paginated posts from the API
- Posts feed → Format post: normalizes · Transforms raw post data for display
- Post page → Post hero: renders · Builds the article header section
- Post page → Post content: renders · Builds the article body section
- Post page → API client: fetches · Loads a single post by slug
- Post page → Format post: normalizes · Prepares post data for presentation
- Home page → SEO: metadata · Defines home page metadata
- Post page → SEO: metadata · Defines post page metadata
- API client → WordPress API: requests · Reads posts and pagination data from WordPress
- App shell → Global CSS: styles · Imports shared global styling
- Home page → Home CSS: styles · Uses home route styles
- Post page → Post CSS: styles · Uses post route styles
- Header → Component CSS: styles · Uses component-scoped CSS
- Footer → Component CSS: styles · Uses component-scoped CSS
- Post card → Component CSS: styles · Uses component-scoped CSS
- Post hero → Component CSS: styles · Uses component-scoped CSS
- Post content → Component CSS: styles · Uses component-scoped CSS
- Load more → Component CSS: styles · Uses component-scoped CSS
- Home page → Public assets: loads · Consumes public images and icons
- Post page → Public assets: loads · Consumes public images and icons
- Header → Public assets: loads · Uses logos or icons from public assets
- Post hero → Public assets: loads · Uses featured imagery or decorative assets
