# Office365 V2 Project Guide

## Purpose

This is a fresh full-stack rebuild of the old static Microsoft 365 subscription site. The old ZIP remains a reference only.

## Main Flow

1. Customer views plans on the homepage.
2. Customer selects a plan.
3. Selected plan is saved in browser storage for the preview and checkout flow.
4. Checkout submits customer/order data to the Express backend.
5. Backend stores customer, order, lead, status history, and email logs in SQLite.
6. Backend sends customer/admin notifications through Nodemailer.
7. Admin dashboard reviews and updates orders.

## Important Security Decisions

- No EmailJS.
- No card number, expiry, or CVV fields.
- No raw payment data stored in SQLite.
- Admin dashboard uses server-side session auth.
- Email sends from backend only.

## Key Locations

- Frontend app: `client/src/`
- Backend API: `server/`
- SQLite schema: `server/db/schema.sql`
- Email templates: `server/email-templates/`
- Admin CRM pages: `client/src/pages/AdminDashboard.jsx` and `client/src/pages/AdminOrderDetail.jsx`

## API Summary

- `GET /api/plans`
- `GET /api/plans/:id`
- `POST /api/orders`
- `GET /api/orders/:orderNumber`
- `POST /api/admin/login`
- `POST /api/admin/logout`
- `GET /api/admin/me`
- `GET /api/admin/stats`
- `GET /api/admin/orders`
- `GET /api/admin/orders/:id`
- `PATCH /api/admin/orders/:id/status`
- `PATCH /api/admin/orders/:id/notes`
- `GET /api/admin/leads`
