A responsive and accessible social media application built with Next.js 16, connecting to a NestJS backend.
- Login with email and password
- OAuth 2.0 login (Github, Google, and Facebook)
- JWT token authentication with NextAuth.js
- Middleware for route protection
- Update personal information, profile picture, and cover photo
- Profile page with tabs: Posts, Media, About
- Display lists of followers and following
- Search for users with filters
- Create, edit, and delete posts, comments, and replies
- Like/unlike posts, comments, and replies
- Add images and videos to posts
- Drag & drop to sort media when creating/editing a post
- Support for hashtags in posts
- @mention users in posts, comments, and replies
- Personalized feed with infinite scrolling
- Real-time feed with auto-refresh
- Trending page with popular hashtags
- Search and discover new content
- Bookmarks to save favorite posts
- Activity history
- Real-time notification system
- Activity logging
- Notifications for new interactions
- Fully responsive design (mobile-first)
- Dark/Light theme with theme switcher
- Accessible components with React Aria
- Full-page gallery for viewing photos/videos
- Smooth animations with Framer Motion
- Modern UI with shadcn/ui components
- Join and manage groups
- "My Groups" page to view joined groups
- Admin panel for moderation
- Next.js 16 - React framework with App Router, Turbopack default bundler
- React 19 - UI library with Server & Client Components and React Compiler support
- TypeScript - Type safety
- Tailwind CSS - Utility-first CSS framework
- TanStack Query - Server state management
- Axios - HTTP client
- Zustand - Client state management
- shadcn/ui - Re-usable component library
- Radix UI - Unstyled, accessible components
- React Aria - Accessibility hooks
- Lucide React - Icon library
- Framer Motion - Animation library
- React Hook Form - Form management
- Zod - Schema validation
- @hookform/resolvers - Form validation resolvers
- NextAuth.js - Authentication solution
- Jose - JWT operations
- bcryptjs - Password hashing
- DND Kit - Drag and drop functionality
- Swiper - Touch slider
- DOMPurify - HTML sanitization
- html-react-parser - HTML parsing
- ESLint - Code linting
- Prettier - Code formatting
- TypeScript ESLint - TypeScript linting
comunia/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (auth)/ # Auth layout group
β β βββ (protected)/ # Protected routes
β β β βββ feed/ # Main feed page
β β β βββ [username]/ # User profile pages
β β β βββ groups/ # Groups functionality
β β β βββ notifications/ # Notifications page
β β β βββ ...
β β βββ (unprotected)/ # Public routes
β β βββ admin/ # Admin panel
β β βββ layout.tsx # Root layout
β βββ components/ # Reusable UI components
β β βββ ui/ # Base UI components (shadcn/ui)
β β βββ feed/ # Feed-related components
β β βββ ...
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utility functions
β βββ types/ # TypeScript type definitions
β βββ contexts/ # React contexts
β βββ constants/ # App constants
βββ public/ # Static assets
βββ docs/ # Documentation
- Node.js 18+
- npm or yarn
- Backend API running on port 3001
- Clone repository:
git clone https://github.com/lugondev/comunia.git
cd comunia- Install dependencies:
pnpm install- Environment Setup:
Create a
.env.localfile in the root directory:
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3002
NEXTAUTH_SECRET=your-secret-key
# OAuth Providers
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
FACEBOOK_CLIENT_ID=your-facebook-client-id
FACEBOOK_CLIENT_SECRET=your-facebook-client-secret
# Backend API
NEXT_PUBLIC_API_URL=http://localhost:3001
API_URL=http://localhost:3001
# Database (if needed)
DATABASE_URL=postgresql://username:password@localhost:5432/comunia- Run development server:
pnpm run devThe frontend will run on http://localhost:3002
pnpm run build
pnpm run start- If you see a warning like "Ignored build scripts ... Run pnpm approve-builds":
Then re-run the install/build command.
pnpm approve-builds
The project uses Next.js 16 with the App Router, leveraging:
- Server Components - Render server-side for performance
- Client Components - Interactive UI components
- Route Groups - Organize routes by layout
- Nested Layouts - Shared layouts for route groups
- Middleware - Authentication & route protection
- Turbopack - Default dev bundler in Next 16 for faster HMR and rebuilds
- React Compiler - Leverages React 19 compiler improvements
- TanStack Query - Server state, caching, and synchronization
- React Context - Authentication state and theme
- Local State - Component-level state with useState/useReducer
// Example: Custom hook with TanStack Query
export function useFeed(feedType: FeedType) {
return useInfiniteQuery({
queryKey: ['feed', feedType],
queryFn: ({ pageParam = 1 }) => fetchFeed(feedType, pageParam),
getNextPageParam: (lastPage) => lastPage.nextPage,
staleTime: 5 * 60 * 1000, // 5 minutes
})
}// Composition pattern with compound components
<FeedContainer>
<FeedTabs />
<PostList>
<PostCard>
<PostHeader />
<PostContent />
<PostActions />
</PostCard>
</PostList>
</FeedContainer>- Color System: Semantic colors with CSS variables
- Typography: Poppins font family with responsive sizing
- Spacing: Consistent spacing scale with Tailwind
- Breakpoints: Mobile-first responsive design
Using shadcn/ui as a base, extended with:
- Custom animations with Framer Motion
- Accessible components with React Aria
- Form components with React Hook Form integration
- Login Page - Email/password or OAuth providers
- Middleware Check - Verify JWT token
- Protected Routes - Redirect if not authenticated
- Token Refresh - Auto-refresh expired tokens
- Logout - Clear tokens and redirect
- Mobile: < 768px - Single column layout
- Tablet: 768px - 1024px - Adapted layouts
- Desktop: > 1024px - Multi-column with sidebar
- Touch-friendly interactions
- Swipe gestures for media gallery
- Bottom navigation on mobile
- Optimized infinite scroll
- Route-based code splitting with Next.js
- Dynamic imports for heavy components
- Lazy loading for images and videos
- TanStack Query cache with stale-while-revalidate
- Next.js static generation for public pages
- Browser caching for static assets
// next.config.js
module.exports = {
experimental: {
optimizePackageImports: ['lucide-react', '@radix-ui/react-*'],
},
images: {
domains: ['localhost', 'your-cdn-domain.com'],
},
}- Unit Tests: Jest + React Testing Library
- Integration Tests: Playwright
- E2E Tests: Cypress (planned)
npm run test # Unit tests
npm run test:watch # Watch mode
npm run test:e2e # E2E tests- ESLint + Prettier - Enforced code formatting
- TypeScript Strict Mode - Type safety
- Absolute Imports - Clean import paths with
@/alias
feat: add new post creation modal
fix: resolve infinite scroll bug
docs: update README with deployment steps
style: improve mobile navigation layout// Use function declarations for components
export default function ComponentName() {
// Custom hooks at the top
const { user } = useUser()
const { data, isLoading } = useQuery(...)
// Event handlers
const handleClick = useCallback(() => {
// Implementation
}, [])
// Early returns for loading/error states
if (isLoading) return <LoadingSkeleton />
return (
<div className="component-container">
{/* JSX content */}
</div>
)
}- Setup Environment:
# Clone repository
git clone https://github.com/lugondev/comunia.git
cd comunia
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env.local
# Edit .env.local with production values- Build Application:
# Production build
npm run build
# Start production server
npm start
# or use PM2
npm run pm2- Nginx Configuration:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}NODE_ENV=production
NEXTAUTH_URL=https://your-domain.com
NEXT_PUBLIC_API_URL=https://api.your-domain.com
# Add other production secrets- Next.js Analytics - Core Web Vitals tracking
- Vercel Analytics - Real-time performance data
- Custom Metrics - User engagement tracking
- Sentry Integration - Error monitoring and alerting
- Console Logging - Development debugging
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'feat: add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Ensure all tests pass
- Update documentation if necessary
- Follow coding conventions
- Add screenshots for UI changes
- Backend API documentation:
/docs/backend-api-status-report.md - Authentication flow:
/docs/auth-system.md - Database schema:
/comunia-backend/prisma/schema.prisma
This project is licensed under the MIT License - see the LICENSE file for details.
Lugon - GitHub
Note: This project is under active development and may contain bugs. It will be continuously updated to keep up with the latest framework changes.