# juangui78/myviewproyect architecture

> Architecture diagram of the GitHub repository juangui78/myviewproyect, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/juangui78/myviewproyect
- Repository: https://github.com/juangui78/myviewproyect

## Overview

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: [`src/app/api/libs/mongoose.js`](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/mongoose.js) (MongoDB), [`src/app/api/auth/[...nextauth]/route.js`](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/auth/[...nextauth]/route.js) (NextAuth), [`src/app/web/views/admin/Projects/page.jsx`](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/Projects/page.jsx) (Projects view), [`src/app/web/global_components/navbar/Navbar.jsx`](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/global_components/navbar/Navbar.jsx) (Shared UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app_shell["App shell"]
  node_layout["Root layout<br/>next app shell<br/>[layout.jsx]"]
  node_home_page["Home page<br/>entry page<br/>[page.jsx]"]
  node_providers["Providers<br/>[providers.jsx]"]
  node_middleware["Middleware<br/>route gate<br/>[middleware.js]"]
end

subgraph group_auth_backend["Auth & API"]
  node_nextauth["NextAuth<br/>auth route<br/>[route.js]"]
  node_api_users["Users API<br/>controller<br/>[route.js]"]
  node_api_user_id["User detail<br/>controller<br/>[route.js]"]
  node_api_share["User share<br/>controller<br/>[route.js]"]
  node_api_projects["Projects API<br/>controller<br/>[route.js]"]
  node_api_models["Models API<br/>controller<br/>[route.js]"]
  node_api_model_list["Model list<br/>controller<br/>[route.js]"]
  node_api_visualizer["Visualizer API<br/>controller<br/>[route.js]"]
  node_api_analytics["Analytics API<br/>controller<br/>[route.js]"]
  node_mongoose[("MongoDB<br/>db connector<br/>[mongoose.js]")]
  node_s3[("S3 storage<br/>object storage<br/>[s3.js]")]
  node_mailer["Mailer<br/>email service<br/>[mailer.js]"]
  node_crypto["Crypto<br/>security util<br/>[crypto.js]"]
  node_models["Data models<br/>mongoose models<br/>[models.js]"]
end

subgraph group_admin_ui["Admin"]
  node_admin_projects["Projects view<br/>admin ui<br/>[page.jsx]"]
  node_admin_companies["Companies view<br/>admin ui<br/>[page.jsx]"]
  node_admin_analytics["Analytics view<br/>admin ui<br/>[page.jsx]"]
end

subgraph group_user_ui["User"]
  node_user_feed["User feed<br/>user ui<br/>[page.jsx]"]
end

subgraph group_visualizer_ui["Visualizer"]
  node_visualizer_page["Viewer<br/>visualizer ui<br/>[page.jsx]"]
  node_visualizer_edit["Editor<br/>visualizer ui<br/>[page.jsx]"]
end

subgraph group_shared_ui["Shared UI"]
  node_global_components["Shared UI<br/>ui kit<br/>[Navbar.jsx]"]
end

node_middleware -->|"auth gate"| node_nextauth
node_layout -->|"wraps"| node_providers
node_home_page -.->|"login flow"| node_nextauth
node_nextauth -->|"session data"| node_mongoose
node_nextauth -->|"hash/token"| node_crypto
node_nextauth -.->|"notify"| node_mailer
node_api_users -->|"read/write"| node_mongoose
node_api_user_id -->|"read/write"| node_mongoose
node_api_share -.->|"invite email"| node_mailer
node_api_share -->|"share state"| node_mongoose
node_api_projects -->|"read/write"| node_mongoose
node_api_projects -.->|"assets"| node_s3
node_api_models -->|"read/write"| node_mongoose
node_api_models -->|"uploads"| node_s3
node_api_model_list -->|"query"| node_mongoose
node_api_visualizer -->|"scene data"| node_mongoose
node_api_analytics -->|"events"| node_mongoose
node_models -->|"schemas"| node_mongoose
node_admin_projects -->|"manage"| node_api_projects
node_admin_projects -->|"attach models"| node_api_models
node_admin_projects -->|"presign"| node_s3
node_admin_companies -.->|"admin data"| node_api_users
node_admin_analytics -->|"reporting"| node_api_analytics
node_user_feed -->|"profile/share"| node_api_users
node_user_feed -->|"invite"| node_api_share
node_visualizer_page -->|"scene load"| node_api_visualizer
node_visualizer_edit -->|"authoring"| node_api_visualizer
node_global_components -.->|"shared chrome"| node_admin_projects
node_global_components -.->|"shared chrome"| node_user_feed
node_global_components -.->|"shared chrome"| node_visualizer_page

click node_layout "https://github.com/juangui78/myviewproyect/blob/master/src/app/layout.jsx"
click node_home_page "https://github.com/juangui78/myviewproyect/blob/master/src/app/page.jsx"
click node_providers "https://github.com/juangui78/myviewproyect/blob/master/src/app/providers.jsx"
click node_middleware "https://github.com/juangui78/myviewproyect/blob/master/src/middleware.js"
click node_nextauth "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/auth/[...nextauth]/route.js"
click node_api_users "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/users/route.js"
click node_api_user_id "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/users/[id]/route.js"
click node_api_share "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/users/share/route.js"
click node_api_projects "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/proyects/route.js"
click node_api_models "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/models_/[id]/route.js"
click node_api_model_list "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/models_/[id]/allmodels/route.js"
click node_api_visualizer "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/visualizer/[id]/route.js"
click node_api_analytics "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/analytics/route.js"
click node_mongoose "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/mongoose.js"
click node_s3 "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/s3.js"
click node_mailer "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/mailer.js"
click node_crypto "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/crypto.js"
click node_models "https://github.com/juangui78/myviewproyect/blob/master/src/app/api/models/models.js"
click node_admin_projects "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/Projects/page.jsx"
click node_admin_companies "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/allCompanies/page.jsx"
click node_admin_analytics "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/analytics/page.jsx"
click node_user_feed "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/user/feed/page.jsx"
click node_visualizer_page "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/visualizer/page.jsx"
click node_visualizer_edit "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/visualizer/edit/page.jsx"
click node_global_components "https://github.com/juangui78/myviewproyect/blob/master/src/app/web/global_components/navbar/Navbar.jsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_layout,node_home_page,node_providers,node_middleware toneBlue
class node_nextauth,node_api_users,node_api_user_id,node_api_share,node_api_projects,node_api_models,node_api_model_list,node_api_visualizer,node_api_analytics,node_mongoose,node_s3,node_mailer,node_crypto,node_models toneAmber
class node_admin_projects,node_admin_companies,node_admin_analytics toneMint
class node_user_feed toneRose
class node_visualizer_page,node_visualizer_edit toneIndigo
class node_global_components toneTeal
```

## Components

### App shell

Next.js entrypoints, providers, and middleware.

- [Root layout](https://github.com/juangui78/myviewproyect/blob/master/src/app/layout.jsx): next app shell · Global app layout and composition. · `src/app/layout.jsx`
- [Home page](https://github.com/juangui78/myviewproyect/blob/master/src/app/page.jsx): entry page · Top-level landing route. · `src/app/page.jsx`
- [Providers](https://github.com/juangui78/myviewproyect/blob/master/src/app/providers.jsx): client providers · App-wide client context setup. · `src/app/providers.jsx`
- [Middleware](https://github.com/juangui78/myviewproyect/blob/master/src/middleware.js): route gate · Pre-routes request gating and access control. · `src/middleware.js`

### Auth & API

Authentication, API routes, shared libs, and data models.

- [NextAuth](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/auth/[...nextauth]/route.js): auth route · Authentication endpoint and session flow. · `src/app/api/auth/[...nextauth]/route.js`
- [Users API](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/users/route.js): controller · User CRUD and related operations. · `src/app/api/controllers/users/route.js`
- [User detail](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/users/[id]/route.js): controller · Per-user read/update/delete endpoint. · `src/app/api/controllers/users/[id]/route.js`
- [User share](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/users/share/route.js): controller · Sharing and invitation endpoint. · `src/app/api/controllers/users/share/route.js`
- [Projects API](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/proyects/route.js): controller · Project CRUD and lifecycle operations. · `src/app/api/controllers/proyects/route.js`
- [Models API](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/models_/[id]/route.js): controller · Model CRUD and model-file coordination. · `src/app/api/controllers/models_/[id]/route.js`
- [Model list](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/models_/[id]/allmodels/route.js): controller · Fetch all models for a project. · `src/app/api/controllers/models_/[id]/allmodels/route.js`
- [Visualizer API](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/visualizer/[id]/route.js): controller · Visualizer-specific data endpoint. · `src/app/api/controllers/visualizer/[id]/route.js`
- [Analytics API](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/controllers/analytics/route.js): controller · Analytics ingestion and reporting endpoint. · `src/app/api/controllers/analytics/route.js`
- [MongoDB](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/mongoose.js): db connector · Mongoose connection and database access. · `src/app/api/libs/mongoose.js`
- [S3 storage](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/s3.js): object storage · Binary asset uploads and presigned URLs. · `src/app/api/libs/s3.js`
- [Mailer](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/mailer.js): email service · Outbound email notifications. · `src/app/api/libs/mailer.js`
- [Crypto](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/libs/crypto.js): security util · Hashing and secure token helpers. · `src/app/api/libs/crypto.js`
- [Data models](https://github.com/juangui78/myviewproyect/blob/master/src/app/api/models/models.js): mongoose 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](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/Projects/page.jsx): admin ui · Admin project management workspace. · `src/app/web/views/admin/Projects/page.jsx`
- [Companies view](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/allCompanies/page.jsx): admin ui · Company/inmobiliaria management workspace. · `src/app/web/views/admin/allCompanies/page.jsx`
- [Analytics view](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/admin/analytics/page.jsx): admin ui · Admin reporting dashboard. · `src/app/web/views/admin/analytics/page.jsx`

### User

Authenticated user feed and sharing flows.

- [User feed](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/user/feed/page.jsx): user ui · Authenticated dashboard/feed for end users. · `src/app/web/views/user/feed/page.jsx`

### Visualizer

3D/360 viewing and edit experiences.

- [Viewer](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/visualizer/page.jsx): visualizer ui · Runtime 3D/360 viewer entry. · `src/app/web/views/visualizer/page.jsx`
- [Editor](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/views/visualizer/edit/page.jsx): visualizer ui · Visualizer edit/authoring entry. · `src/app/web/views/visualizer/edit/page.jsx`

### Shared UI

Reusable UI primitives across the app.

- [Shared UI](https://github.com/juangui78/myviewproyect/blob/master/src/app/web/global_components/navbar/Navbar.jsx): ui kit · Global navbar, footer, alerts, and icons. · `src/app/web/global_components/navbar/Navbar.jsx`

## Connections

- 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.
