Project File Structure
Relevant source files
The following files were used as context for generating this wiki page:
The ElmecV2 project is a cross-platform mobile application developed using React Native 0.74 and Expo 51. It follows a modular architecture designed for high scalability, integrating Supabase as a Backend-as-a-Service (BaaS) and utilizing Netlify for web deployment. The file structure is organized to separate UI components, business logic, global state management, and infrastructure automation.
The system's primary purpose is the efficient management of requests, featuring real-time chat capabilities and an integrated industrial calculator. The architecture emphasizes security through Row Level Security (RLS) and robust error handling to ensure production readiness.
Sources: README.md:1-25, VALIDACION-COMPLETA.md:10-30
## Core Directory Organization
The project's root directory contains configuration files for the development environment, build tools, and deployment pipelines. The source code is divided into logical subdirectories based on functional responsibility.
### Source Code Hierarchy
| Directory | Description |
|---|---|
app/ | Contains the main routing logic and application screens using Expo Router. |
components/ | Reusable UI elements, subdivided into ui/ (base components) and forms/ (input handling). |
screens/ | Specific view implementations for auth, admin, and user roles. |
contexts/ | React Context providers for global state like ChatContext. |
store/ | Global state management implemented with Zustand. |
services/ | API interaction layers and Supabase service wrappers. |
utils/ | Helper functions, including the central error handler and logging system. |
supabase/ | Database migrations and backend configuration scripts. |
scripts/ | Automation tools for environment setup and CI/CD validation. |
Sources: README.md:145-165, FIXES-APLICADOS.md:250-265
## Infrastructure and Automation Logic
The project includes an extensive suite of scripts and configuration files to manage the relationship between the mobile frontend and the Supabase backend.
### Deployment and Environment Flow
The application uses a specific flow for environment configuration, ensuring that production keys are isolated from development. The deployment to Netlify is managed through a netlify.toml file which defines the build command and publish directory.
The flow ensures that environment variables like EXPO_PUBLIC_SUPABASE_URL are correctly injected during the build process.
Sources: DEPLOY-NETLIFY.md:20-45, STATUS-DEPLOY.md:15-35
### Setup and Migration Scripts
The scripts/ directory contains tools to automate database provisioning. A key file is scripts/setup-supabase-complete.js, which handles connection testing, user creation, and verification.
// Example of the setup flow found in automation scripts
async function main() {
const connected = await step1_testConnection();
await step2_executeMigrations();
await step3_createUsers();
await step4_verifySetup();
}
Sources: scripts/setup-supabase-complete.js:150-165
## Database Schema and Storage Structure
The backend structure is defined by Supabase migrations, creating a relational schema in PostgreSQL and a bucket system in Supabase Storage.
### Entity Relationship Overview
The system relies on six core tables to manage the lifecycle of a request from creation to resolution and associated chat communications.
### Storage Configuration
A dedicated bucket named request-files is used for managing file uploads.
- Pathing Strategy: Files are stored under
requests/{user_id}/{filename}. - Constraints: Maximum file size of 5MB and a limit of 3 files per request.
Sources: RESUMEN_FINAL.md:120-145, TEST_REPORT.md:250-265
## Real-time and Messaging Architecture
The messaging system is implemented through a combination of the ChatContext.tsx and Supabase Realtime subscriptions.
### Message Synchronization Flow
The architecture uses Postgres Changes events to listen for new records in the messages table and update the local state without requiring a page refresh.
## Technical Specifications Summary
The project utilizes specific versions and configurations as detailed in the technical documentation.
| Feature | Specification |
|---|---|
| Node.js Version | 20.19.4 (Production), 18+ (Dev) |
| Primary Framework | React Native 0.74 / Expo 51 |
| Auth Provider | Supabase Auth (JWT + Refresh Tokens) |
| Routing | Expo Router (File-based) |
| Storage RLS | Owner-based policies (owner_id validation) |
| Message Latency | < 1s (Target real-time performance) |
Sources: DEPLOY-NETLIFY.md:30-40, README.md:65-85, VALIDACION-COMPLETA.md:80-100
## Conclusion
The Project File Structure of ElmecV2 reflects a modern mobile architecture that prioritizes developer experience through automation scripts and system stability through a strictly defined directory hierarchy. By separating concerns into dedicated services and context providers, the project maintains a high quality of code (rated 7.5/10) and is structured for seamless production deployment to platforms like Netlify.