How uniestetic/conectando-ph works
1. This is a Next.js App Router application in TypeScript, organized around route segments in app/. The repo is structured more like a role-based product shell than a single feature app: admin, residentes, and porteria are separate user-facing domains, with auth/login as the entry point.
2. The main architectural boundary is between route/page components and the service layer. Pages and UI components live under app/..., while domain data access is centralized under app/services/* and app/utils/apiClient.ts. That makes the app mostly a frontend orchestration layer over backend APIs.
3. Authentication is handled through NextAuth. The auth endpoint lives at app/api/auth/[...nextauth], with shared auth configuration in auth.config.ts. Login/logout UI is under app/auth/login, and middleware.ts likely protects role-based routes and redirects unauthenticated users.
4. Role-based navigation is a key design axis. The app has distinct areas for administrators, residents, and security/front-desk staff:
- app/admin/* for management CRUD
- app/residentes/* for resident self-service
- app/porteria/* for gate/security workflows
This is the clearest architectural partition in the repo.
5. The admin subsystem covers master data and operational back-office features: copropiedades, unidades, usuarios, roles, asambleas, comunicados, documentos, formación, pqrs, porteria, and visitantes. Most of these routes have create/edit subpages, indicating a CRUD-heavy domain model with reusable forms and listing screens.
6. Property context is an important cross-cutting concept. Components such as PropertySelector, HeaderPropertySelector, PropertyManager, and the hook usePropertySelector suggest the app operates across multiple properties/copropiedades and needs the current property to scope data and UI behavior.
7. The assembly / meeting room is the most specialized subsystem. Under app/residentes/room there is a dedicated AssemblyInterface plus cards for agenda, attendance, messages, users online, shared files, request-to-speak, video, and recording controls. This is a real-time collaboration area rather than a standard form-based screen.
8. Real-time collaboration is backed by LiveKit and socket-style messaging. app/services/livekit.service.ts, app/actions/livekit.ts, app/services/socket.service.tsx, and hooks like useVotes and useVotingQuestions indicate the assembly room coordinates media, chat/events, voting, and participant state through realtime channels.
9. File and document handling is also first-class. There is an upload API route at app/api/uploads/route.ts, static/public storage under public/uploads, and document-oriented sections in admin and resident areas. This suggests the app moves documents and media between user actions, backend APIs, and uploaded asset storage.
10. The service layer is domain-based and maps closely to business entities: assemblies, agenda, attendances, announcements, votes, voting questions, users, roles, units, unit assignments, PHs/copropiedades, and Q&A entries. This layer is the main integration boundary to backend data sources and keeps page components relatively thin.
11. Shared presentation is split between app/components and app/ui. app/components holds app-specific reusable widgets like selectors, cards, headers, modals, and toggles; app/ui contains more atomic design-system-style primitives, global styles, fonts, and generic skeleton/loading components.
12. Types are centralized in app/types, with one declaration file per domain. That implies the app relies on explicit domain models rather than inferred API shapes, which is useful for drawing the data model side of the architecture diagram.
13. Infrastructure-wise, this is a browser-facing Next.js frontend with server-side route handlers/actions where needed, role-aware routing, backend API integration, realtime services for assemblies, and asset uploads. It does not appear to be a standalone backend; instead it sits as the presentation and interaction layer over external application services.
Main entry points: admin/page.tsx Admin area · app/page.tsx Next.js app · auth.service.ts Service layer · residentes/page.tsx Residents area
Components 18
App shell
Next.js routing, auth entrypoints, and shared frontend composition.
- Next.js app · Top-level browser-facing application shell and route composition.
app/page.tsx - Auth flow · Login/logout entry point and NextAuth endpoint/configuration.
app/auth/login/page.tsx - Route guard · Protects routes and handles redirects for unauthenticated or mismatched roles.
middleware.ts
Role domains
User-facing areas separated by role and workflow.
- Admin area · CRUD-heavy management shell for properties, users, assemblies, documents, and operations.
app/admin/page.tsx - Properties · Property and unit management with create/edit flows and property-scoped data.
app/admin/copropiedades/page.tsx - Users & roles · Administrative management of users, roles, and assignments.
app/admin/usuarios/page.tsx - Assemblies · Assembly setup, agenda building, and voting-question configuration.
app/admin/asambleas/page.tsx - Content ops · Back-office sections for communicados, documentos, formacion, pqrs, porteria, and visitantes.
app/admin/comunicados/page.tsx - Residents area · Resident-facing portal for documents, notices, visitor access, PQRS, and the assembly room.
app/residentes/page.tsx - Assembly room · Specialized live meeting interface with agenda, attendance, chat, voting, media, and recording controls.
app/residentes/room/page.tsx - Porteria area · Front-desk and gate workflows for visitors, citofonia, casillero, and notices.
app/porteria/page.tsx
Platform layer
Shared services, realtime integrations, and domain types.
- Property context · Shared property selection and header management that scopes the current copropiedad across the app.
app/components/PropertySelector.tsx - Shared UI · App-specific widgets, headers, modals, and general presentation primitives.
app/components/Providers.tsx - Service layer · Centralized data-access layer for assemblies, users, roles, units, properties, votes, and auth.
app/services/auth.service.ts - Realtime layer · LiveKit and socket-based coordination for live assembly media and participant events.
app/services/livekit.service.ts - Uploads · Upload route and public asset storage for documents, images, and media.
app/api/uploads/route.ts - Domain types · Centralized TypeScript declarations for entities such as assemblies, users, roles, votes, and properties.
app/types/definitions.ts - API client · Shared client utilities used by the service layer to reach backend APIs.
app/utils/apiClient.ts
Connections 23
- Next.js app → Auth flow: entry · Authentication is the main public entry path.
- Next.js app → Admin area: routes · Top-level role-based admin branch.
- Next.js app → Residents area: routes · Top-level resident branch.
- Next.js app → Porteria area: routes · Top-level porteria branch.
- Route guard → Admin area: protects · Guards admin routes and redirects as needed.
- Route guard → Residents area: protects · Guards resident routes and redirects as needed.
- Route guard → Porteria area: protects · Guards security/front-desk routes and redirects as needed.
- Auth flow → Service layer: auth api · Login/session handling relies on the service layer.
- Admin area → Properties: manages · Property and unit CRUD lives under the admin shell.
- Admin area → Users & roles: manages · User and role administration lives under the admin shell.
- Admin area → Assemblies: manages · Assembly setup and voting configuration.
- Admin area → Content ops: manages · Operational content and support sections.
- Residents area → Assembly room: hosts · The assembly room is the most specialized resident experience.
- Residents area → Property context: scoped by · Resident views depend on the selected property.
- Porteria area → Property context: scoped by · Gate workflows are also property-scoped.
- Shared UI → Property context: uses · Shared UI includes property selectors and header controls.
- Shared UI → Next.js app: composes · Reusable widgets support the main app shell and pages.
- Service layer → API client: uses · Services centralize API access through the shared client.
- Service layer → Domain types: typed by · Domain models are defined centrally in TypeScript declarations.
- Assembly room → Realtime layer: coordinates · Live assembly interaction depends on realtime media and events.
- Assembly room → Service layer: loads data · Room state, agenda, votes, and attendance flow through services.
- Uploads → Service layer: supports · Upload handling complements document and media workflows.
- Content ops → Uploads: stores · Documents and assets move through upload handling.