# Project: ComFi Management System ## Overview ComFi is a React-based financial and management dashboard. - **Frontend:** React 19, Vite, TypeScript. - **Serving (Production):** Node.js (Express) via `server.js`. - **State Management:** Context API (`ComFiContext`, `ToastContext`). - **Styling:** CSS / Lucide React icons. ## Architecture ### Current (Local) - **Dev Server:** `vite` (HMR, local dev). - **Prod Preview:** `node server.js` serving `dist/`. ### Target (Production) - **Containerization:** Docker (Multi-stage build). - **Orchestration:** Docker Swarm (managed via Portainer). - **CI/CD:** Gitea Actions. - **Reverse Proxy:** Traefik or Nginx (implied by Swarm/Portainer setup, usually handles SSL termination). ## Deployment Roadmap ### 1. Dockerization - Create `Dockerfile`: - **Stage 1 (Builder):** Install deps, run `npm run build` to generate `dist/`. - **Stage 2 (Runner):** Alpine Node image, copy `dist/`, `server.js`, and `package.json`. Run `npm install --production`. - Create `docker-compose.yml` for local testing of the production build. ### 2. CI/CD (Gitea Actions) - Define workflow `.gitea/workflows/deploy.yaml`. - **Steps:** - Checkout code. - Login to Container Registry. - Build and Push Docker Image (tagged with commit SHA and `latest`). - Trigger Deployment (Portainer Webhook). ### 3. Portainer & Swarm Configuration - **Stack Definition:** A `docker-compose` style file for Swarm. - **Secrets Management:** - Registry Credentials (if private). - Environment variables (if any, e.g., API endpoints). - **Update Mechanism:** Webhook URL provided by Portainer Service. ## Required Configuration & Secrets To proceed, we will need to define: 1. **Registry URL:** `gitea.blyzer.com.br` 2. **Image Name:** `gitea.blyzer.com.br/blyzer/comfi` 3. **Portainer Webhook:** The URL Portainer provides to trigger a service update. ### Secrets (Gitea) Set these in your Gitea repository settings (Settings > Actions > Secrets): - `REGISTRY_USERNAME`: Your Gitea username. - `REGISTRY_TOKEN`: Your Gitea password or token. - `PORTAINER_WEBHOOK`: The full webhook URL from Portainer. - `API_KEY`: (Optional) Google GenAI API key. ## Directives - **Conventions:** Follow existing TypeScript and React patterns. - **Safety:** Do not commit `.env` files. - **Style:** Maintain the clean, dashboard-style UI.