Skip to content

Feat/init project#4

Merged
damnthonyy merged 23 commits into
developfrom
feat/init-project
Mar 10, 2026
Merged

Feat/init project#4
damnthonyy merged 23 commits into
developfrom
feat/init-project

Conversation

@damnthonyy

Copy link
Copy Markdown
Member

nothing change, just update develop with main code

…ketClient tests with new connection handling scenarios
…gurations, and update coverage report settings
- Add URL normalization utility to ensure consistent trailing slashes
- Simplify 401 error handling and redirect logic
- Prevent duplicate WebSocket connections during CONNECTING state
- Update test mocking approach for location object
- Set default API URL in environment example
@damnthonyy damnthonyy added the chore Maintenance ,Config, deps, tooling label Mar 10, 2026
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Initialize project with API clients, tests, and Clean Architecture setup
✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add HTTP and WebSocket API clients with comprehensive test coverage
• Implement URL normalization and improved error handling for API requests
• Configure Vitest with jsdom environment and coverage reporting
• Establish project structure with Clean Architecture and documentation
Diagram
flowchart LR
  A["API Layer<br/>client.ts<br/>ws.client.ts"] -- "HTTP/WebSocket" --> B["API Clients<br/>with Error Handling"]
  C["Test Suite<br/>client.test.ts<br/>ws.client.test.ts"] -- "validates" --> B
  D["Configuration<br/>vitest.config.ts<br/>tsconfig.json"] -- "enables" --> C
  E["Project Structure<br/>Clean Architecture<br/>Documentation"] -- "organizes" --> A
  F["CI/CD Pipeline<br/>GitHub Actions<br/>SonarCloud"] -- "validates" --> B
Loading

Grey Divider

File Changes

1. src/architecture/api/client.ts ✨ Enhancement +133/-0

HTTP API client with error handling

src/architecture/api/client.ts


2. src/architecture/api/client.test.ts 🧪 Tests +268/-0

Comprehensive HTTP client test suite

src/architecture/api/client.test.ts


3. src/architecture/api/ws.client.ts ✨ Enhancement +126/-0

WebSocket client with reconnection logic

src/architecture/api/ws.client.ts


View more (30)
4. src/architecture/api/ws.client.test.ts 🧪 Tests +369/-0

WebSocket client connection and messaging tests

src/architecture/api/ws.client.test.ts


5. src/architecture/api/types.ts ✨ Enhancement +48/-0

API response and WebSocket type definitions

src/architecture/api/types.ts


6. vitest.config.ts ⚙️ Configuration changes +26/-0

Vitest configuration with jsdom and coverage

vitest.config.ts


7. src/test/setup.ts 🧪 Tests +7/-0

Test environment setup for browser globals

src/test/setup.ts


8. package.json Dependencies +45/-0

Add test scripts and dev dependencies

package.json


9. tsconfig.json ⚙️ Configuration changes +34/-0

TypeScript compiler configuration

tsconfig.json


10. next.config.ts ⚙️ Configuration changes +7/-0

Next.js configuration file

next.config.ts


11. src/app/layout.tsx ✨ Enhancement +34/-0

Root layout with fonts and metadata

src/app/layout.tsx


12. src/app/page.tsx ✨ Enhancement +9/-0

Home page placeholder

src/app/page.tsx


13. src/app/not-found.tsx ✨ Enhancement +20/-0

404 error page component

src/app/not-found.tsx


14. src/app/globals.css Formatting +26/-0

Global styles with Tailwind integration

src/app/globals.css


15. src/types/generics.ts ✨ Enhancement +3/-0

Generic type definitions placeholder

src/types/generics.ts


16. eslint.config.mjs ⚙️ Configuration changes +18/-0

ESLint configuration with Next.js rules

eslint.config.mjs


17. .prettierrc ⚙️ Configuration changes +6/-0

Prettier code formatting configuration

.prettierrc


18. postcss.config.mjs ⚙️ Configuration changes +7/-0

PostCSS configuration for Tailwind

postcss.config.mjs


19. .env.example ⚙️ Configuration changes +3/-0

Environment variables template

.env.example


20. pnpm-workspace.yaml ⚙️ Configuration changes +6/-0

pnpm workspace configuration

pnpm-workspace.yaml


21. .prettierignore ⚙️ Configuration changes +6/-0

Prettier ignore patterns

.prettierignore


22. .husky/pre-commit ⚙️ Configuration changes +2/-0

Git pre-commit hook for lint-staged

.husky/pre-commit


23. .husky/pre-push ⚙️ Configuration changes +11/-0

Git pre-push hook blocking direct pushes

.husky/pre-push


24. .github/workflows/ci.yml ⚙️ Configuration changes +72/-0

CI/CD pipeline with tests and SonarCloud

.github/workflows/ci.yml


25. .github/PULL_REQUEST_TEMPLATE.md 📝 Documentation +29/-0

Pull request template for contributions

.github/PULL_REQUEST_TEMPLATE.md


26. sonar-project.properties ⚙️ Configuration changes +11/-0

SonarCloud configuration and coverage settings

sonar-project.properties


27. README.md 📝 Documentation +35/-1

Project overview and setup instructions

README.md


