posts-app Tailwind Templates

Posts App

A modern Next.js application that fetches and displays posts from JSONPlaceholder API with a responsive card layout. Built with TypeScript, Tailwind CSS, and TanStack Query for efficient data caching. Features a clean architecture following SOLID principles and custom hooks for data management.

Posts App

A Next.js application that fetches and displays posts from the JSONPlaceholder API in a card-based interface, following SOLID principles.

šŸš€ Technologies

✨ Features

  • Responsive card layout displaying posts from JSONPlaceholder API
  • Custom hooks for data fetching with TanStack Query
  • Clean architecture following SOLID principles
  • Efficient data caching to minimize API calls
  • Type-safe development with TypeScript

šŸ“¦ Installation

  1. Clone the repository:
git clone https://github.com/thiagosrib/posts-app.git
cd posts-app
  1. Install dependencies:
npm install
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser to see the application.

šŸ”§ Project Structure

src/
ā”œā”€ā”€ app/               # Next.js app router
│   ā”œā”€ā”€ page.tsx       # Home page
│   ā”œā”€ā”€ layout.tsx     # Root layout
│   └── globals.css    # Global styles
ā”œā”€ā”€ components/        # UI components
│   ā”œā”€ā”€ ui/            # Reusable UI components
│   └── posts/         # Domain-specific components
ā”œā”€ā”€ hooks/             # Custom React hooks
│   ā”œā”€ā”€ provider.ts    # Custom Client Provider
│   └── use-posts.ts   # Posts data handling hook
ā”œā”€ā”€ services/          # API services
│   ā”œā”€ā”€ api/           # API configuration
│   └── posts/         # Posts-specific service
└── types/             # TypeScript types

🧩 Architecture

This project follows the SOLID principles:

  • S - Single Responsibility: Each component, hook, and service has a single responsibility
  • O - Open/Closed: Components are open for extension but closed for modification
  • L - Liskov Substitution: Interfaces can be substituted without affecting the application
  • I - Interface Segregation: Specific interfaces are better than general ones
  • D - Dependency Inversion: High-level modules depend on abstractions

šŸ”„ API Integration

The application fetches data from the JSONPlaceholder API, a fake online REST API for testing and prototyping.

šŸ“ Development Notes

  • The usePosts hook handles data fetching, caching, and transformation
  • TanStack Query manages the cache with a 5-minute stale time
  • Cards display a title and truncated description for each post
  • The application is fully responsive for all device sizes

Top categories

Loading Svelte Themes