# Sendx Tele — reconstructed web application

This project uses the supplied Node.js/Express backend and replaces the original `client/public/index.html` installation redirect with a responsive Sendx Tele web interface. The uploaded archive contains backend routes and only a redirect page—not the original application frontend—so this is a source-based reconstruction rather than a pixel-perfect copy of a missing frontend.

## Included interface and API wiring

- Sign-in and registration using `/api/user/login` and `/api/user/signup`.
- Dashboard connected to `/api/user/get_dashboard`, campaign and contact counts.
- Campaign list, create campaign, schedule calls, and delete campaign using the existing campaign routes.
- Contact list, add contacts, create a phonebook when needed, and delete contacts.
- Agent list, create agent, activate/deactivate agent, and delete agent.
- IVR/device list and an incoming IVR JSON editor that saves to the existing flow update endpoint.
- Call log retrieval by configured device.
- SMS history retrieval and send SMS form using the existing message routes.
- Profile updates and optional password change.
- Responsive navigation, search, loading/error states and status messages.

The full drag-and-drop IVR designer, complete agent/browser-call experience, full campaign log drill-down, and end-to-end payment checkout still need further implementation and integration testing.

## Run locally

1. Install a supported Node.js LTS release and MySQL.
2. Copy `.env.example` to `.env` and replace placeholders with your own values. Never commit `.env`.
3. Configure the MySQL database and create the tables/columns expected by the existing routes. The uploaded ZIP did not include a database schema or migrations.
4. Run `npm install`.
5. Run `npm start`.
6. Open `http://localhost:3010` (or the port configured in `.env`).

## Required integrations

- Database settings and a strong, random `JWTKEY` are required for authentication and persisted data.
- Twilio credentials and a verified caller ID are required for real calls/SMS.
- `OPENAI_API_KEY` is only required for the AI response feature.
- Payment credentials are required only if the associated checkout/payment features are used.

## Security changes in this reconstruction

- The source archive's `.env` file is not included; `.env.example` uses placeholders.
- Removed hardcoded OpenAI/Twilio credentials from the IVR call path; these values now come from environment variables.
- Restricted the special `/api/ivr/initiate-call` endpoint to authenticated users and made it require explicit environment configuration.
- Removed the setting that disabled TLS certificate verification globally.

Because the original source archive included credentials, rotate any credentials that were present in that archive. Before public deployment, review the remaining legacy backend routes, database access controls, token expiry, CORS policy, and authorization checks. Real calling and billing should be tested in sandbox/test mode first.
