How mkunboxing/quicky works
Main Components
• Client-Facing Frontend: Located mainly under src/app/(client). This includes pages such as the homepage, product details, contact, account management (orders), delivery, and payment results. Also include shared UI components (header, footer, hero elements, etc.) under src/app/(client)/_components.
• Administration Interface: Found under src/app/admin with its own layout and dedicated pages (orders, inventories, products, warehouses, delivery persons). This section also contains its UI components (data table, sidebar, etc.).
• API Endpoints: Under src/app/api, there are RESTful or possibly Next.js Route Handlers for handling various actions (e.g., orders, auth, delivery-persons, inventories, products, warehouses, verify-payment). This shows the separation between UI and business logic.
• Database & Migrations: The “drizzle” folder along with drizzle.config.ts and files under src/lib/db indicate that the project uses a migration system (Drizzle ORM) with SQL migrations and corresponding schema definitions. Also include “drizzle/meta” for schema snapshots and versioning.
• State Management & Utility Services: The project includes a global store (src/store) for managing state related to products, orders, deliveries, etc., along with utility libraries (src/lib), authentication options, and API/client utilities (src/http).
• External Dependencies / Auth Providers: Key libraries include Next.js, Drizzle ORM, and integration with Supabase (src/lib/supabase.ts) along with custom font optimizations from next/font.
Relationships and Interactions
• Frontend Clients (both client and admin views) interact with API endpoints via HTTP or Next.js-specific routing conventions.
• API routes interact with the database layer (managed via Drizzle migrations, and schema definitions in src/lib/db) to read/write persistent data.
• UI components make use of centralized stores and validation utilities to manage state and validate user data.
• Authentication flows (in src/app/api/auth and src/lib/auth) encapsulate security aspects and tie into both API services and frontend providers.
• Providers (auth-provider, query-provider) wrap the application to manage user sessions and asynchronous data fetching.
Architectural Patterns & Design Principles
• Separation of Concerns: Clear separation between presentation (client/admin pages), business logic (API endpoints), data persistence (database migrations and ORM), and state management (stores).
• Modularization: Organized file structure separates concerns by context (client vs. admin), supporting a modular approach to component reuse.
• API-centric Communication: API routes serve as a clear boundary between the server-side logic and frontend, making it easier to manage data flow.
• Use of Providers: The providers encapsulate global concerns (auth, query management) and help decouple the UI from direct integration with lower-level services.