How izoxvl/uniroom-front-web works
After reviewing the file tree and the minimal README, it’s clear that this project – named “UniRoom-Front-Web” – is a full-stack web application built on Next.js (using both server and client components) with integrated API routes and authentication flows. The project appears to be a frontend web application with “protected” areas (like dashboard, admin, rooms management, and settings) and public authentication pages, leveraging technologies such as Next.js, React (with TypeScript), NextAuth for authentication, and Prisma for database interactions.
Main Components
a. Client / Presentation Layer:
• Pages & Views – Found in directories like src/app/auth and src/app/(protected). These include login, register, new-password, settings, room management (add, edit, list), and admin panels.
• UI Components – In src/components (category-wise: Admin, Auth, Rooms, Header, Sidebar, common, etc.), which encapsulate reusable visual and interaction elements.
• Styling & Assets – CSS files (in src/css), fonts (in src/fonts), public images, and lottie animations (in public).
b. Business Logic & State Management:
• React Hooks – Custom hooks (e.g., use-current-role, use-current-user, useLocalStorage) and actions in src/actions that manage logic like authentication, password reset, and settings.
• Providers – Components in src/components/providers (e.g., confetti-provider) indicating global state or UI enhancement wrappers.
c. Server/API Layer:
• API Routes – Found under src/app/api, targeting authentication (including admin auth endpoints) via Next.js API handler routes.
• NextAuth Integration – Files like src/auth.config.ts and src/next-auth.d.ts indicate configuration for authentication flows handled on the server side.
• Middleware – src/middleware.ts which can be used for things like route protection or other pre-processing.
d. Data Access Layer:
• Prisma – The prisma directory containing schema.prisma indicates database models and migration logic.
• Database Utilities – In src/lib/db.ts for database-related functions.
• Other Utilities – In src/lib (auth.ts, mail.ts, tokens.ts, utils.ts) that coordinate external services like mailing or token management.
e. External Dependencies:
• Next.js – The next.config.mjs file dictates project configurations, workloads split into server/client, and may include integration with plugins.
• Styling Tools – Tailwind CSS (configured via tailwind.config.ts) and PostCSS (via postcss.config.js).
• Tooling – Standard configuration files (.env, .eslintrc.json, .prettierrc, tsconfig.json) for environment, linting, formatting, and type-checking.
Establish Relationships and Interactions
• The Client (React pages and components) interacts with the server’s API routes for authentication (e.g., login, register, logout, password resets) and to fetch or update room details.
• Authentication is managed via NextAuth, with specific routes under src/app/api/auth, and frontend actions calling these endpoints.
• Protected areas of the app (under src/app/(protected)) enforce authentication and role-based access (as indicated by role-gates and hooks like use-current-role).
• Data fetched from or written to the database flows through Prisma, accessed via helper functions in src/lib/db.ts.
• UI state and asynchronous actions come with the support of custom React hooks and libraries provided in src/hooks and src/components.
• Cross-cutting concerns (like error/success messaging) are handled by shared components (e.g., form-error.tsx, form-success.tsx).
Architectural Patterns and Design Principles
• Separation of Concerns – The project distinguishes between presentation (components and pages), business logic (hooks, actions), and data handling (API routes and Prisma).
• Server-Side Rendering and API-First Approach – Leveraging Next.js features for server-side data fetching and dynamic routing, particularly for authentication.
• Modular Design – Components are broken down by domain (Auth, Admin, Rooms, common) and reused across views.
• Role-Based Access Control – Evident from segregation into authentication pages and protected pages, as well as specialized admin components.
Instructing the Principal Software Engineer
2. Inside the Client section, break down the UI into public (auth flows) and protected (authenticated areas like dashboard, rooms management, and admin functionalities). Indicate the navigation flow (using components like Header, Sidebar, Breadcrumbs).
3. In the Server/API section, illustrate endpoints for auth (including admin-specific endpoints) and highlight integrations with business logic (actions in src/actions) and further connect these to the database.
4. How common utilities (from src/lib and src/hooks) support both client and server operations.
• Integration points such as interaction with NextAuth, integration with Prisma for the database, and the usage of external assets (images, animations, fonts) to enrich the UI.