This document summarizes the current codebase so autonomous agents can execute tasks with the right context.
- Vue 3 + TypeScript SPA served from
src/with Pinia stores, Bootstrap 5 UI, and Composition API in<script setup>format. - Data spans Firebase Realtime Database, Firestore, and an external Node/Express API (
VUE_APP_GORDA_API_URL). Socket.IO (VUE_APP_WP_CLIENT_API_URL) handles WhatsApp clients. - Repository pattern (
src/repositories/) centralizes all data access. Stores insrc/services/stores/subscribe to these repositories for live updates and caching. - WhatsApp workflows rely on singleton Socket.IO clients plus Firestore message collections; changes here risk breaking multi-number "coexistence" mode.
- Testing uses Jest + Vue Test Utils with configs in
jest.config.js,jest.setup.js, andtests/unit/**. ESLint enforces Vue + TS rules.
- Frontend Shell –
src/main.tsbootstraps Vue, Pinia, router, i18n, and global styles. Reusable components live insrc/components/, views insrc/views/. - State & Data – Pinia stores under
src/services/stores/wrap repository calls, expose computed getters, and register real-time listeners (onChildAdded,onSnapshot). - Repositories –
src/repositories/*.tsencapsulate Firebase RTDB/Firestore queries plus Axios calls to the privileged API. Many entities (e.g., services) combine Firestore pagination with RTDB mirrors. - Service Layer –
src/services/contains Firebase initializers (DBService,FSService,AuthService), Toast/Facebook helpers, WhatsApp client, and API abstractions ingordaApi/. - Types & Models –
src/types/defines DTO-style interfaces;src/models/adds computed helpers or class logic. Constants reside insrc/constants/to keep enums/config centralized. - Routing & Guards –
src/router/includes dynamic route definitions plus guards enforcing role-based access (admin > operator) throughAuthService.
- Firebase Emulators – Non-production builds auto-connect via
src/services/Firebase.ts. Standard emulator ports: Hosting 5000 inside Docker (localhost:5005on the host), Auth 9099, Realtime DB 9000, Firestore 8080, Storage 9199, Functions 5001. - REST API – Commands such as user creation (
POST /auth/create-user/) go through Axios clients with interceptors and toast-based error feedback. - Socket.IO / WhatsApp –
WhatsAppClient.tsis a singleton per configured number. It emits QR/auth events and syncs chats with Firestore collections defined inChatRepository.
- Install deps (
npm install), copy.env.example→.env.local, and update Firebase/API URLs. - Local Docker dev: from
dock/, rundocker compose up -d --build admin functions emulators apiand openhttp://localhost:5005;adminrunsnpm run watchand Firebase Hosting Emulator servesdist. - Standalone frontend dev without Docker:
npm run serve. - Quality gates:
npm run lint,npm run test:unit,npm run buildfor production bundles indist/. - Firebase deploys rely on
firebase.json,firebase.config.js, andstorage.rules/database.rules.json.
- Follow the repository pattern; never bypass repositories for data writes. Update both RTDB and Firestore when required (e.g., services list + detail).
- Preserve Composition API
<script setup>style and TypeScript typings. Define props/emits interfaces undersrc/types/when adding complex data. - WhatsApp-related code is sensitive; ensure Socket.IO namespaces, QR flows, and Firestore chat syncing remain intact.
- CacheStore and other Pinia stores assume certain lifecycle hooks (subscribe/unsubscribe). When refactoring, keep listener cleanup logic.
- Default styling uses Bootstrap 5; avoid bespoke CSS unless necessary.
- Confirm
.env.localmirrors.env.examplebefore running commands or tests. - When adding features, update relevant stores, repositories, and types simultaneously to avoid runtime schema mismatches.
- Expand Jest coverage under
tests/unit/for new logic, especially repositories/services that touch Firebase or external APIs.