How juangui78/myviewproyect works
1. Overall shape
- This is a Next.js App Router application with both UI and backend logic in the same repo.
- The architecture is split into three main layers: route-based UI under src/app/web, API endpoints under src/app/api, and shared infrastructure/helpers under src/app/api/libs and src/app/api/models.
2. Request entry and routing
- src/app/layout.jsx, src/app/page.jsx, and src/app/providers.jsx provide the app shell and top-level composition.
- src/middleware.js sits in front of the app and likely enforces auth/route access rules, which is important because the repo has distinct login, signup, user, admin, and visualizer areas.
3. Public/auth flow
- Authentication is centered around NextAuth at src/app/api/auth/[...nextauth]/route.js.
- Public entry points include src/app/web/views/login, signup, and the root page.
- This suggests a flow where users authenticate through NextAuth, then middleware and/or server-side route logic redirect them into role-specific sections.
4. Backend API boundary
- All server endpoints live under src/app/api/controllers/*.
- These are grouped by domain rather than by UI: users, proyects, models_, visualizer, analytics, registeruser, signup, and users/share.
- The API layer appears to be the main backend contract consumed by the client-side actions in the UI.
5. Data access and persistence
- MongoDB is the primary persistence layer, via src/app/api/libs/mongoose.js.
- Data schemas/models are defined in src/app/api/models, including users, proyect, models, company, notes, plansM, and analytics.
- This points to a document-model backend where route handlers call model methods directly rather than going through a separate service tier.
6. External service integrations
- src/app/api/libs/s3.js indicates object storage is used, likely for project/model assets or media uploads.
- src/app/api/libs/mailer.js suggests email notifications or account-related mail flows.
- src/app/api/libs/crypto.js implies password hashing, token handling, or secure identifiers.
- These integrations are part of the backend boundary and are likely invoked from auth, signup, and project/model endpoints.
7. Admin subsystem
- src/app/web/views/admin contains the admin-facing UI, subdivided into:
- Projects: project CRUD, model attachment, file upload/presigned URL flow.
- allCompanies: company/inmobiliaria management.
- analytics: browser, device, OS, and daily usage charts.
- Each area has its own actions, components, layout.jsx, and page.jsx, showing a route-scoped feature structure.
8. Project/model management flow
- The strongest backend/UI coupling is in admin Projects.
- UI actions such as createNewProject, getAllProjects, getModels, addNewModel, generatePresignedUrl, and updateModelFile indicate a workflow where:
- a project is created,
- models are associated,
- files are uploaded through S3 presigned URLs,
- model metadata is updated in the database.
- This is a key architecture boundary: database metadata in MongoDB + binary assets in S3.
9. User-facing feed subsystem
- src/app/web/views/user/feed is the authenticated user dashboard/feed.
- It includes cards, drawers, QR modal, invited-users modal, and a header, plus serverComponents/Cards.server.jsx.
- The presence of both client and server components suggests the feed mixes server-fetched project data with interactive UI elements like QR generation and invitation management.
10. 3D/visualizer subsystem
- src/app/web/views/visualizer is a specialized application area for viewing and interacting with 3D/360 content.
- Components include:
- viewer360, background360, cameras, markers, clickhandler, and toolbar
- tables/history and tables/terrains
- loading/slider/information UI
- This implies a data-driven visualization experience with scene state, markers, camera control, and editable metadata.
11. Visualizer edit mode
- src/app/web/views/visualizer/edit is a separate edit experience from the runtime viewer.
- It has its own utility getConnectionType.js, suggesting environment/device detection or connection-specific rendering behavior.
- Architecturally, this is likely the authoring side of the visualizer, while visualizer/page.jsx is the consumption side.
12. Analytics subsystem
- src/app/api/controllers/analytics and src/app/web/views/admin/analytics form a complete analytics pipeline.
- The UI renders charts for browser, device type, OS, and daily counts, while the API/model layer stores and serves the underlying analytics records.
- This is a read-heavy reporting path separate from the core CRUD workflows.
13. Shared UI system
- Reusable UI primitives are centralized under src/app/web/global_components, including icons, navbar, footer, and alerts.
- This shared layer keeps the admin, user, login, and visualizer views consistent without duplicating basic UI assets.
- Styling is mixed between CSS modules and global Tailwind/PostCSS setup.
14. Project infrastructure and runtime
- The stack is Next.js + React, with route handlers for backend APIs.
- Styling uses Tailwind CSS and PostCSS, plus CSS modules for local component styles.
- The repo includes static assets in public/fonts, public/images, and public/logos, which feed the branded UI and visualizer experiences.
15. How data likely moves through the system
- Users enter through the public pages, authenticate via NextAuth, and are gated by middleware.
- Client views call feature-specific actions, which hit /api/controllers/* routes.
- Those controllers read/write MongoDB models, and for large media they interact with S3.
- Admin analytics and user feed pages consume the same backend data, but present it in different role-specific interfaces.
Main entry points: mongoose.js MongoDB · route.js NextAuth · page.jsx Projects view · Navbar.jsx Shared UI
Components 25
App shell
Next.js entrypoints, providers, and middleware.
- Root layout · Global app layout and composition.
src/app/layout.jsx - Home page · Top-level landing route.
src/app/page.jsx - Providers · App-wide client context setup.
src/app/providers.jsx - Middleware · Pre-routes request gating and access control.
src/middleware.js
Auth & API
Authentication, API routes, shared libs, and data models.
- NextAuth · Authentication endpoint and session flow.
src/app/api/auth/[...nextauth]/route.js - Users API · User CRUD and related operations.
src/app/api/controllers/users/route.js - User detail · Per-user read/update/delete endpoint.
src/app/api/controllers/users/[id]/route.js - User share · Sharing and invitation endpoint.
src/app/api/controllers/users/share/route.js - Projects API · Project CRUD and lifecycle operations.
src/app/api/controllers/proyects/route.js - Models API · Model CRUD and model-file coordination.
src/app/api/controllers/models_/[id]/route.js - Model list · Fetch all models for a project.
src/app/api/controllers/models_/[id]/allmodels/route.js - Visualizer API · Visualizer-specific data endpoint.
src/app/api/controllers/visualizer/[id]/route.js - Analytics API · Analytics ingestion and reporting endpoint.
src/app/api/controllers/analytics/route.js - MongoDB · Mongoose connection and database access.
src/app/api/libs/mongoose.js - S3 storage · Binary asset uploads and presigned URLs.
src/app/api/libs/s3.js - Mailer · Outbound email notifications.
src/app/api/libs/mailer.js - Crypto · Hashing and secure token helpers.
src/app/api/libs/crypto.js - Data models · Project, user, company, notes, plans, and analytics schemas.
src/app/api/models/models.js
Admin
Role-based admin experiences for projects, companies, and analytics.
- Projects view · Admin project management workspace.
src/app/web/views/admin/Projects/page.jsx - Companies view · Company/inmobiliaria management workspace.
src/app/web/views/admin/allCompanies/page.jsx - Analytics view · Admin reporting dashboard.
src/app/web/views/admin/analytics/page.jsx
User
Authenticated user feed and sharing flows.
- User feed · Authenticated dashboard/feed for end users.
src/app/web/views/user/feed/page.jsx
Visualizer
3D/360 viewing and edit experiences.
Shared UI
Reusable UI primitives across the app.
- Shared UI · Global navbar, footer, alerts, and icons.
src/app/web/global_components/navbar/Navbar.jsx
Connections 30
- Middleware → NextAuth: auth gate · Protects and redirects around authenticated routes.
- Root layout → Providers: wraps · Root layout composes application providers.
- Home page → NextAuth: login flow · Public entry can lead into auth flow.
- NextAuth → MongoDB: session data · Auth reads and writes persisted user state.
- NextAuth → Crypto: hash/token · Uses secure credential helpers.
- NextAuth → Mailer: notify · May send account-related emails.
- Users API → MongoDB: read/write · Persists users through MongoDB models.
- User detail → MongoDB: read/write · Per-user persistence operations.
- User share → Mailer: invite email · Sharing flow can trigger email delivery.
- User share → MongoDB: share state · Stores invited/shared user metadata.
- Projects API → MongoDB: read/write · Project CRUD uses document models.
- Projects API → S3 storage: assets · Project workflow can coordinate file storage.
- Models API → MongoDB: read/write · Model metadata persists in MongoDB.
- Models API → S3 storage: uploads · Model files are managed in object storage.
- Model list → MongoDB: query · Returns all models for a project.
- Visualizer API → MongoDB: scene data · Visualizer reads scene/project state.
- Analytics API → MongoDB: events · Stores and aggregates analytics records.
- Data models → MongoDB: schemas · Model definitions are backed by Mongoose.
- Projects view → Projects API: manage · Project UI drives project CRUD endpoints.
- Projects view → Models API: attach models · Project UI manages model metadata and files.
- Projects view → S3 storage: presign · Uploads use presigned S3 URLs.
- Companies view → Users API: admin data · Company management shares backend user/company state.
- Analytics view → Analytics API: reporting · Charts consume analytics data.
- User feed → Users API: profile/share · Feed interacts with user and invitation endpoints.
- User feed → User share: invite · Invitations and QR sharing originate here.
- Viewer → Visualizer API: scene load · Viewer loads visualizer data by id.
- Editor → Visualizer API: authoring · Edit mode persists visualizer changes.
- Shared UI → Projects view: shared chrome · Admin and user screens reuse global UI.
- Shared UI → User feed: shared chrome · Shared navigation and common components.
- Shared UI → Viewer: shared chrome · Visualizer reuses common UI primitives.