How thedarklee/logisystem-app works
1. This is a Next.js App Router application: the app/ tree contains both the user-facing pages and the server-side API route handlers. That makes the repo a single full-stack codebase rather than a separate frontend/backend split.
2. The product domain looks like an operations and access-control system. The main business areas are access events, cards/badges, users, vehicles, and “envíos” (shipments/dispatches), with dashboards built around those entities.
3. The backend boundary is implemented with Next.js route handlers under app/api/*. These handlers expose CRUD-style endpoints for users, vehicles, cards, and envios, plus specialized endpoints for auth/login, setup, access, and dashboard statistics.
4. Data persistence is centralized in lib/mongodb.ts / lib/mongodb.js and the models/ directory. The presence of model files for Envio, LecturaAcceso, Tarjeta, Usuario, and Vehiculo indicates a MongoDB-based data layer with domain models sitting below the API routes.
5. Access control is its own subsystem. The API exposes app/api/access/manual, app/api/access/rfid, and app/api/access/latest, which suggests the system ingests access events from both manual entry and RFID reads, and also provides the most recent event for the UI or polling.
6. The RFID experience crosses the frontend/backend boundary through components/RFIDListener.tsx. That component likely acts as the client-side bridge that watches for RFID-related state or events and then updates access flows in the UI.
7. The dashboard UI is organized as a protected application area under app/dashboard/, with its own layout at app/dashboard/layout.tsx. This area contains subpages for access, cards, users, vehicles, envíos, and several analytics views.
8. Analytics is split into dedicated dashboard pages and dedicated data endpoints. The API has app/api/dashboard/stats and app/api/dashboards/{envios,operacional,tendencia}, while the UI has corresponding pages plus chart components like _DonutChart, _BarrasChart, and _AreaChart. That suggests the pages fetch aggregated data rather than raw records.
9. The app appears to have a standard authentication boundary: /login is the public entry point for sign-in, and /dashboard is the main authenticated workspace. app/api/auth/login is the server-side login endpoint supporting that flow.
10. There is also a setup API route, which usually means first-run initialization or environment/bootstrap behavior. In architecture terms, that is an administrative bootstrap path separate from normal CRUD operations.
11. The root app/page.tsx is likely a simple landing or redirect page, while the real product surface lives in /login and /dashboard. This keeps the public entry surface small and pushes most interactions into the authenticated area.
12. Overall, the repo is structured around a clean separation: Next.js pages render the UI, route handlers expose domain operations, MongoDB-backed models hold state, and chart components consume aggregated API data for operational reporting. The key diagrammatic boundaries are public vs authenticated UI, UI vs API routes, and domain CRUD vs specialized access/analytics workflows.
Main entry points: manual/route.ts Access API · operacional/route.ts Analytics API · page.tsx Overview · users/route.ts Users API
Components 33
Public UI
Landing and sign-in surface
Dashboard UI
Authenticated application workspace
- Dashboard Shell · Authenticated app layout and navigation frame
app/dashboard/layout.tsx - Overview · Main authenticated landing page
app/dashboard/page.tsx - Access · Access events workspace
app/dashboard/accesos/page.tsx - New Access · Create or capture an access event
app/dashboard/accesos/nuevo/page.tsx - Cards · Badge and card management screen
app/dashboard/tarjetas/page.tsx - Users · User management screen
app/dashboard/usuarios/page.tsx - New User · Create user flow
app/dashboard/usuarios/nuevo/page.tsx - Vehicles · Vehicle management screen
app/dashboard/vehiculos/page.tsx - Fleet Admin · Vehicle management subpage
app/dashboard/vehiculos/gestion/page.tsx - Shipments · Envíos management screen
app/dashboard/envios/page.tsx - Shipment Access · Shipment-related access view
app/dashboard/envios/accesos/page.tsx - Donut Chart · Shipment analytics visualization
app/dashboard/dashboards/envios/_DonutChart.tsx - Bars Chart · Operational analytics visualization
app/dashboard/dashboards/operacional/_BarrasChart.tsx - Area Chart · Trend analytics visualization
app/dashboard/dashboards/tendencia/_AreaChart.tsx
API Routes
Next.js server-side route handlers
- Cards API · CRUD for card records
app/api/cards/route.ts - Users API · CRUD for user records
app/api/users/route.ts - Vehicles API · CRUD for vehicle records
app/api/vehicles/route.ts - Shipments API · CRUD for envío records
app/api/envios/route.ts - Access API · Manual and RFID access event ingestion
app/api/access/manual/route.ts - Latest Access · Returns most recent access event
app/api/access/latest/route.ts - Login API · Authentication endpoint for sign-in
app/api/auth/login/route.ts - Setup API · Bootstrap or first-run initialization
app/api/setup/route.ts - Stats API · Dashboard aggregation endpoint
app/api/dashboard/stats/route.ts - Analytics API · Aggregated analytics for operational dashboards
app/api/dashboards/operacional/route.ts
Data Layer
MongoDB connection and domain models
- MongoDB · Central database connection
lib/mongodb.ts - Envio · Shipment domain model
models/Envio.ts - Access Log · Access event domain model
models/LecturaAcceso.ts - Tarjeta · Card or badge domain model
models/Tarjeta.ts - Usuario · User domain model
models/Usuario.ts - Vehiculo · Vehicle domain model
models/Vehiculo.ts
Other components
- RFID Listener · Client-side RFID bridge for access flows
components/RFIDListener.tsx
Connections 32
- Home → Login: entry · Public users are directed into sign-in
- Login → Login API: auth · Login form submits credentials to the server
- Login API → MongoDB: reads · Authentication reads stored user data
- Dashboard Shell → Overview: wraps · Authenticated layout frames dashboard pages
- Overview → Stats API: loads · Overview pulls summary metrics
- Access → Access API: records · Access UI sends manual or captured events
- New Access → Access API: creates · New access flow posts event data
- Access API → Access Log: stores · Access events persist through the access model
- Latest Access → Access Log: reads · Latest access endpoint queries recent events
- Cards → Cards API: crud · Cards screen uses card CRUD endpoints
- Users → Users API: crud · Users screen uses user CRUD endpoints
- New User → Users API: creates · New user form submits to users API
- Vehicles → Vehicles API: crud · Vehicles screen uses vehicle CRUD endpoints
- Fleet Admin → Vehicles API: manages · Fleet management works through vehicle API
- Shipments → Shipments API: crud · Shipments screen uses envío CRUD endpoints
- Shipment Access → Access API: views · Shipment access view depends on access events
- Overview → Analytics API: analytics · Dashboard landing can consume aggregated analytics
- Donut Chart → Analytics API: data · Shipment chart is driven by aggregated endpoint data
- Bars Chart → Analytics API: data · Operational chart is driven by aggregated endpoint data
- Area Chart → Analytics API: data · Trend chart is driven by aggregated endpoint data
- Cards → Tarjeta: backed by · Card management persists through the card model
- Users → Usuario: backed by · User management persists through the user model
- Vehicles → Vehiculo: backed by · Vehicle management persists through the vehicle model
- Shipments → Envio: backed by · Shipment management persists through the envío model
- Access API → MongoDB: uses · Access handlers use the central database connection
- Cards API → Tarjeta: uses · Card CRUD operates on the card model
- Users API → Usuario: uses · User CRUD operates on the user model
- Vehicles API → Vehiculo: uses · Vehicle CRUD operates on the vehicle model
- Shipments API → Envio: uses · Shipment CRUD operates on the envío model
- Setup API → MongoDB: initializes · Setup route likely bootstraps persisted state
- RFID Listener → Latest Access: polls · Client-side RFID bridge can watch latest access state
- RFID Listener → Access API: triggers · RFID events feed into access ingestion flows