How xxvnte/website-chaleco_inteligente works
Project type and purpose
• This is a full-stack monitoring application for a “smart vest” that collects sensor data.
• Frontend: React + Vite + Tailwind CSS (SPA for registration, login, dashboard, user profile).
• Backend: Node.js + Express (REST API with authentication middleware)
• Database: PostgreSQL (stores users, sensor readings).
File structure
• Root: monorepo containing two sub-projects.
• chaleco-inteligente/ → Express server, entry point app.js/index.js, middlewares/auth.js, routes/main.js & user.js.
• chaleco-inteligente-ui/ → React app (src/components, context/AuthContext, assets, config files for Vite/Tailwind).
• Config files:
• Frontend: package.json, vite.config.js, tailwind.config.js, postcss.config.js
• Backend: package.json, .gitignore, Express setup files
README for insights
• Confirms architecture: React frontend on port 5173, Express backend on port 3000, local PostgreSQL.
• Use cases: user registration/login, viewing live sensor data, editing profile.
Main components and interactions
a. Components
1. External Actor: Smart Vest Device (IoT sensor source)
2. Frontend Client (React SPA)
3. Backend API Server (Node.js + Express)
4. Authentication Middleware (JWT/session)
5. Routes/Controllers (main.js, user.js)
6. PostgreSQL Database
b. Relationships / Data Flow
• Smart Vest → HTTP/WebSocket → Backend API → persists to DB
• Browser ←→ React SPA (UI components)
• React SPA → REST calls → Express routes → auth middleware → DB queries
• Backend → Responses (JSON) → React displays sensor readings and user data
c. Architectural patterns & principles
• Separation of concerns: UI layer vs API layer vs Data layer
• Middleware chain in Express for authentication/authorization
• Context provider in React for global auth state
• Component-based UI (DatosSensores, UserForm, UserCard)
d. Key technologies
• Frontend: React, Vite, Tailwind CSS, Context API
• Backend: Node.js, Express, PostgreSQL driver (e.g., node-pg)
• Dev tools: ESLint, PostCSS, Vite