How rayjaywolf/newera works
Main Components
• Frontend (Client UI):
– Represented by the Next.js pages found in the “app” directory (with segregated areas like admin, projects, sign-in, etc.).
– Includes public-facing pages (e.g., main landing page, sign-up, sign-in) as well as admin and project-specific dashboards (pages under “app/admin” and “app/projects”).
• Backend/API Layer:
– The “app/api” directory contains numerous serverless API routes handling CRUD operations and business logic for attendance, workers, projects, machinery, materials, and image uploads.
• Business Logic & Services:
– Shared functionality is located under “lib” (with modules for AWS config, face recognition, ID generators, and Prisma integration) and “utils”.
– “hooks” provide additional client-side behavior, such as mobile support and toast notifications.
• Database:
– Use of Prisma is indicated by “prisma/schema.prisma” and related files in “lib/prisma” and “utils/db.” This points to a relational database at the backend.
• External Integrations:
– The presence of AWS configuration in “lib/aws-config.ts” and a dedicated “face-recognition” module suggests integration with an external face recognition service.
• UI Components:
– The “components” folder hosts a wide range of UI elements, from basic UI primitives to complex components like image viewers, project sidebars, advanced dialogs, and various charts and tables.
Relationships and Interactions
• The Client UI (browser) interacts with:
– Next.js pages that render various views (admin dashboards, projects, etc.).
– API endpoints for dynamic data and CRUD operations.
• API Endpoints:
– Directly map to serverless function routes in “app/api/*”.
– They handle data requests from frontend pages, transform data via the business logic provided in “lib” and “utils,” and then interact with the database.
• Backend Services:
– Modules like “face-recognition.ts” in “lib” take inputs from API endpoints (for example, when a worker’s attendance data requires facial recognition) and may also interact with external systems (AWS services).
• Database:
– The middleware (e.g., Prisma files) manages database interactions.
• UI Components and Hooks:
– All reusable and common UI fragments are in “components” and “hooks” and are utilized across both the frontend pages and possibly within dynamically rendered admin or project views.
Architectural Patterns & Design Principles
• Separation of Concerns:
– The project is clearly split into UI (app directory and components), API logic (app/api), and business logic (lib and utils).
• File-System Based Routing:
– Next.js’s designated structure in “app” and “app/api” domains defines the routing, benefiting from clear and predictable URL structures.
• Serverless Architecture:
– API endpoints (each as an individual route.ts file) are designed to be stateless and could map directly to serverless functions on deployment platforms like Vercel.
• Modular Design:
– Shared logic and utilities (e.g., authentication, role management in “utils/roles.ts”) promote reusability and maintainability.