How ehtisham-sadiq/auto-post-manager works
Project type and purpose
• This is a full-stack “frontend” application built with Next.js (App Router), React, and Tailwind CSS. Its sole responsibility is to provide a modern LinkedIn content management and scheduling UI. It handles authentication via NextAuth.js, session management, routing, UI state, and delegates all business logic and data persistence to a separate backend API.
File structure
• Top-level “app/” directory: contains Next.js App Router pages and layouts (public pages, protected area under “(protected)”).
• “pages/api/”: serverless API routes powering NextAuth.js authentication endpoints.
• “components/”: purely client-side or shared UI components (dialogs, cards, navigation).
• “services/”: client-side API clients (analytics-service.ts, post-service.ts, etc.) that call the external backend at NEXT_PUBLIC_API_URL.
• “lib/”: shared utilities (api-client.ts for fetch wrappers, auth.ts for NextAuth config, db.ts probably for in-memory or preview).
• “hooks/”: custom React hooks for UI state (use-toast, use-mobile).
• “public/” and “styles/”: static assets and global styles.
• Config files: next.config.mjs, tailwind.config.ts, tsconfig.json, .env for environment variables.
README for additional insights
• Project description confirms: frontend for LinkedIn-CMS, uses NextAuth.js for authentication, protected routes, bulk uploads, templates, analytics, scheduling.
• Mentions external API base URL via NEXT_PUBLIC_API_URL. No database logic lives here.
a. Main components:
• Browser (User’s Client)
• Next.js App Server (SSR/ISR and Router)
– Pages & Layouts (public vs protected)
– NextAuth.js Middleware / API Routes ([...nextauth].ts)
• Client-side “Services” Layer (services/*.ts)
• External Backend API (REST or GraphQL)
• Authentication Provider (NextAuth Credentials flow)
• Static Assets/CDN (public/, fonts, images)
• External 3rd-party services (e.g., image AI generator if any)
b. Relationships & interactions:
1. Browser requests a page → Next.js Server renders (SSR/Server Components) → sends HTML/CSS/JS.
2. Client-side React hydrates → UI components call services/*.ts → fetch to backend API (NEXT_PUBLIC_API_URL).
3. Protected route guard (ProtectedRoute or getServerSession) checks NextAuth session via cookies.
4. Authentication flows: Sign-in/sign-up pages call NextAuth API Route → NextAuth uses Credentials Provider to validate → sets session cookie.
5. Bulk upload: CSV file → csv-uploader component → calls bulk-service.ts → backend → processes.
6. Analytics: stats-card calls analytics-service.ts → external API → returns metrics.
c. Architectural patterns & design principles:
• App Router with nested layouts for separation of public vs protected UI.
• Hooks & service layer for separation of concerns (UI vs data fetching).
• “Fat” client: most logic lives in React components and service modules. Minimal serverless logic only for auth.
• Tailwind + component library for consistent, responsive UI.
d. Relevant technologies/frameworks/libraries:
• Next.js (App Router with server & client components)
• React (hooks, context via auth-provider and theme-provider)
• NextAuth.js (authentication)
• Tailwind CSS (styling)
• TypeScript (type safety)
• Node.js runtime for serverless API routes
Essential architectural elements
• Don’t group everything under “frontend”—break out:
• App Router (public vs protected)
• API routes for NextAuth
• Service layer (analytics, posts, templates, schedule)
• Shared UI components vs page-specific components
• Static assets