Prerequisites
Before installing CEMAC, ensure you have the following:- Node.js version 18 or higher
- npm (included with Node.js)
- Git for version control
- Firebase account for authentication and database services
CEMAC uses Firebase for authentication and Firestore for the database. You’ll need to create a Firebase project and obtain configuration credentials.
Installation steps
Install dependencies
Install all required npm packages:This will install the following core dependencies:
Configure Firebase
Create a Firebase project at console.firebase.google.com and enable:
- Authentication - Enable Email/Password authentication
- Cloud Firestore - Create a Firestore database
Set up environment variables
Create a
.env file in the root directory with your Firebase configuration:.env
Start the development server
Run the development server with automatic restart on file changes:Or start the production server:The server will start on
http://localhost:3000 (or your configured PORT).server/server.js
Project structure
Understand the CEMAC codebase organization:Available routes
Once installed, CEMAC provides these routes:Frontend routes
GET /- Login page (admin)GET /views/employee-login.html- Employee login pageGET /views/dashboard/inicio.html- Main dashboardGET /views/dashboard/inventario.html- Inventory managementGET /views/dashboard/ventas.html- Sales trackingGET /views/dashboard/alertas.html- Alerts and notificationsGET /views/dashboard/analisis.html- Analytics dashboard
API routes
routes/authRoutes.js
CEMAC uses a hybrid architecture: the frontend runs on your local server, while the backend API is deployed on Vercel at
https://cemac-api.vercel.app/.Development workflow
Running in development mode
nodemon to automatically restart the server when you make changes to any file.
Running in production mode
Environment configuration
CEMAC automatically detects the environment based on the hostname:public/js/services/authService.js
Local development
When running onlocalhost, CEMAC uses the local server as a proxy to the external API.
Production deployment
In production, CEMAC communicates directly with the Vercel-deployed API.Database setup
CEMAC uses Cloud Firestore with the following collections:users- User accounts and profilesproducts- Inventory itemssales- Transaction recordscustomers- Customer informationcategories- Product categoriesbrands- Product brandssuppliers- Supplier informationalerts- System notifications and alerts
Troubleshooting
Port already in use
Port already in use
If port 3000 is already in use, either:
- Stop the process using port 3000
- Change the PORT in your
.envfile
Firebase authentication errors
Firebase authentication errors
Verify that:
- Your Firebase credentials in
.envare correct - Email/Password authentication is enabled in Firebase Console
- Firebase project is active and not suspended
API connection timeout
API connection timeout
If you see timeout errors when logging in:
- Check that
https://cemac-api.vercel.app/is accessible - Verify your internet connection
- Check if the API is experiencing downtime
Missing dependencies
Missing dependencies
If you encounter module errors, try:
Next steps
Quickstart guide
Learn how to use CEMAC for the first time.
API reference
Explore the complete API documentation.
User management
Set up user accounts and permissions.
Deployment guide
Deploy CEMAC to production.