How ericgalbarn/univeristy-library-webapp works
Main Components
• Admin UI (Frontend Pages) – These are the Next.js admin pages located in the folder structure under “app/admin”. They include:
• Dashboard components (e.g. activities, dashboard-stats)
• Account requests (e.g. account-requests pages)
• Book addition and book management (e.g. book-addition-requests, books with pages for new/edit and details)
• Borrow-request management (e.g. book-requests, borrow-requests)
• User management (e.g. users pages for listing/editing)
• Admin API Endpoints – These are found under “app/api/admin”. They serve as the backend “controller” layer for all admin actions:
• Endpoints for account requests, books (including export and borrowers), borrow requests (with routes for return and export), dashboard stats, and user-related export endpoints.
• Admin Business Logic & Actions – The business rules for handling admin workflows reside in:
• “lib/admin” (such as actions for book and user management)
• “components/admin” that provide specialized UI elements (e.g., Sidebar, Header, Book and User lists with modals).
• Database and Infrastructure – The shared database resources and migration scripts in the “db” and “migrations” directories show how the admin actions persist, update, or query data.
• Auxiliary Services – Optionally, include other supporting elements used in admin (for instance, email notification templates or exports) if they tie into admin functions.
Relationships & Interactions
• The Admin UI sends requests (using fetch calls, API actions, or Next.js routing) to respective Admin API endpoints.
• Admin API endpoints, after validating requests (possibly using middleware/authentication), trigger the business logic provided in “lib/admin” to process actions.
• The Business Logic interacts with the Database (via “db” and migration scripts) to read or modify persistent state (like account requests, book records, and user details).
Architectural Patterns & Design Principles
• MVC/Component Separation: The Next.js pages under “app/admin” (View) are cleanly separated from the API “controller” layer (the business logic) and the database (Model). Show these three layers distinctly.
• Modularization: Highlight that the admin case is split into various modules (account-requests, book-addition-requests, books, users, activities, and borrow-requests), which are separately maintained in the file tree. Each module has its dedicated set of pages, API endpoints, and even specialized components.
Putting It All Together
• Link the API endpoints to a “Business Logic / Admin Actions” module.
• Finally, connect the Business Logic to a “Database” component representing the persistent data store.
• To add any supporting flows (like data exports) on side branches and include labels for clarity.