How polotorom-debug/worm-ai works
1. Overall shape
- This is a client-side React application built with Vite. The architecture is centered around a browser UI, with no backend service visible in the repo tree.
- The app is organized into three main layers: pages/UI, application logic/hooks, and shared services/provider adapters.
2. Bootstrapping and routing
- src/main.jsx is the entry point and mounts the React app.
- src/App.jsx is the top-level composition/routing layer that decides which page is shown.
- The primary user-facing routes are the pages under src/pages/, including landing, auth, dashboard, chat, settings, profile, admin, and docs.
3. Presentation layer
- src/components/ contains the reusable UI shell and layout primitives:
- Layout.jsx for the app frame
- Header.jsx and Sidebar.jsx for navigation/chrome
- components/ui/ for base design-system components
- The project uses a shadcn/ui-style component set plus Tailwind CSS for styling, so the UI is assembled from small composable primitives rather than a large monolithic widget layer.
4. Authentication boundary
- Authentication is handled through src/hooks/useAuth.js and src/lib/auth.js.
- The auth layer appears to manage login state, user identity, and role separation between admin and regular user.
- Demo credentials in the README suggest the app supports a local/demo auth mode rather than relying only on an external identity provider.
5. Data persistence and local state
- src/lib/db.js is the main persistence abstraction, likely for local/browser-side storage of user/session/conversation data.
- src/lib/cache.js provides a separate caching layer for reducing repeated work or repeated provider calls.
- src/lib/logger.js captures operational/audit events, which is important for the admin workflow.
- These modules form the app’s internal state boundary; they are the shared data services used by the rest of the app.
6. Chat subsystem
- src/hooks/useChat.js is the orchestration hook for the chat experience.
- The Chat.jsx page is the main consumer of this hook and likely drives conversation history, model selection, and message submission.
- The chat subsystem depends on provider adapters, local persistence, and caching, making it the most integration-heavy part of the app.
7. LLM provider abstraction
- src/providers/ is a clear adapter layer that normalizes multiple model backends:
- openai/
- anthropic/
- google/
- local/ for Ollama
- custom/ for arbitrary endpoints
- src/providers/index.js acts as the provider registry/factory, so the rest of the app can switch providers without changing UI logic.
- Each provider has its own client module and wrapper, which keeps vendor-specific API details isolated.
8. External integrations
- The app can call OpenAI, Anthropic, Google Gemini, or local Ollama depending on configuration.
- The README shows these are configured through environment variables, so provider selection is runtime-configurable.
- This means the system has two external boundaries: cloud AI APIs and local model serving via Ollama.
9. Security and content policy
- The product is explicitly positioned as defensive cybersecurity only.
- The guardrails are part of the application architecture, not just product copy: the chat/provider layers are expected to restrict outputs to ethical, defensive content and block malicious requests.
- That policy boundary is central to the app’s purpose and likely influences prompt construction and response filtering.
10. Admin and observability
- src/pages/Admin.jsx is the operational control surface, likely consuming logs and user/system data.
- logger.js plus the admin page create an internal observability path for reviewing activity.
- This is distinct from end-user chat and indicates the app has a lightweight governance/monitoring subsystem.
11. Configuration and settings
- Settings.jsx is the user-facing configuration surface for model/provider preferences and API key management.
- src/lib/app-params.js suggests central app configuration values are separated from feature logic.
- Environment-driven setup in the README means the app’s runtime behavior is heavily parameterized rather than hardcoded.
12. Legacy boundary
- src/API/base44Client.js is called out as legacy, which implies there was an older backend/client integration path.
- Architecturally, this should be treated as a separate compatibility boundary rather than the primary app path.
13. Operational flow summary
- A user enters through landing/login/register, gets authenticated, and lands in the dashboard/chat shell.
- Chat requests flow from page → useChat → provider registry → provider client → external API or local Ollama.
- Results and metadata can be cached, stored in local DB/state, and surfaced to dashboard/admin views through the shared lib layer.
14. What to draw as the main boxes
- For an architecture diagram, the key boxes are:
- React/Vite UI shell
- Auth and local persistence services
- Chat orchestration hook
- Provider adapter layer
- External AI providers / Ollama
- Admin/logging surface
- The strongest architectural boundary is between the browser app and the LLM provider backends, with the provider abstraction insulating the UI from vendor specifics.
Main entry points: pages Pages · index.js Provider registry · useChat.js useChat · useAuth.js useAuth
Components 24
UI shell
React views, layout, and shared visual components
- main · Bootstraps the React app in the browser.
src/main.jsx - App · Top-level composition and route selection.
src/App.jsx - Layout · Shared application frame and chrome.
src/components/Layout.jsx - Header · Top navigation and user controls.
src/components/Header.jsx - Sidebar · Primary navigation and section switching.
src/components/Sidebar.jsx - Pages · Landing, auth, dashboard, chat, settings, profile, admin, and docs views.
src/pages - UI atoms · Reusable shadcn-style primitives built on Tailwind.
src/components/ui
App logic
Hooks and app-level orchestration
Shared services
Local persistence, auth, caching, and logging
- Auth lib · Credential handling and auth helpers.
src/lib/auth.js - DB · Browser-side persistence for app data.
src/lib/db.js - Cache · Local caching layer for repeated work and provider calls.
src/lib/cache.js - Logger · Operational and activity logging for admin visibility.
src/lib/logger.js - App params · Central runtime configuration values.
src/lib/app-params.js
Model adapters
Provider registry and vendor-specific clients
- Provider registry · Selects and normalizes model providers.
src/providers/index.js - OpenAI · Adapter for OpenAI models.
src/providers/openai - Anthropic · Adapter for Anthropic models.
src/providers/anthropic - Google · Adapter for Gemini models.
src/providers/google - Local · Adapter for local Ollama models.
src/providers/local - Custom · Adapter for arbitrary endpoint providers.
src/providers/custom
External systems
Browser, local model runtime, and cloud AI APIs
- Browser · Client-side React/Vite execution environment.
- Cloud AI APIs · OpenAI, Anthropic, and Google model services.
- Ollama · Local model serving backend.
- Legacy API · Older Base44 integration path kept for compatibility.
src/API/base44Client.js
Connections 29
- Browser → main: loads · The browser starts the application bundle.
- main → App: mounts · Entry point mounts the routed app shell.
- App → Layout: wraps · Routes are rendered inside the shared frame.
- Layout → Header: contains · Layout includes top navigation.
- Layout → Sidebar: contains · Layout includes primary navigation.
- App → Pages: routes · Top-level route switching selects pages.
- Pages → UI atoms: composes · Pages are built from shared UI primitives.
- useAuth → Auth lib: uses · Auth hook delegates identity logic to auth helpers.
- useAuth → DB: reads/writes · Auth state is persisted locally.
- useAuth → Logger: emits · Auth events can be recorded for audit and admin workflows.
- useChat → DB: stores · Conversation state and metadata are persisted locally.
- useChat → Cache: caches · Chat results and repeated calls are cached.
- useChat → Logger: emits · Chat activity can be logged for operational review.
- useChat → Provider registry: selects · Chat orchestration resolves the active model provider.
- Provider registry → OpenAI: adapts · Registry can route to OpenAI adapter.
- Provider registry → Anthropic: adapts · Registry can route to Anthropic adapter.
- Provider registry → Google: adapts · Registry can route to Google adapter.
- Provider registry → Local: adapts · Registry can route to local Ollama adapter.
- Provider registry → Custom: adapts · Registry can route to custom endpoint adapter.
- OpenAI → Cloud AI APIs: calls · OpenAI adapter connects to external API services.
- Anthropic → Cloud AI APIs: calls · Anthropic adapter connects to external API services.
- Google → Cloud AI APIs: calls · Google adapter connects to external API services.
- Local → Ollama: calls · Local adapter connects to on-device or LAN model serving.
- Custom → Cloud AI APIs: calls · Custom adapter can target arbitrary remote endpoints.
- Pages → useAuth: consumes · Auth pages and protected views depend on auth state.
- Pages → useChat: consumes · Chat page drives conversation orchestration.
- Pages → App params: configures · Settings and app flows read central runtime parameters.
- Pages → Logger: reviews · Admin views surface logged activity.
- Legacy API → DB: integrates · Legacy client sits beside the current local state boundary.