How siddharth-mourya/powerlytic-ui works
Project Type & Purpose
• This is a Next.js front-end dashboard application for managing devices, device-models, organizations, users and port-types.
• It uses React components, Next.js App Router, React-Query for data fetching, Context for authentication state, and Axios to call external RESTful APIs.
Break Down the File Structure into Logical Layers
• Presentation Layer
– app/(pages)/… (SSR/SSG page entries)
– app/_components (reusable UI primitives)
– app/layout.tsx, providers.tsx (root layout, context providers)
• Data-Fetching Layer
– app/_lib/_react-query-hooks (React-Query hooks per domain: auth, devices, models, orgs, portTypes, values)
– app/_lib/api/axios.ts (Axios instance for HTTP calls)
• Business-Logic & State
– app/_lib/context/AuthContext.tsx (authentication context)
– app/_lib/utils/rbac (role-based access control policies & guards)
• Static & Configuration
– public/ (static assets)
– next.config.ts, tsconfig.json, package.json (build & TypeScript config)
Readme for Stack & Deployment
• Next.js v13+ with App Router
• Tailwind/PostCSS (postcss.config.mjs, globals.css)
• Deployed on Vercel by default
Main Components & Their Relationships
a. Client (Browser)
• Renders Next.js pages & React components
• Interacts with Next.js server via SSR/SSG and client-side JS
b. Next.js Runtime/Server
• Serves routes under /dashboard, /login, etc.
• Provides API routes if any (none here) or proxies to external APIs
c. UI Component Library
• Accordion, Badge, Button, Tables, Charts
• Layout primitives: Header, SideBar, DashboardLayout
d. Data Layer
• React-Query Queries & Mutations
• Axios HTTP client
e. External RESTful Back-end Services
• Auth service (login, logout, current user)
• Device service (CRUD devices, update values)
• Device-Model service
• Organization service
• Port-Type service
• Values service
Architectural Patterns & Principles
• Feature-based folder structure (group by domain: devices, models, orgs)
• Separation of concerns: UI components vs. data-fetch hooks vs. business policies
• Context for cross-cutting concerns (authentication)
• React-Query for server-state management and caching
• Role-based access control via guard components
Essential Elements
• Clear component labels (e.g., “DeviceModelList.tsx”, “useDeviceModelsListRQ”)
• Annotations for key design patterns (e.g., “React-Query caching”)