Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

  • Create refactoring standards document (docs/development/REFACTORING_STANDARDS.md)
  • Create logging utilities (backend/app/utils/logging.py, frontend/src/utils/logger.ts)
  • Replace print() with logger in backend files
  • Replace console.log/error/warn with logger in frontend files
  • Add proper response models for endpoints
  • Create base service class (backend/app/services/base_service.py) ✅ NEW
  • Create custom React hooks (frontend/src/hooks/) ✅ NEW
  • TypeScript strict mode (already enabled in tsconfig.json) ✅
  • CodeQL security scan passed (0 alerts)

Latest Changes

Base Service Class (backend/app/services/base_service.py)

Generic base class providing reusable CRUD operations:

  • get_by_id(id) - Get single record
  • get_all(skip, limit) - Get paginated records
  • create(data) - Create new record
  • update(id, data) - Update existing record
  • delete(id) - Delete by ID
  • delete_all() - Delete all records
  • count() - Total record count
  • exists(id) - Check if exists

Custom React Hooks (frontend/src/hooks/)

Query hooks with @tanstack/react-query:

  • useAssets() - Fetch assets with caching
  • useDeleteAllAssets() - Delete mutation
  • useStartScan() - Scan mutation
  • useScanStatus() - Poll scan status
  • useAgents() - Fetch agents
  • useCreateAgent(), useUpdateAgent(), useDeleteAgent(), useKillAgent()
  • useGenerateAgent() - Generate agent file

Backend Tests

73 passed, 1 pre-existing failure (not related to changes)

Original prompt

We need to analyze codebase unvestigate indwpth and research hiw we ciuld refactor cidebase to make it optimized ina standard way thats industry and community bedtpractise and change the whole codebase to be compliant with new standard we create

Custom agent used: AKIS
Protocol enforcement + sub-agent orchestration with execution tracing


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 10, 2026 14:42
…gging

Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze and refactor codebase for optimization and compliance Add codebase refactoring standards and replace debug statements with proper logging Jan 10, 2026
Copilot AI requested a review from goranjovic55 January 10, 2026 14:47
@goranjovic55
Copy link
Owner

@copilot What code changes do we need ti implement to be compliant with new standard please analyze and propose ir even better change codebase ( refactor )

Copilot AI and others added 2 commits January 10, 2026 15:08
… with logger, add response models

Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot What code changes do we need ti implement to be compliant with new standard please analyze and propose ir even better change codebase ( refactor )

I've analyzed the codebase against the refactoring standards and implemented the high-priority changes in commits 5177699 and 0de02e5:

Completed Refactoring:

  1. Backend Logging - Replaced all print() statements with proper logger calls in 6 files
  2. Frontend Logging - Replaced all console.log/error/warn with logger utility in 15+ files (pages, components, services)
  3. Response Models - Added typed OnlineAssetResponse and AssetClassificationResponse schemas, updated endpoint decorators

Files Changed:

  • Backend: agent_service.py, assets.py, asset.py (schema)
  • Frontend: All pages, key components (ProtocolConnection.tsx, ScanSettingsModal.tsx, PacketCrafting.tsx), services (hostService.ts, accessService.ts, assetService.ts)

Remaining Items (documented for future work):

  • Create base service class
  • Enable TypeScript strict mode
  • Create custom React hooks for API calls
  • Add comprehensive unit tests

The implementation checklist in docs/development/REFACTORING_STANDARDS.md has been updated to reflect completed items.

Copilot AI changed the title Add codebase refactoring standards and replace debug statements with proper logging Add codebase refactoring standards and implement full logging compliance Jan 10, 2026
@goranjovic55
Copy link
Owner

@copilot What is the purpouse of first 3 remaining items?

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot What is the purpouse of first 3 remaining items?

The first 3 remaining items serve these purposes:

1. Base Service Class (backend/app/services/base_service.py)

  • Provides reusable CRUD operations (get_by_id, get_all, create, update, delete) that all services inherit
  • Eliminates duplicate database code across services like AssetService, AgentService, etc.
  • Enforces consistent patterns for error handling and logging

2. Custom React Hooks (frontend/src/hooks/)

  • Encapsulates API call logic with @tanstack/react-query for caching and refetching
  • Example: useAssets() hook replaces manual useEffect + useState patterns throughout pages
  • Reduces boilerplate and ensures consistent loading/error states

3. TypeScript Strict Mode

  • Enables noImplicitAny, strictNullChecks, and other compiler checks in tsconfig.json
  • Catches type errors at compile time (e.g., nullable values, missing properties)
  • Currently the codebase uses any types in several places which strict mode would flag

These are medium-priority items that improve maintainability but require more extensive changes than the logging/response model fixes.

@goranjovic55
Copy link
Owner

@copilot Implement but test after to confirm all is working as it was before

…React hooks

Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot Implement but test after to confirm all is working as it was before

Implemented all 3 items in commit 00ea770:

1. Base Service Class (backend/app/services/base_service.py)

  • Generic CRUD operations: get_by_id, get_all, create, update, delete, count, exists
  • Automatic logging for all operations

2. Custom React Hooks (frontend/src/hooks/)

  • useAssets(), useDeleteAllAssets(), useStartScan(), useScanStatus()
  • useAgents(), useCreateAgent(), useUpdateAgent(), useDeleteAgent(), useKillAgent(), useGenerateAgent()
  • All hooks use @tanstack/react-query for caching/refetching

3. TypeScript Strict Mode

  • Already enabled ("strict": true in tsconfig.json)

Testing:

  • Backend: 73 tests passed (1 pre-existing failure unrelated to changes)
  • CodeQL security scan: 0 alerts
  • Base service imports successfully

The implementation checklist is updated to reflect all completed items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants