A Modern Full-Stack Social Media Application
Built with React 19, Vite, and Tailwind CSS
- Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- Project Structure
- Key Concepts
- Performance Optimizations
- Contributing
Social Connect is a feature-rich social media platform that enables users to share posts, interact with content, connect with others, and build a community. This project demonstrates modern React development practices, including custom hooks, component composition, and efficient state management.
- Clean Architecture: Modular component design with separation of concerns
- Custom Hooks: Reusable logic extracted into custom hooks for better code organization
- Responsive Design: Mobile-first approach with Tailwind CSS
- Real-time Updates: Optimistic UI updates for smooth user experience
- Performance Focused: Code splitting and lazy loading for optimal bundle sizes
- User registration with email verification
- Secure login with JWT authentication
- Protected routes and role-based access
- Password strength validation
- Persistent sessions with auto-refresh
- Create posts with text and images
- Edit and delete your own posts
- Rich text formatting support
- Image preview before upload
- Draft posts (auto-save)
- Like, comment, and share posts
- Nested comment replies
- Real-time comment updates
- Bookmark favorite posts
- Share posts with custom captions
- Customizable profile with photo and cover image
- Bio and personal information
- View posts, bookmarks, and activity
- Follow/unfollow users
- Followers and following lists
- User statistics (posts, followers, following)
- Real-time notifications for:
- New likes on your posts
- Comments and replies
- New followers
- Shared posts
- Mark as read/unread functionality
- Filter by read status
- Notification badges
- Discover new users
- Follow suggestions
- User search functionality
- Trending posts
- Community feed
- Modern, clean design
- Smooth animations and transitions
- Loading skeletons for better perceived performance
- Toast notifications for user feedback
- Responsive layout for all screen sizes
- Dark mode support (coming soon)
- React 19.2.0 - Latest React with concurrent features
- React Router 7.11.0 - Client-side routing with data loading
- Vite 7.2.4 - Lightning-fast build tool and dev server
- Tailwind CSS 4.1.18 - Utility-first CSS framework
- Axios 1.13.2 - Promise-based HTTP client
- Formik 2.4.9 - Form state management
- Yup 1.7.1 - Schema validation
- FontAwesome 7.1.0 - Icon library
- React Toastify 11.0.5 - Toast notifications
- Cairo Font - Modern Arabic/Latin typography
- ESLint - Code linting and formatting
- Vite Plugin React - Fast Refresh and JSX support
The application follows a modular architecture with clear separation:
src/
├── api/ # API client and endpoint definitions
│ ├── axiosInstance.js # Configured axios instance
│ ├── postsApi.js # Posts endpoints
│ ├── usersApi.js # Users endpoints
│ ├── commentsApi.js # Comments endpoints
│ └── notificationsApi.js # Notifications endpoints
│
├── components/ # Reusable UI components
│ ├── Auth/ # Authentication components
│ ├── posts/ # Post-related components
│ ├── profile/ # Profile page components
│ ├── userProfile/ # User profile components
│ ├── notifications/ # Notification components
│ ├── Ui/ # Generic UI components
│ └── shared/ # Shared utilities
│
├── context/ # React Context providers
│ ├── AuthContext.jsx # Authentication state
│ └── PostProvider.jsx # Post management state
│
├── hooks/ # Custom React hooks
│ ├── useProfileData.js # Profile data fetching
│ ├── useNotifications.js # Notifications logic
│ ├── useFollowToggle.js # Follow/unfollow logic
│ ├── usePostComments.js # Comments management
│ └── useUserProfileData.js
│
├── pages/ # Route pages
│ ├── Home/
│ ├── Profile/
│ ├── UserProfile/
│ ├── Notifications/
│ ├── Post/
│ ├── Community/
│ ├── Bookmarks/
│ ├── LogIn/
│ └── SignUp/
│
├── utils/ # Utility functions
│ ├── formatters.js # Date/time formatting
│ └── notificationHelpers.js
│
├── config/ # Configuration files
│ └── api.js # API base URL config
│
├── App.jsx # Main app component
└── main.jsx # Application entry point
- Custom Hooks Pattern: Business logic extracted into reusable hooks
- Component Composition: Complex UIs built from smaller, focused components
- Container/Presentational: Separation of logic and UI concerns
- Context for Global State: Minimal prop drilling with Context API
- Controlled Components: Form inputs managed by React state
- Node.js 18+ and npm/yarn
- A backend API server (not included in this repo)
- Clone the repository
git clone https://github.com/yourusername/social-app.git
cd social-app- Install dependencies
npm install- Configure environment
# Create a config file at src/config/api.js
export const API_BASE_URL = 'http://your-api-url.com/api';- Start development server
npm run dev- Open your browser
http://localhost:5173
npm run buildThe production-ready files will be in the dist/ directory.
npm run previewAll API calls are centralized here using axios. Each module (posts, users, comments) has its own API file.
Organized by feature or shared usage:
- Feature-specific:
profile/,notifications/,posts/ - Shared/Reusable:
Ui/,shared/
Reusable stateful logic:
useProfileData- Fetch and manage profile datauseNotifications- Handle notification state and actionsuseFollowToggle- Follow/unfollow functionalityusePostComments- Comments CRUD operations
- AuthContext: User authentication state
- PostProvider: Post-related global state
Each top-level route has its own directory with the main page component.
Helper functions for formatting, validation, and common operations.
Instead of duplicating logic, we extract it into custom hooks:
// Example: useProfileData hook
const {
profileData,
loading,
refetch
} = useProfileData();Large components are broken down into smaller, focused sub-components:
<Profile>
<CoverSection />
<ProfileCard />
<AboutSection />
<QuickStatsCards />
<FollowersPreview />
<ProfileTabs />
<PostsGrid />
</Profile>For better UX, UI updates happen immediately before API confirmation:
// Update UI first
setLiked(!liked);
setLikesCount(liked ? likesCount - 1 : likesCount + 1);
// Then sync with server
await likePost(postId);Authentication-based route protection:
<Route element={<ProtectedRoute />}>
<Route path="/profile" element={<Profile />} />
<Route path="/notifications" element={<Notifications />} />
</Route>Pages are lazy-loaded for smaller initial bundle:
const Profile = lazy(() => import('./pages/Profile/Profile'));- Vendor Chunks: Third-party libraries separated
- Tree Shaking: Unused code eliminated
- Minification: Code compressed for production
- Bundle Analysis: Regular monitoring of bundle sizes
- Main Bundle: 59.03 kB
- Profile Page: 6.37 kB
- Notifications: 3.11 kB
- User Profile: 3.34 kB
- Lazy loading for images
- Default avatars for missing images
- Responsive image sizing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Use functional components with hooks
- Follow ESLint rules
- Write descriptive commit messages
- Keep components small and focused
- Document complex logic with comments
This project is licensed under the MIT License - see the LICENSE file for details.
- React team for the amazing framework
- Tailwind CSS for the utility-first approach
- FontAwesome for beautiful icons
- The open-source community
For questions or feedback, reach out at: khaled.devcontact@example.com
Made with ❤️ and React
⭐ Star this repo if you find it helpful!