A React web application built with Vite that demonstrates a simple social media platform with posts, comments, and likes functionality.
-
Post Management
- View all posts in a feed
- Create new posts
- View post details
- Like posts
- Delete posts
-
Comments
- View comments on posts
- Create comments on posts
- Delete comments
- Update comments
-
User Management
- Set and change username
- All posts and comments are attributed to the current username
-
API Status Monitoring
- Visual indicator when backend API is unavailable
- Automatic health check every 5 seconds
- Graceful fallback UI when offline
src/
├── components/
│ ├── APIStatusIndicator.jsx # Shows API availability status
│ ├── CommentList.jsx # Displays comments for a post
│ ├── CreateCommentModal.jsx # Modal to add new comment
│ ├── CreatePostModal.jsx # Modal to create new post
│ ├── PostDetail.jsx # Detailed view of a single post
│ ├── PostList.jsx # Feed of all posts
│ └── UsernameModal.jsx # Modal for username input
├── context/
│ └── UsernameContext.jsx # React context for managing current username
├── services/
│ └── api.js # API client service
├── App.jsx # Main application component
├── App.css # Component styles (Tailwind)
├── index.css # Global styles with Tailwind
└── main.jsx # Application entry point
- Node.js 16+
- npm or yarn
- Backend API running at
http://localhost:8000
cd SimpleSocialMediaApplication
npm installStart the development server:
npm run devThe application will be available at http://localhost:3000
Create a production build:
npm run buildPreview the production build:
npm run previewThe application connects to a backend API at http://localhost:8000/api with the following endpoints:
GET /posts- List all postsPOST /posts- Create a new postGET /posts/{postId}- Get a specific postPATCH /posts/{postId}- Update a postDELETE /posts/{postId}- Delete a post
GET /posts/{postId}/comments- List comments for a postPOST /posts/{postId}/comments- Create a commentGET /posts/{postId}/comments/{commentId}- Get a specific commentPATCH /posts/{postId}/comments/{commentId}- Update a commentDELETE /posts/{postId}/comments/{commentId}- Delete a comment
POST /posts/{postId}/likes- Like a postDELETE /posts/{postId}/likes- Unlike a post
This project uses Tailwind CSS for styling. All component styles are defined using Tailwind utility classes.
tailwind.config.js- Tailwind CSS configurationpostcss.config.js- PostCSS configuration with Tailwind and autoprefixer
- React 19 - UI framework
- Vite - Frontend build tool
- Tailwind CSS - Utility-first CSS framework
- JavaScript (ES6+) - Programming language
- Initial Setup: Enter a username when the app loads
- Browse Posts: View all posts in the main feed
- View Details: Click on a post to see full details and comments
- Create Post: Click "Create Post" button to open the post creation modal
- Comment: Add comments to posts from the post detail view
- Change Username: Click "Change Username" to update your username
- Network errors are displayed with retry options
- API unavailability is clearly indicated with a prominent notification
- Form validation prevents invalid submissions
- Confirmation dialogs appear before deleting content
MIT
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the TS template for information on how to integrate TypeScript and typescript-eslint in your project.