Skip to content

Commit 3b1ab59

Browse files
docs: update file paths to reflect src/ reorganization
- Update README.md to note that core code is organized in src/ directory - Update ARCHITECTURE.md with complete src/ file paths including middleware and validators - Update DEVELOPMENT.md with src/ paths for Node.js debugging and profiling commands - Ensure all documentation consistently references new directory structure
1 parent d62ed29 commit 3b1ab59

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

AGENTS.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# AGENTS.md — Quick Guide for Coding Agents
2+
23
Scope: entire repo. Always branch first (feature/... or fix/...), never commit to master/main.
34
Build/run: `npm ci`; dev: `npm run dev`; prod: `npm start`.
45
Health check: `npm run ping` or `curl http://localhost:3000/ping`.
5-
Tests: none configured; use curl/manual checks. If Jest is added: `npx jest path/to.test.js -t "name"` for single tests.
6-
Lint/format: ESLint v9+ is configured (see eslint.config.js). Use 2space indent, single quotes, semicolons, trailing newline. Run `npx eslint . --ext .js` before committing.
6+
Tests: Jest configured; use `npx jest path/to.test.js -t "name"` for single tests.
7+
Lint/format: ESLint v9+ is configured (see eslint.config.js). Use 2-space indent, single quotes, semicolons, trailing newline. Run `npx eslint . --ext .js` before committing.
78
Modules: CommonJS only (`require`/`module.exports`). Do not introduce ESM.
8-
Imports: group builtin, deps, local; use relative paths (`./`, `../`). Avoid deep coupling.
9+
Imports: group built-in, deps, local; use relative paths (`./`, `../`). Avoid deep coupling.
910
Types: plain JS; add JSDoc for complex functions. Do not add TS files unless requested.
1011
Naming: camelCase vars/functions; PascalCase classes; UPPER_SNAKE for constants/env.
1112
Errors: validate inputs; respond JSON `{ ok:false, error }` with correct HTTP codes; avoid uncaught throws in handlers.
12-
Logging: use `logger.js` helpers (`httpLogger`, `wireSocketLogging`, `appLogger`). Never log secrets.
13-
MongoDB: reuse a single client (no per‑request connects). Keep auth state in `mongoAuthState.js`.
14-
Routes: define in `routes.js` as `[{ method, path, handler }]`; use `req.app.locals.whatsapp_socket`.
15-
Socket lifecycle: in `index.js`; don’t change without need; keep HTTP and socket separate.
13+
Logging: use `src/logger.js` helpers (`httpLogger`, `wireSocketLogging`, `appLogger`). Never log secrets.
14+
MongoDB: reuse a single client (no per-request connects). Keep auth state in `src/mongoAuthState.js`.
15+
Routes: define in `src/routes.js` as `[{ method, path, handler }]`; use `req.app.locals.whatsapp_socket`.
16+
Socket lifecycle: in `src/index.js`; don't change without need; keep HTTP and socket separate.
17+
Middleware: auth in `src/middleware/authMiddleware.js`; webhooks in `src/middleware/webhookSecurityMiddleware.js`.
18+
Validators: schemas in `src/validators/validationSchemas.js`; apply with `validateRequest` middleware.
1619
Env vars: `HOST`, `PORT`, `MONGO_URL`, `DB_NAME`; keep README and `.env.example` in sync.
1720
API shape: return `{ ok: boolean, ... }`; keep endpoints small and testable.
1821
Docs: update `docs/API_Reference.md` and `README.md` when adding/modifying endpoints.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ curl -X POST http://localhost:3000/accounts/mybot/message/send \
155155
- **Config:** See `eslint.config.js` in the project root.
156156
- **CI:** Linting is enforced in GitHub Actions.
157157
- **Style:** 2-space indent, single quotes, trailing commas, semicolons, CommonJS modules.
158+
- **Core Code:** Application code is organized in the `src/` directory with structured subdirectories for middleware, validators, and types.
158159

159160
<table>
160161
<tr>

docs/ARCHITECTURE.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ This document describes the high-level architecture of the Wildcat WhatsApp inte
3737

3838
### Key Files
3939

40-
- **`index.js`** - Application entry point, initializes managers and starts server
41-
- **`server.js`** - Express app construction and server startup
42-
- **`managementRoutes.js`** - Global routes (accounts, webhooks, media)
43-
- **`accountRouter.js`** - Per-account routes (messages, status)
44-
- **`socketManager.js`** - WhatsApp socket lifecycle management
45-
- **`accountManager.js`** - Account CRUD operations
46-
- **`mediaHandler.js`** - Media download/upload to GridFS
47-
- **`logger.js`** - Structured logging utilities
40+
- **`src/index.js`** - Application entry point, initializes managers and starts server
41+
- **`src/server.js`** - Express app construction and server startup
42+
- **`src/managementRoutes.js`** - Global routes (accounts, webhooks, media)
43+
- **`src/accountRouter.js`** - Per-account routes (messages, status)
44+
- **`src/socketManager.js`** - WhatsApp socket lifecycle management
45+
- **`src/accountManager.js`** - Account CRUD operations
46+
- **`src/mediaHandler.js`** - Media download/upload to GridFS
47+
- **`src/logger.js`** - Structured logging utilities
48+
- **`src/middleware/authMiddleware.js`** - HTTP authentication middleware
49+
- **`src/middleware/webhookSecurityMiddleware.js`** - Webhook request validation
50+
- **`src/validators/validationSchemas.js`** - Input validation schemas
51+
- **`src/db.js`** - MongoDB connection management
52+
- **`src/mongoAuthState.js`** - WhatsApp auth state persistence
4853

4954
## Data Flow
5055

docs/DEVELOPMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ docs: update API reference
6464
- **Formatting:** Consistent indentation (2 spaces)
6565
- **Naming:** camelCase for variables/functions, PascalCase for classes
6666
- **Error Handling:** Use try/catch, return structured error responses
67-
- **Logging:** Use the provided logger utilities
67+
- **Logging:** Use the provided logger utilities from `src/logger.js`
6868

6969
### API Design
7070

@@ -195,11 +195,11 @@ NODE_ENV=development
195195

196196
```bash
197197
# Memory usage
198-
node --inspect index.js
198+
node --inspect src/index.js
199199

200200
# Performance monitoring
201201
npm install -g clinic
202-
clinic doctor -- node index.js
202+
clinic doctor -- node src/index.js
203203
```
204204

205205
## Security

0 commit comments

Comments
 (0)