Webapp for the Eloka white-labelled SaaS platform to run your business like agent-banking, micro-finance, payments, etc.
- One-time Setup:
- Run
npm i - Run
npm run prepare - Make sure the .husky/pre-commit file is executable by running:
chmod +x pre-commit
- Run
- Run project on your local device:
- Run:
npm run dev - Open webpage: http://localhost:3002
- Run:
npm run dev- Run development server on port 3002npm run dev.https- Run development server with HTTPS on port 3004npm run scan- Run development server on port 3006 with react-scan to detects rerenders and other performance issuesnpm run inspect- Run development server with Node inspectornpm start- Start production servernpm run build- Build production bundlenpm run analyze- Build with bundle-analyzer for size analysis
npm run lint- Run Next.js lintingnpm run lint:error- Run linting with fewer warningsnpm run lint:fix- Fix linting issues automaticallynpm run format- Format code with Prettiernpm run format:check- Check code formatting without changes
npm test- Run all testsnpm run test:quick- Run tests quickly without coverage for a single or all files (skips if no tests found)npm run test:file- Run tests for a single file in verbose mode (usage:npm run test:file path/to/file)npm run test:file:pattern- Run tests matching a pattern (usage:npm run test:file:pattern pattern)npm run test:failed- Run only the tests that failed in the last runnpm run test:watch- Run tests in watch modenpm run test:coverage- Run tests with coverage reportnpm run test:update:snapshots- Update test snapshots to match current output
npm run gornpm run generate- Run plop generator for new componentsnpm run sbornpm run storybook- Run Storybook on port 6006npm run build:storybook- Build static Storybooknpm run check-updates- Check for outdated dependenciesnpm run check-deps- Run custom dependency checks
npm run docker:dev- Run development containernpm run docker:prod- Run production containernpm run docker:dev:build- Build and run development containernpm run docker:prod:build- Build and run production containernpm run docker:stop- Stop all containersnpm run docker:clean- Remove containers, images, and volumes
components/: Contains reusable components used across the application.constants/: Contains constant values, configurations, and settings used throughout the application.contexts/: Contains context providers for managing global state and data.docs/: Contains extensive documentation files for the project.helpers/: Contains helper functions and utilities for various functionalities.hooks/: Contains custom React hooks for reusable logic.layout-components/: Contains components related to the layout and structure of the application.libs/: Contains wrapper functions for third-party libraries.memory-bank/: Contains the foundational project documentation for Memory Bank to be used by AI Agents.page-components/: Contains the main page components for the application.pages/: Contains Next.js page routes and components.plop-templates/: Contains templates for generating new components, hooks, etc. using Plop.public/: Contains static assets such as images and icons.styles/: Contains global styles and theme configurations.tf-components/: Contains low-code components related to the transaction framework.utils/: Contains shared utility functions and helpers for various functionalities.__tests__/: Contains unit and integration tests for the application. The tests are organized in a similar structure to the main codebase for easy navigation.
π Extended Documentation (docs/)
commit-message-instructions.md: Guidelines for writing good commit messages.docker-usage.md: Instructions for using Docker with the project.]features/: Contains detailed documentation for various features of the application.android.md: How does Eloka communicate with the Android wrapper app to provide a native experience?dashboard.md: Admin dashboard feature documentation.dynamic-popup-module.md: How to use the dynamic popup module to show custom popups throughout the app?feature-flags.md: How to use feature flags to conditionally enable/disable features, or for a beta rollout?inventory-management.md: Inventory management feature documentation.pub-sub.md: How to enable cross-component communication using the Pub/Sub pattern?transaction-history.md: Transaction history feature documentation.
- Global Styles:
- Global CSS styles are defined in styles/globals.ts.
- Theme:
- Default color theme configuration (CHakraUI): styles/themes.tsx
- A list of predefined color-themes for the organizations to choose from: constants/colorThemes.js
- Component to show theme colors to users to choose from: components/ColorPair/ColorPair.jsx -Organization's custom theme is loaded in pages/_app.tsx.
- Icon Library:
- To view available icons, open the webpage: http://localhost:3002/icons_demo
- To add new icons, see the file: constants/IconLibrary.ts
- There are duplicate icon-names as well, same icons with different names (for backward compatibility). Such icons are shown in red background with the pointer to the actual icon name.
- For optimizing individual SVG icons, use: SVGOMG - SVGO's Missing GUI
- Top Navbar - components/NavBar/NavBar.jsx
- Profile-menu (drop-down menu in top-right corner):
- Rendered in the
MyAccountCardcomponent in NavBar.jsx. - Items configuration (for internal links, such as, Settings page): constants/profileCardMenus.js
- Rendered in the
- Profile-menu (drop-down menu in top-right corner):
- Left Sidebar - components/SideBar/SideBar.jsx
- Menu items configuration: constants/SidebarMenu.ts
- Menu Context (data fetch after login, and filtered into transaction & other lists for the sidebar & bottom app bar): contexts/MenuContext.tsx
- Menu data filtering & transformation using: helpers/processTransactionData.js
- Bottom App Bar - The
BottomAppBaris a flexible component that serves as the primary navigation bar at the bottom of the small screen. It adapts to various use cases, allowing for the inclusion of navigation links, actions, and custom components. components/BottomAppBar/BottomAppBar.tsx- Bottom App Bar Items - The items in the Bottom App Bar are configured using the
useBottomAppBarItemshook. This hook returns an array of objects, each representing an item in the bottom app bar. components/BottomAppBar/useBottomAppBar.ts- Each item can include the following properties:
name: A unique identifier for the item.label: The text label displayed beneath the icon.icon: The name of the icon displayed in the item.path: The navigation path for the item. For admin users, paths can be prefixed with/admin.action: A function that is executed when the item is clicked, such as toggling a search bar.component: A custom JSX component that can be rendered within the item.visible: A boolean indicating whether the item should be visible in the Bottom App Bar.
- Each item can include the following properties:
- Bottom App Bar Items - The items in the Bottom App Bar are configured using the
To add pricing configuration page for a new product in the Admin portal under "Pricing & Commission" left-menu section, use the following steps:
- Create a configuration for the product in
constants/ProductBusinessConfigurations.tsfile under thebusiness_config_slug_mapobject.- Set a unique slug (for the page URL) and the name of the page-component to display.
- Set template="fileupload"
- Add set URL & parameters for file-upload and sample-file-download in the
metaobject. - Add the slug to
product_pricing_categoriesobject in the order that you want to display on the product listing page. If not added here, the product will not be displayed on the product listing page.
- Create a page-component for the pricing configuration running the command
npm run g- Select "Component"
- Enter the name of the page-component (eg:
TrainTravel) - Select Path:
page-components/Admin - Enter sub-folder:
PricingCommission
- Copy sub-components from other existing pricing page-component such as:
TrainTravelDistributorandTrainTravelRetailer - Create a configuration for the product in
constants/ProductBusinessConfigurations.tsfile under thebusiness_config_slug_mapobject.- Set a unique slug (for the page URL) and the name of the page-component to display (created in step #1).
- Add the slug to
product_pricing_categoriesobject in the order that you want to display on the product listing page. If not added here, the product will not be displayed on the product listing page.
- Create a configuration for the product in
constants/ProductDetails.jspage. Set slabs, validations, etc for the pricing configuration.
- To add a public page/route (that can be accesseed by anyone, without logging in), add the route in constants/validRoutes.js within the array:
publicLinks.
πͺ Custom hooks/:
useAppLink: For handling app links (deep-links) and redirecting to the appropriate page. Supports oldconnect.eko.inlinks as well as theekoconnect://links.useClipboard: Copy text to clipboard.useDailyCacheState: Cache the state in the browser's localStorage. The cache state has avalidflag which is set tofalsewhen the cache is stale (older than 1 day).useDebouncedState: Debounce the state update to avoid unnecessary re-renders.useDelayToggle: A simple hook to toggle a boolean value after a delay. For example, it can be used to load/show a component after an initial delay.useExternalResource: Load an external resource (JS/CSS) dynamically. It returns a state variable (idle, loading, ready, error) and a reload function. The resource is loaded only once.useFeatureFlag: Check if a feature is enabled or not. Set the feature-flags with conditions in the constants/featureFlags.ts file.useHotkey: Register a hotkey (keyboard shortcut) and execute a callback function when the hotkey is pressed. Uses the tinykeys library.useHslColor: Get a dynamic color in HSL format based on the input value. Useful for creating a color scale or colored tags.useLocalStorage: Read/Write data to the browser's localStorage.useSessionStorage: Read/Write data to the browser's sessionStorage.usePubSub: Publish/Subscribe to events. Add new topics in the contexts/PubSubContext.js file.
π¦ Custom libs:
These are wrappers around 3rd-party libraries or associated utility functions.
- GoogleMap - Google Maps API wrapper
- Map View - View static maps using iFrame
- dateFormat - Date formatting utility (wrapper around
date-fns) - faceDetector - Dynamically loads MediaPipe Face Detector model (uses wasm)
- chakraKeyFrames - Common keyframes for ChakraUI animations
π½ Global Contexts (Data Providers)
The following data is stored in the browser (localStorage & sessionStorage):
org_detail: Organization detailsuser_detail: User detailsaccess_token: Access tokenaccess_token_liteaccess_token_crmtoken_timeout: Token timeoutrefresh_token: Refresh token
- Component: AiChatWidget.jsx
- TODO: use
react-chatbot-kitlibrary.
π Pages
Admin Pages:
- Dashboard
- Business Dashboard: Divided into 4 part i.e. TopPanel, EarningOverview, SuccessRate & TopMerchants with there config in there respective file - page-components/Admin/Dashboard/BusinessDashboard
- Home
- Know Your Commissions:
- Commission Data is fetched via CommissionContext when the user signs-in.
- Know Your Commissions: