Skip to content

Commit c98a831

Browse files
committed
feat: improve docs
1 parent baf020c commit c98a831

5 files changed

Lines changed: 11 additions & 23 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ These are intentional extras beyond the assessment requirements:
4141

4242
- **Live demo** at custom domains (Cloudflare Pages + Railway).
4343
- **CI → gated deploy pipeline** - production deploy only fires after CI succeeds on `main` via a `workflow_run` trigger.
44-
- **A4 print-to-PDF** without a PDF library - pure CSS `@media print` swap. See [`frontend/src/features/invoices/detail/InvoicePrintDocument.tsx`](./frontend/src/features/invoices/detail/InvoicePrintDocument.tsx).
44+
- **A4 print-to-PDF** without a PDF library - pure CSS `@media print` swap. See [`frontend/src/features/invoices/detail/components/InvoicePrintDocument.tsx`](./frontend/src/features/invoices/detail/components/InvoicePrintDocument.tsx).
4545
- **Runtime Zod validation** at the frontend API boundary - every response is parsed; schema drift fails loudly. See [`frontend/src/api/invoices.schema.ts`](./frontend/src/api/invoices.schema.ts).
4646
- **Summary dashboard endpoint** - `GET /invoices/summary` returns aggregated totals/counts respecting the same filters as `GET /invoices`. Powers the invoice list tiles.
4747
- **`Decimal.js` precision arithmetic** - money math never touches IEEE-754 floats. See [`backend/src/invoices/domain/invoice-calculation.ts`](./backend/src/invoices/domain/invoice-calculation.ts).
@@ -146,6 +146,7 @@ Docker Compose reads the root `.env` for container wiring and `backend/.env` for
146146
| `JWT_SECRET` | Secret for signing JWT tokens (min 32 chars) | - |
147147
| `JWT_EXPIRES_IN` | Token expiry in seconds | `3600` |
148148
| `CORS_ORIGIN` | Comma-separated allowlist of permitted origins | `http://localhost:3000,https://simpleinvoice.khangtran.dev` |
149+
| `VITE_API_URL` | Base URL for frontend API calls (backend API) | `http://localhost:4000` |
149150

150151
---
151152

‎backend/.env.example‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
NODE_ENV=development
33
PORT=4000
44
# Comma-separated allowlist of origins permitted by CORS.
5-
CORS_ORIGIN=http://localhost:3000,https://simpleinvoice.khangtran.dev
5+
CORS_ORIGIN=http://localhost:3000,http://localhost:5173,https://simpleinvoice.khangtran.dev
66

77
# Database - host is 'localhost' for local dev; overridden to 'postgres' in Docker
88
POSTGRES_HOST=localhost

‎backend/README.md‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,6 @@ Database constraints protect invariants at the storage boundary even if a future
145145

146146
---
147147

148-
## Reviewer Quick Start
149-
150-
See the [root README](../README.md) for full setup instructions (Docker or local). This section highlights backend-specific endpoints and credentials.
151-
152-
### Default Credentials
153-
154-
Seeded automatically by `npm run seed`:
155-
156-
```
157-
Email: reviewer@simpleinvoice.local
158-
Password: Password123!
159-
```
160-
161148
### Backend Endpoints
162149

163150
| Resource | URL |
@@ -445,5 +432,4 @@ erDiagram
445432
- **Overdue is derived, not persisted.** The database stores only `Draft`, `Pending`, and `Paid`. `Overdue` is computed at read time when `status != Paid AND dueDate < today`. No background job is needed.
446433
- **No refresh tokens.** The access token is the only credential. Token refresh is out of scope for this assessment.
447434
- **No role-based authorization.** All authenticated users have the same permissions. RBAC is out of scope.
448-
- **No email delivery or payment integration.** Invoice creation and status transitions are data-only operations.
449435
- **Customer is embedded on the invoice.** Customer data (name, email, mobile, address) is stored as columns on `invoices` rather than a separate `customers` table. Invoices are self-contained records; there is no shared customer identity across invoices.

‎backend/src/config/app.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Joi from 'joi';
33

44
const DEFAULT_CORS_ORIGINS = [
55
'http://localhost:3000',
6+
'http://localhost:5173',
67
'https://simpleinvoice.khangtran.dev',
78
];
89
const DEFAULT_CORS_ORIGIN = DEFAULT_CORS_ORIGINS.join(',');

‎frontend/README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ React 19 + TypeScript + Vite frontend for the SimpleInvoice assessment applicati
88

