How joseegarciaa/kryotec-admin works
Project Type and Purpose
• Full-stack web application following the MVC pattern.
• Frontend: React + TypeScript + Vite + TailwindCSS
• Backend: Node.js + Express
• Data storage: relational database (configured in src/server/config/db.js)
• Special feature: Excel import/export workflow for “Inventario Prospectos.”
File Structure
• Top-level config: Vite, Tailwind, ESLint, TypeScript, Railway deploy config.
• src/views: Presentation (React Views, UI components, routing, contexts).
• src/controllers: Client-side controllers tying models to views, plus React hooks.
• src/models: Business logic & types.
• src/services/api.ts: Frontend HTTP client to backend.
• src/server: Express application
• config (db.js), index.js (server bootstrap), db.js (connection helper)
• routes (Express routers)
• services (business logic on server side)
• utils (cache.js)
• Misc: assets, utils (date, excel template), package.json, .env.production
Key Insights from README
• MVC structure is explicit: Model, View, Controller separation.
• Data-flow: View → Controller → Model → API → Server routes → Services → DB.
• Excel import on prospectos with a dedicated backend endpoint.
• React Contexts (AuthContext, ThemeContext) for cross-cutting state.
Main Components & Their Relationships
A. Frontend (Browser)
1. UI Layer (Views & Components)
• src/views/… (LoginView, DashboardView, subviews + shared UI)
• Layout & navigation components under src/components/layout & navigation
2. Presentation Logic (React Contexts & Hooks)
• AuthContext, ThemeContext under src/views/contexts
• useXController hooks under src/controllers/hooks
3. Controller Layer (src/controllers/*.ts)
• AuthController, ThemeController, ProspectoController, etc.
• Coordinates view events with model calls.
4. Model Layer (src/models/*.ts)
• Defines business logic & data structures.
5. API Client (src/services/api.ts)
• Wraps fetch/axios, exposes REST methods for entities.
B. Backend (Node/Express)
1. HTTP Server (src/server/index.js)
2. Routing Layer (src/server/routes/*.js)
• clientesProspectosRoutes, sugerenciasRoutes, etc.
3. Service Layer (src/server/*Service.js)
• clientesProspectosService, userService, tenantService, etc.
• Implements business logic, enforces validation and Excel import logic.
4. Data Access Layer
• src/server/config/db.js + src/server/db.js for DB connection
5. Utilities
• src/server/utils/cache.js for in-memory caching
6. Database
• Relational DB (PostgreSQL or similar)
C. External/Deployment
• Railway deployment (railway.json)
• Excel file I/O (via src/utils/excelTemplate.ts)
Architectural Patterns and Principles
• MVC (clear separation of concerns)
• Layered Architecture (UI → Controllers → Models → API → Server → DB)
• Context/Provider pattern for cross-cutting state (Auth, Theme)
• Hook-based controllers for view integration
• RESTful API design with modular Express routers
• Utility-based caching for performance