# Implementation Plan - Backend Consolidation

# Goal Description
Consolidate the existing `auth_services` and `business_services` (microservices) into a single monolithic `backend` application to simplify development and deployment. Update the frontend to communicate with this single backend.

## User Review Required
> [!IMPORTANT]
> This is a significant structural change. The existing `backend` subdirectories (`auth_services`, `business_services`) will be effectively merged.
> - **Port Change**: The new backend will run on a single port (proposed: **5000**).
> - **Database**: We assume both services use the same database. If they don't, we need to clarify. (Code suggests they both expect standard DB env vars).

## Proposed Changes

### Backend
#### [NEW] `backend/unified_server` (New Directory for Monolith)
- create `package.json` (merged dependencies).
- create `server.js` (main entry point).
- create `src` structure:
    - `config/db.js` (Unified DB connection)
    - `routes/` (auth.routes.js, business.routes.js, etc.)
    - `controllers/` (auth.controller.js, business specific controllers)
    - `models/` (Sequelize models)
    - `middleware/` (Auth middleware, CORS, etc.)

#### [MODIFY] `backend`
- We will eventually archive or delete `auth_services` and `business_services` after verification.

### Frontend
#### [MODIFY] `frontend1/src/components/api`
- Update `auth.js`, `businessApi.js`, `dashboardApi.js`, `metricsApi.js` to use a single base URL (from environment variable or constant).

## Verification Plan

### Automated Tests
- Since there are no existing test suites mentioned, we will rely on manual verification.

### Manual Verification
1.  **Start the new unified server**: Verify it connects to the database.
2.  **Frontend Integration**:
    -   **Login/Register**: Verify authentication flows work with the new backend.
    -   **Dashboard**: Verify data loading for business widgets.
    -   **Teams**: Verify team management features.
