How elopes-sv/front-end-challenge works
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: [slug]/page.jsx Post page · components Component CSS · app/page.jsx Home page · PostsFeed.jsx Posts feed
Components 21
App Router
Route-level pages and shared shell
Components
Reusable UI building blocks
- Header · Shared top navigation and branding
src/components/Header.jsx - Footer · Shared site footer
src/components/Footer.jsx - Posts feed · Fetches and renders the post list with pagination
src/components/PostsFeed.jsx - Post card · Renders a single post preview
src/components/PostCard.jsx - Load more · Triggers fetching the next page of posts
src/components/LoadMoreButton.jsx - Post hero · Featured image and title header for a post
src/components/PostHero.jsx - Post content · Renders the main post content
src/components/PostContent.jsx
Lib
Data access, formatting, and metadata helpers
- API client · WordPress REST requests and pagination metadata
src/lib/api.js - Format post · Normalizes WordPress post data for the UI
src/lib/formatPost.js - SEO · Page metadata helpers
src/lib/seo.js
Styles
Global, route, and component CSS
- Global CSS · Base and shared site styles
src/styles/globals.css - Home CSS · Styles for the home route
src/styles/home.css - Post CSS · Styles for the post route
src/styles/post.css - Component CSS · Scoped styles for shared components
src/styles/components
External
Remote API dependency
- WordPress API · Headless content source at blog.apiki.com
Other components
- User · Browser visitor using the blog
Connections 29
- 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