How connect2local247/development works
1. This is a Next.js App Router application that combines a public marketing/portfolio site with a logged-in admin/user portal. The UI lives under src/app, while almost all business operations are exposed through route handlers under src/app/api.
2. The app has two main surfaces:
- Public-facing pages: home, about, services, portfolio, projects, blogs, case studies, contact, terms, and payment-related views.
- Authenticated dashboard areas: /user/[role] with management screens for users, clients, projects, payments, receipts, refunds, requests, notifications, inbox, CMS, and role-permission administration.
3. The API layer is organized by domain rather than by generic CRUD. Route groups such as auth, dashboard, project-management, payment-management, resource-management, role-permission, notification, client, request, upload, webhook, and cms map directly to business capabilities. Most endpoints follow an [action] and optional [data] pattern, suggesting a command-style API design rather than a purely RESTful one.
4. Underneath the route handlers is a server-side application layer in src/server. It is split into:
- module/*: domain controllers and module configs
- controller/*: higher-level controllers
- service/*: orchestration and workflow logic
- provider/*: external integrations
- config/*: environment, middleware, payment, upload, Firebase, GraphQL, templates, and model wiring
5. Persistence is handled by Prisma with a fairly rich relational schema. The migration history shows evolving models for users, clients/POs, projects, project attributes, technologies, links, payments, payment orders, receipts, refunds, currencies, payment methods/types, notifications, and role/permission entities. This is the core data store for the portal and the admin workflows.
6. The domain model is centered around a few major subsystems:
- Project management: project records, attributes, technologies, links, media, status, and client/project associations.
- Payment management: payment requests, payment orders, receipts, refunds, currencies, methods, and payment types.
- Access control: roles, permissions, modules, and assignment screens.
- Content management: editable pages and sections for the marketing site.
- Notifications/inbox: cross-cutting messaging around payments, projects, and user actions.
7. External integrations materially shape the architecture:
- Razorpay for payment processing and payment/order lifecycle.
- Cloudinary for media uploads and asset storage.
- Firebase for messaging/push and admin permission support.
- Mail delivery and templated emails for OTP, welcome, payment, refund, and invoice flows.
- GraphQL is present for page/content retrieval and selected backend workflows, alongside the route-handler API.
8. Data flow is typically: UI page/component → client hook/store/API helper → Next.js route handler → server module/controller/service → Prisma/database and/or external provider. The src/config/api and src/hooks/* folders provide the client-side request and state abstraction, while src/server/lib/* and src/lib/* provide shared validation, formatting, serialization, and response/error handling.
9. The frontend is highly componentized. src/component contains reusable UI primitives, forms, tables, cards, views, loaders, layouts, modals, and domain-specific sections. The codebase separates:
- generic UI building blocks
- domain forms for projects, payments, users, clients, and role-permission
- read-only views for project/payment/user detail screens
- layout shells for public site, auth pages, dashboard, and request/payment flows
10. State management is split by domain and UI concern. The src/config/store area contains stores for payment, project, request, portfolio, CMS/page editor, theme, users, and role-permission. This suggests the app uses client-side state for complex multi-step workflows such as editing projects, handling payments, and managing CMS content.
11. Validation and data shaping are important boundaries. Schema definitions live in src/lib/schema, with supporting types, patterns, formatters, serializers, and helpers spread across src/lib and src/server/lib. This indicates input validation and output normalization happen close to the domain boundary before data reaches Prisma or external services.
12. There is also a content/SEO/operational layer:
- sitemap generation and next-sitemap.config.js
- public/firebase-messaging-sw.js for push notifications
- static assets in public/images
- Google site verification file
- CMS pages for editing public content
These suggest the repository is not just an internal tool, but also powers a public portfolio/agency site with operational back-office features.
13. The main architectural boundary to preserve in a diagram is between presentation, API orchestration, and domain infrastructure. The UI should be shown as consuming backend capabilities through Next.js route handlers, while server modules should be shown as the canonical business layer coordinating database, payment, upload, notification, and messaging integrations.
Main entry points: module Business Modules · service Services · provider Providers · api Route Handlers
Components 19
Presentation
Public site, auth, and dashboard surfaces rendered by Next.js App Router.
- Public Site · Marketing and portfolio pages such as home, about, services, projects, blogs, case studies, contact, and terms.
src/app - Auth Pages · Login, OTP verification, password recovery, and related authentication screens.
src/app/auth - Dashboard UI · Role-scoped portal for users, clients, projects, payments, receipts, refunds, requests, notifications, inbox, CMS, and access control.
src/app/user/[role]
API Layer
Route handlers and client-side request/state adapters.
- Route Handlers · Domain-organized App Router API endpoints using action/data command-style routes.
src/app/api - Client API · Frontend endpoint definitions, API client setup, and query handler provider used by hooks and stores.
src/config/api - Client State · Domain and UI stores for payments, projects, requests, CMS page editing, users, theme, and role-permission workflows.
src/config/store - GraphQL API · Schema and resolvers for page/content retrieval and selected backend workflows.
src/graphql - CMS API · API surface for editable site pages and sections.
src/app/api/cms
Server Domain
Canonical business logic, orchestration, and integration boundary.
- Business Modules · Primary server-side domain controllers grouped by auth, dashboard, projects, payments, notifications, uploads, users, webhook, and access control.
src/server/module - Controllers · Higher-level controllers that expose domain operations and coordinate request handling.
src/server/controllers - Services · Cross-entity business workflows, especially payment and notification orchestration.
src/server/service - Providers · Shared integration layer for external systems and infrastructure adapters.
src/server/provider - Server Config · Environment, middleware, GraphQL, Firebase, mailer, payment, upload, and model wiring.
src/server/config - Validation & Lib · Shared schemas, serializers, formatters, handlers, and utility code that shape input and output boundaries.
src/lib
Data & Integrations
Persistence, external services, and operational assets.
- Prisma DB · Central relational persistence for users, projects, payments, receipts, refunds, notifications, roles, permissions, and content-related entities.
prisma/schema.prisma - Razorpay · External payment processing and order lifecycle integration.
- Cloudinary · Asset upload and media storage integration.
src/config/cloudinary/cloudinary.ts - Firebase · Push messaging and admin permission support integration.
src/config/firebase/firebase.ts - Mail Templates · Templated OTP, welcome, payment, refund, invoice, and contact email flows.
src/server/templates
Connections 21
- Public Site → Client API: fetches data · Public pages consume API helpers and query hooks for dynamic content.
- Auth Pages → Client API: auth requests · Authentication screens submit through shared client API helpers.
- Dashboard UI → Client API: portal actions · Dashboard screens call domain-specific endpoint helpers.
- Dashboard UI → Client State: stores state · Complex portal workflows rely on domain client stores.
- Client API → Route Handlers: calls · Client-side helpers invoke Next.js route handlers.
- Client State → Route Handlers: mutates via API · Stores coordinate CRUD and command flows through route handlers.
- Route Handlers → Business Modules: dispatches · Route handlers delegate domain work to server modules.
- Business Modules → Controllers: coordinates · Modules reuse controllers for higher-level orchestration.
- Controllers → Services: runs workflows · Controllers hand off to services for multi-step business logic.
- Services → Prisma DB: persists · Services read and write the relational schema.
- Services → Providers: integrates · Services call external adapters through the provider layer.
- Providers → Razorpay: payments · Payment workflows use Razorpay for orders and settlement.
- Providers → Cloudinary: uploads · Media workflows store assets in Cloudinary.
- Providers → Firebase: messaging · Notifications and push flows use Firebase services.
- Services → Mail Templates: emails · Business events render and send templated mail.
- Business Modules → Server Config: depends on · Modules use shared runtime configuration and middleware wiring.
- Server Config → Validation & Lib: shared boundary · Configuration and handlers rely on shared schemas, formatting, and error handling.
- Route Handlers → GraphQL API: content query · Selected endpoints expose GraphQL-backed page and section retrieval.
- CMS API → Business Modules: content ops · CMS endpoints route page editing operations into server modules.
- GraphQL API → Prisma DB: resolves data · GraphQL resolvers source content from the database layer.
- Business Modules → Validation & Lib: validates · Domain modules validate and normalize inputs and outputs.