28. docs/architecture.md 📝 Documentation +93/-0

Technical stack and Clean Architecture design

docs/architecture.md


29. docs/dependance.md 📝 Documentation +111/-0

Dependency management by project phase

docs/dependance.md


30. src/components/readme.md 📝 Documentation +45/-0

Component strategy with shadcn and Tremor

src/components/readme.md


31. pnpm-lock.yaml Additional files +5811/-0

...

pnpm-lock.yaml


32. src/components/dashboard/.gitkeep Additional files +0/-0

...

src/components/dashboard/.gitkeep


33. src/components/ui/.gitkeep Additional files +0/-0

...

src/components/ui/.gitkeep


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Mar 10, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Reconnect state not reset 🐞 Bug ⛯ Reliability
Description
WebSocketClient.disconnect() sets reconnectAttempts to maxReconnectAttempts, but connect() does not
reset it until onopen; if a subsequent manual connect attempt closes before opening, onclose() will
not schedule any retries because reconnectAttempts is already at the max. This makes the client
silently stop auto-reconnecting after a disconnect→connect cycle when the next connection attempt
fails early.
Code

src/architecture/api/ws.client.ts[R63-116]

+  connect(): void {
+    if (globalThis.window === undefined) return;
+    if (
+      this.socket?.readyState === WebSocket.OPEN ||
+      this.socket?.readyState === WebSocket.CONNECTING
+    )
+      return;
+
+    const url = `${this.baseUrl}/${this.config.path.replace(/^\//, '')}`;
+    this.socket = new WebSocket(url);
+
+    this.socket.onopen = () => {
+      this.reconnectAttempts = 0;
+      this.callbacks.onOpen?.();
+    };
+
+    this.socket.onmessage = (event: MessageEvent) => {
+      try {
+        const data = JSON.parse(event.data as string) as TMessage;
+        this.callbacks.onMessage?.(data);
+      } catch {
+        this.callbacks.onMessage?.(event.data as TMessage);
+      }
+    };
+
+    this.socket.onclose = (event: CloseEvent) => {
+      this.callbacks.onClose?.(event);
+      this.socket = null;
+      if (
+        this.config.reconnect &&
+        !event.wasClean &&
+        this.reconnectAttempts < this.config.maxReconnectAttempts
+      ) {
+        this.reconnectAttempts += 1;
+        this.reconnectTimeoutId = setTimeout(() => {
+          this.reconnectTimeoutId = null;
+          this.connect();
+        }, this.config.reconnectDelayMs);
+      }
+    };
+
+    this.socket.onerror = (event: Event) => {
+      this.callbacks.onError?.(event);
+    };
+  }
+
+  disconnect(): void {
+    if (this.reconnectTimeoutId) {
+      clearTimeout(this.reconnectTimeoutId);
+      this.reconnectTimeoutId = null;
+    }
+    this.reconnectAttempts = this.config.maxReconnectAttempts;
+    if (this.socket) {
+      this.socket.close(1000, 'Client disconnect');
Evidence
disconnect() permanently maxes reconnectAttempts, connect() does not clear it at the start of a new
connection attempt, and onclose() gates retries on reconnectAttempts < maxReconnectAttempts—so an
early close before onopen leaves retries disabled for that attempt.

src/architecture/api/ws.client.ts[63-77]
src/architecture/api/ws.client.ts[88-101]
src/architecture/api/ws.client.ts[109-118]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`disconnect()` sets `reconnectAttempts` to `maxReconnectAttempts` to prevent reconnects, but this state persists across subsequent `connect()` calls until `onopen` runs. If the next connection attempt fails before opening (so `onopen` never fires), `onclose` sees `reconnectAttempts` already at max and will not schedule retries.

### Issue Context
This reduces resilience specifically after a user-initiated disconnect→connect cycle under unstable network conditions.

### Fix Focus Areas
- src/architecture/api/ws.client.ts[63-116]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Overlapping lint-staged globs 🐞 Bug ⛯ Reliability
Description
lint-staged config applies both prettier and eslint to the same JS/TS files via overlapping
patterns, so files can be rewritten twice per commit. This increases hook runtime and can cause
avoidable churn (and in some setups can trigger lint-staged reruns when earlier tasks modify files).
Code

package.json[R20-23]

+  "lint-staged": {
+    "*.{js,jsx,ts,tsx,json,md}": "prettier --write",
+    "*.{js,jsx,ts,tsx}": "eslint --fix"
+  },
Evidence
The lint-staged patterns overlap for js/ts file extensions, and the pre-commit hook runs lint-staged
for every commit.

package.json[20-23]
.husky/pre-commit[1-2]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Current lint-staged config has overlapping patterns, so JS/TS files are formatted by prettier and then fixed by eslint as separate tasks. This makes the pre-commit hook do extra work and can cause unnecessary file rewrites.

### Issue Context
Pre-commit runs `pnpm exec lint-staged`, so this affects every commit.

### Fix Focus Areas
- package.json[20-23]
- .husky/pre-commit[1-2]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@damnthonyy damnthonyy merged commit 84ffd2c into develop Mar 10, 2026
5 checks passed
@damnthonyy damnthonyy deleted the feat/init-project branch March 10, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance ,Config, deps, tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants