$ show leandronorcio/munia
Munia is a full-stack social media web application built with Next.js 14, React 18, and TypeScript. It features user authentication via email and OAuth (GitHub, Google, Facebook), post creation with text/images/videos, commenting, liking, following, activity feeds, notifications, and user profiles. The architecture uses Next.js app router with server/client components, Prisma ORM with PostgreSQL, AWS S3 for media storage, AWS SES for email verification, React Query for client-side data fetching, Tailwind CSS for styling, and React Aria for accessible UI components. Key entry points include Next.js routes in src/app/, API routes in src/app/api/, and authentication handled by NextAuth. Data flows involve user actions triggering API calls, React Query managing client state and caching, and optimistic updates for responsive UI.
The LLM identified 19 files worth highlighting for reuse:
Handles conversion of @username mentions to user IDs with bidirectional capability (usernameβID and IDβusername), deduplication, and proper error handling. Isolated function with clear input/output that efficiently uses Prisma to resolve mentions.
Simple utility to revoke object URLs created for blob media files, preventing memory leaks. Focused single responsibility, type-safe, and handles arrays of media objects with minimal dependencies.
Calculates difference between a number and its nearest lower multiple of another number. Pure function with zero dependencies, well-documented with examples, and useful for UI layout calculations.
Extracts initials from a name for fallback avatar display. Pure function that handles edge cases (single name, multiple names) and returns uppercase initials for consistent UI fallback avatars.
Automatically adjusts textarea height based on content. Simple but effective DOM manipulation that directly handles textarea elements for responsive form inputs.
Converts FormData to plain object, properly handling multiple values with same key. Handles edge cases of FormData API with clear examples and is essential for processing file uploads and form submissions.
Validates if a file type is allowed (images/videos). Simple but effective validation against allowed MIME types, providing a reusable guard for file upload security.
Standardized way to include relations and counts in Prisma queries for comments. Encapsulates complex Prisma include logic for comment likes and counts, reusable across multiple query contexts.
Converts Prisma query results to application-specific GetComment type with proper field mapping. Handles type conversion, null safety, and relation mapping consistently for comment data.
Handles logging of mention activities (post/comment/reply mentions) with proper cleanup on updates. Efficiently manages both creation and update scenarios using batch database operations.
Custom hook for detecting element visibility in viewport using Intersection Observer. Properly cleans up observers, accepts configurable root margin, and returns boolean visibility state.
Disables animations when using browser back/forward buttons to preserve scroll position. Uses popstate event listener with timeout to re-enable animations, improving perceived performance during navigation.
Centralized control for create/edit post modal state using React context. Separates concerns with clean API for launching modals, managing form state, and handling file input focus.
Simple wrapper around toast context for consistent API. Provides consistent toast interface with default timeout and encapsulates toast creation logic.
Fully accessible button component with variants, loading states, and icon support. Uses React Aria for accessibility, CVA for variants, and proper focus handling while maintaining design flexibility.
Accessible input with clear button, proper labeling, and error states. Uses React Aria for accessibility, handles clear functionality, and maintains proper accessibility attributes and focus management.
Accessible textarea with auto-resize, clear button, and proper labeling. Combines auto-resize utility with accessible base component for enhanced form usability.
Accessible select/dropdown with search, clear button, and proper labeling. Uses React Aria for accessibility, handles clear functionality, and maintains proper accessibility while providing rich selection experience.
Animated theme switcher between system/light/dark with persistence to localStorage. Uses Framer Motion for smooth animations and persists user preference across sessions.