Prerequisites
Before you begin, ensure you have the following installed on your system:- Node.js (v18 or higher) - Download here
- npm, yarn, or pnpm package manager
- Git for version control
- A Supabase account - Sign up here
This application requires a Supabase project with the proper database schema and Row Level Security (RLS) policies configured. See the Database Setup guide for details.
Installation Steps
Install Dependencies
Install all required dependencies using your preferred package manager:This will install all the dependencies listed in
package.json, including:- React 19 and React Router for the frontend
- @supabase/supabase-js for database and authentication
- Tailwind CSS v4 and Radix UI for styling and components
- Vite for fast development and building
Configure Environment Variables
Create a
.env file in the root directory of your project and add your Supabase credentials:.env
Getting Your Supabase Credentials
- Go to your Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the Project URL and anon/public key
The application validates these environment variables on startup. If they’re missing, you’ll see an error: “Missing Supabase environment variables. Check .env file.” (see
src/lib/supabase.ts:7)Start the Development Server
Launch the Vite development server:The application will start on
http://localhost:5173 by default. The development server includes:- Hot Module Replacement (HMR) for instant updates
- Network access enabled to test on other devices on your network
Verify the Setup
Open your browser and navigate to
http://localhost:5173. You should see the login page of the CEDIS Pedidos application.On first run, you’ll need to create a user account or use superadmin credentials. Superadmin accounts are auto-approved based on the email list in
src/context/AuthContext.tsx:33-36.Quick Code Overview
Here’s how the application initializes and connects to Supabase:Supabase Client Configuration
src/lib/supabase.ts
Application Entry Point
src/main.tsx
Authentication Context
The app uses a customAuthContext to manage user sessions and role-based access:
src/context/AuthContext.tsx
Available Scripts
The following scripts are available inpackage.json:
| Script | Command | Description |
|---|---|---|
dev | vite | Start the development server with HMR |
build | tsc -b && vite build | Type-check and build for production |
lint | eslint . | Run ESLint to check code quality |
preview | vite preview | Preview the production build locally |
Testing Your Setup
To verify everything is working correctly:Check the Console
Open your browser’s developer console (F12). You should see no errors related to Supabase connection or environment variables.
Test Authentication
Try logging in with a test account or creating a new user. The authentication flow should work without errors.
Common Issues
Environment Variables Not Found
Environment Variables Not Found
Error:
Missing Supabase environment variables. Check .env file.Solution:- Ensure your
.envfile is in the project root directory - Verify the variable names start with
VITE_prefix - Restart the development server after creating/modifying
.env
Port Already in Use
Port Already in Use
Error:
Port 5173 is already in useSolution:- Kill the process using port 5173
- Or specify a different port:
vite --port 3000
Supabase Connection Errors
Supabase Connection Errors
Error: Authentication or database errorsSolution:
- Verify your Supabase credentials are correct
- Ensure your Supabase project is active
- Check that RLS policies are properly configured
- Verify the database schema matches the expected structure
Next Steps
Now that you have CEDIS Pedidos running locally, explore these guides:Architecture Overview
Understand the application structure and design patterns
Database Setup
Configure your Supabase database schema and RLS policies
Authentication Guide
Learn about the role-based authentication system
Database Tables
Explore the database schema and data models
Need help? Check out the GitHub repository or review the source code for more details.