How nihalgound/botly-ai works
Main Components
• Frontend (Presentation) Layer:
• The Next.js-based UI residing in the “src/app” directory. This contains pages for dashboards, authentication (sign-in, sign-up), chatbot, and portals.
• UI components under “src/components” form the visual building blocks (buttons, forms, modals, navbars, etc.).
• Context providers and custom hooks (in “src/context” and “src/hooks”) that manage application state such as authentication, theme, chat, sidebar, and settings.
• Backend / Business Logic Layer:
• The “src/actions” directory contains logic for different functionalities (appointment, auth, bot, conversation, dashboard, mail, payment, settings, Stripe integration, etc.). These can be viewed as controllers or service handlers that process incoming requests.
• Data Layer:
• The “prisma” folder, containing schema.prisma and the related configuration, acts as the ORM layer, allowing the application to interact with a database.
• Utility functions (in “src/lib” and “src/schemas”) support data validation, manipulation, and common database interactions.
• Public & Assets:
• DevOps and Configuration:
• Next.js configurations (next.config.mjs), ESLint settings, Tailwind and PostCSS configurations, package management files, etc., which define how the project is built, linted, and deployed.
Relationships and Interactions
• The browser (client) accesses the Next.js application, which renders pages using React components under “src/app” and “src/components.”
• User interactions on the frontend are managed by UI components and handled by custom hooks, which coordinate with context providers.
• Actions (in “src/actions”) serve as the intermediary for processing business logic. For instance, when a user makes an appointment or authenticates, the corresponding action (or controller) is invoked.
• These actions communicate with the database layer using Prisma (managed in “prisma” and “src/lib/prisma.ts”) to create, read, update, or delete data.
• External services (e.g., Stripe for payments, email services, possibly chatbot integrations) are accessed through designated action modules that encapsulate their interfaces.
Architectural Patterns and Design Principles
• Separation of Concerns: The project cleanly separates UI rendering (React components in the app and components directories) from business logic (actions) and data management (Prisma).
• Modular Design: By grouping similar functionalities (authentication, appointments, dashboard, etc.) into their respective directories in both the “actions” and “app” layers, the project promotes scalability and maintainability.
• API Routing & File-based Routing: Next.js file-based routing in the “src/app” directory defines how pages and API calls are delivered.
• Use of Custom Hooks and Context Providers: Helps maintain a predictable state across the application.
Technologies, Frameworks, and Libraries
• Next.js for the frontend framework and server-side rendering.
• React for building UI components.
• Prisma as an ORM for database management.
• Tailwind CSS (configured via tailwind.config.ts) for styling.
• Various integrations (e.g., Stripe, mail services) as indicated by the “src/actions” directory.
• ESLint and PostCSS for code quality and styling processing.