99
**What to look for:**
1010

11-
- **Protected Routes & Authentication** - Login redirects to invoice list on success; all invoice routes require valid JWT; logout clears session. See `auth-context.tsx`, `ProtectedRoute.tsx`.
12-
- **Invoice List** - Paginated, searchable, filterable by status (Draft/Pending/Paid/Overdue), sortable by date/amount. List state lives in URL query params. See `InvoiceListPage.tsx`, `use-invoice-list-query.ts`.
13-
- **Invoice Detail** - Full invoice information, line items, totals, payment status. Includes a **print-to-PDF** feature that produces an A4 document without external dependencies. See `InvoiceDetailPage.tsx`, `InvoicePrintDocument.tsx`.
14-
- **Create Invoice** - Multi-field form with real-time validation and a live preview panel. Backend validates totals; frontend shows preview. One line item per assessment spec. See `CreateInvoiceForm.tsx`, `createInvoiceSchema.ts`.
15-
- **Runtime Response Validation** - Zod schemas validate all API responses at unsafe boundaries (login, invoice list/detail, create). Parsing errors are caught and logged. See `invoices.schema.ts`, `auth.schema.ts`, `parse-api-response.ts`.
11+
- **Protected Routes & Authentication** - Login redirects to invoice list on success; all invoice routes require valid JWT; logout clears session. See [`src/features/auth/auth-context.tsx`](./src/features/auth/auth-context.tsx), [`src/features/auth/components/ProtectedRoute.tsx`](./src/features/auth/components/ProtectedRoute.tsx).
12+
- **Invoice List** - Paginated, searchable, filterable by status (Draft/Pending/Paid/Overdue), sortable by date/amount. List state lives in URL query params. See [`src/features/invoices/list/InvoiceListPage.tsx`](./src/features/invoices/list/InvoiceListPage.tsx), [`src/features/invoices/list/invoice-list-query.schema.ts`](./src/features/invoices/list/invoice-list-query.schema.ts).
13+
- **Invoice Detail** - Full invoice information, line items, totals, payment status. Includes a **print-to-PDF** feature that produces an A4 document without external dependencies. See [`src/features/invoices/detail/InvoiceDetailPage.tsx`](./src/features/invoices/detail/InvoiceDetailPage.tsx), [`src/features/invoices/detail/components/InvoicePrintDocument.tsx`](./src/features/invoices/detail/components/InvoicePrintDocument.tsx).
14+
- **Create Invoice** - Multi-field form with real-time validation and a live preview panel. Backend validates totals; frontend shows preview. One line item per assessment spec. See [`src/features/invoices/create/CreateInvoiceForm.tsx`](./src/features/invoices/create/CreateInvoiceForm.tsx), [`src/features/invoices/schema/create-invoice.schema.ts`](./src/features/invoices/schema/create-invoice.schema.ts).
15+
- **Runtime Response Validation** - Zod schemas validate all API responses at unsafe boundaries (login, invoice list/detail, create). Parsing errors are caught and logged. See [`src/api/invoices.schema.ts`](./src/api/invoices.schema.ts), [`src/api/auth.schema.ts`](./src/api/auth.schema.ts), [`src/api/parse-api-response.ts`](./src/api/parse-api-response.ts).
1616
- **Comprehensive Tests** - tests cover form validation, hooks, utilities, component behavior, and runtime schema validation. MSW mocks backend; factories generate test data. Run `npm run test` for the full suite. See `frontend/src/**/*.test.ts`, `test/mocks/`.
1717
- **Feature-First Architecture** - Code organized by feature (`auth`, `invoices`) with feature-local domain logic, not by layer. Shared utilities live in `shared/`. See folder structure below.
1818

@@ -329,8 +329,8 @@ const user = authFactory.build({ email: 'test@example.com' });
329329
- **A4-ready** - CSS handles page size, margins, breaks.
330330

331331
**Implementation:**
332-
- `InvoicePrintDocument.tsx` - A4-sized hidden layout.
333-
- `index.css` - `@media print` rule hides app shell, shows print document.
332+
- [`src/features/invoices/detail/components/InvoicePrintDocument.tsx`](./src/features/invoices/detail/components/InvoicePrintDocument.tsx) - A4-sized hidden layout.
333+
- [`src/index.css`](./src/index.css) - `@media print` rule hides app shell, shows print document.
334334
- `page-break-inside: avoid` prevents table/totals from splitting across pages.
335335

336336
---

0 commit comments

Comments
 (0)