How meetmendapara09/gearlink-crm works
Purpose and runtime
GearLink CRM is a Next.js App Router business-management application for auto-parts stores. It combines CRM, POS/sales, inventory, invoicing, planning, reporting, and AI-assisted workflows. The primary runtime is the Next.js server/client application; AI flows run through a separate Genkit development/runtime process. Firebase provides authentication and likely application backend integration. Deployment configuration is present in apphosting.yaml.
Application entry and route partitioning
The public root and account/legal pages enter through src/app/page.tsx, src/app/login/page.tsx, and src/app/signup/page.tsx. The root application shell is defined in src/app/layout.tsx; authenticated/operational routes are grouped under src/app/(app)/layout.tsx. Request-level access control is a distinct boundary at src/middleware.ts, while client auth state is supplied by src/components/auth-provider.tsx and consumed through src/hooks/use-auth.ts.
Auth and Firebase boundary
Firebase integration is centralized in src/lib/firebase.ts, with authentication-oriented logic in src/lib/auth.ts. Login and signup forms at src/app/login/login-form.tsx and src/app/signup/signup-form.tsx are the user-facing ingress for Firebase Authentication. This separates identity/session concerns from the business pages and middleware route protection.
Operational CRM modules
The authenticated route group organizes major workflows as independently routed screens: dashboard (src/app/(app)/dashboard/page.tsx), POS sales (src/app/(app)/sales/page.tsx), customers (src/app/(app)/customers/page.tsx), products (src/app/(app)/products/page.tsx), invoices (src/app/(app)/invoices/page.tsx), tasks, calendar, and support. Shared business entities are represented through data modules such as src/lib/data/products.ts, src/lib/data/customers.ts, and src/lib/data/invoices.ts, with common domain typing in src/lib/types.ts.
Sales pipeline, scheduling, and analytics
Deal progression is modeled as a visual pipeline: src/app/(app)/sales-pipeline/page.tsx composes src/components/sales-pipeline-board.tsx, src/components/pipeline-column.tsx, and src/components/deal-card.tsx; deal data is isolated in src/lib/data/deals.ts. Tasks and invoice timing converge in src/app/(app)/calendar/page.tsx via src/components/calendar-view.tsx. Reporting is routed through src/app/(app)/reports/page.tsx and rendered with chart components including src/components/sales-chart.tsx and src/components/top-products-chart.tsx.
AI workflow boundary
Genkit initialization is isolated at src/ai/genkit.ts; its development entry point is src/ai/dev.ts. AI capabilities are explicit flow modules: part recommendations in src/ai/flows/smart-part-finder.ts, campaign generation in src/ai/flows/email-marketer.ts, and report summarization in src/ai/flows/sales-report-summarizer.ts. UI entry points for these capabilities include src/app/(app)/smart-finder/smart-finder-form.tsx and src/app/(app)/marketing/marketing-campaign-form.tsx. The application invokes server-side behavior through src/lib/actions.ts, keeping UI forms distinct from AI/service execution.
Interface and infrastructure
The app-level navigation/container appears to be centralized in src/components/app-sidebar.tsx, with reusable ShadCN-derived primitives under src/components/ui. Tailwind and TypeScript form the frontend implementation stack. Key external boundaries are Firebase Authentication/backend services, Google Gemini accessed through Genkit, and Firebase App Hosting configuration in apphosting.yaml.
Main entry points: (app)/layout.tsx Authenticated shell · products.ts Business data modules · app/layout.tsx Root shell · firebase.ts Firebase integration
Components 20
Public & Identity
- Root shell
src/app/layout.tsx - Public account pages · Landing, login, and signup entry routes.
src/app/page.tsx - Login & signup forms
src/app/login/login-form.tsx - Route protection
src/middleware.ts - Client auth state
src/components/auth-provider.tsx
Operational App
- Authenticated shell
src/app/(app)/layout.tsx - App navigation
src/components/app-sidebar.tsx - CRM operations · Dashboard, sales, customers, products, invoices, tasks, calendar, and support.
src/app/(app)/dashboard/page.tsx - Sales pipeline · Board, columns, and deal cards visualize deal progression.
src/app/(app)/sales-pipeline/page.tsx - Calendar · Combines task and invoice timing.
src/app/(app)/calendar/page.tsx - Reports · Renders sales and top-product charts.
src/app/(app)/reports/page.tsx - AI workflow forms · Smart Finder and marketing campaign UI entry points.
src/app/(app)/smart-finder/smart-finder-form.tsx
Domain & Backend
- Business data modules · Products, customers, invoices, and deals with shared types.
src/lib/data/products.ts - Firebase integration · Central Firebase initialization and authentication logic.
src/lib/firebase.ts - Firebase services · Authentication and application backend boundary.
AI Workflows
- Server actions · Separates UI requests from server-side execution.
src/lib/actions.ts - Genkit runtime · Separate development/runtime process for AI flows.
src/ai/genkit.ts - AI flows · Part finder, campaign generation, and report summarization.
src/ai/flows/smart-part-finder.ts - Google Gemini
Other components
- Firebase App Hosting
apphosting.yaml
Connections 22
- Root shell → Public account pages: renders
- Root shell → Authenticated shell: hosts
- Route protection → Authenticated shell: guards
- Public account pages → Login & signup forms: contains
- Login & signup forms → Firebase integration: signs in/up
- Client auth state → Firebase integration: uses
- Firebase integration → Firebase services: connects to
- Authenticated shell → App navigation: includes
- Authenticated shell → CRM operations: routes to
- Authenticated shell → Sales pipeline: routes to
- Authenticated shell → Calendar: routes to
- Authenticated shell → Reports: routes to
- Authenticated shell → AI workflow forms: routes to
- CRM operations → Business data modules: uses
- Sales pipeline → Business data modules: reads deals
- Calendar → Business data modules: uses timing data
- Reports → Business data modules: analyzes
- AI workflow forms → Server actions: invokes
- Server actions → AI flows: executes
- Genkit runtime → AI flows: runs
- AI flows → Google Gemini: uses
- Firebase App Hosting → Root shell: deploys