| id | PRO4TECH-SINAPSE-AGENT-CONTEXT | |||||
|---|---|---|---|---|---|---|
| type | AI_AGENT_CONTEXT | |||||
| project | Sinapse | |||||
| project_aliases |
|
|||||
| status | authoritative-context | |||||
| repository | Galaticos-API/API-4 | |||||
| source_documents |
|
|||||
| read_first | true | |||||
| purpose | This file is the single canonical context for AI agents working on this project. It contains total domain, architecture, schema, requirements, design system, and operational rules. |
Project Goal: Build a platform that converts software requirements into a reusable, intelligent institutional memory for the software factory (PRO4TECH). The system helps Product Owners (POs) specify features with standard quality, lower rework, and zero knowledge loss between teams and projects.
Core Product Essence:
-
Hierarchical Backlog:
Projeto$\rightarrow$ Épico$\rightarrow$ Feature$\rightarrow$ PBI$\rightarrow$ Critério de Aceitação (BDD). - Assistive AI: AI acts strictly as an assistant/copilot (questioning, suggesting, standardizing), never as an autonomous persistent author.
-
Three Knowledge Axes:
- Projects (Requirements, decisions, documents, history)
- People (Developers, roles, seniorities, project allocations)
- Technologies / Stacks (Frameworks, libraries, integrations, competencies)
- Knowledge Retrieval: Semantic/text hybrid search, natural language Q&A chat with mandatory source citations, and team competence matching.
- Client: PRO4TECH — Digital Tech Transformation (Software factory & digital transformation partner).
- Operating Model: Scrum, squads, DevOps pipelines, multi-model contracts (build, support, build+support).
- Stakeholders: 4 Product Owners.
- Domain Problem:
- POs document requirements inconsistently across different channels.
- Critical technical decisions are lost in chat histories or individual memory.
- Solutions built in past projects are forgotten and reimplemented from scratch.
- Onboarding new squad members to legacy projects takes excessive time.
- Tracing what was decided and why is costly.
- Core Value Proposition: Transform learned project knowledge into searchable, reusable institutional memory.
- Assistive Only: AI never writes directly to business database tables.
- Explicit Human Action Required: Every AI output is a draft/suggestion. The PO must explicitly accept, edit, or discard suggestions.
- Provenance Tracking: Every requirement field must record its origin (
human-authored,ai-accepted,ai-edited). - Zero Hallucinations: Chat and RAG responses must only answer based on retrieved evidence and must cite source documents/PBIs. If no evidence is found, return "Informação não encontrada no acervo do projeto."
- Primary AI Behavior: AI should prioritize questioning (identifying gaps, edge cases, missing non-functionals) rather than merely drafting text.
- This Product IS NOT a Project Management Tool.
- Azure DevOps remains the single source of truth for sprint execution, Kanban boards, hour tracking, task assignments, and burndown charts.
- Sinapse IS Responsible For: Requirements specification, quality scoring, technical decisions rationale, document acervo, team competencies, and reusable knowledge.
- Project Isolation (RNF-03): Vector RAG queries must enforce metadata filtering by
project_id. Semantic vector closeness across projects does not grant project membership. - 100% Local & Offline Stack (RNF-03, RNF-04): Core LLM inference (
qwen2.5:1.5b) and embeddings (bge-m3) run 100% locally via Ollama with zero external cloud dependencies. - LGPD Awareness (RNF-09): Developer competence and allocation data must handle professional information transparently with role-based access control.
- Product Owner (PO - Primary Persona):
- Needs: Copilot that standardizes specifications, flags vague terms, asks clarifying questions, and suggests similar past features for reuse.
- Developer / Tech Lead:
- Needs: Unambiguous, testable BDD acceptance criteria, decision rationales, and fast technical onboarding.
- Delivery Manager / Head of Delivery:
- Needs: Mapped team technical competencies to form optimal squads based on stack experience.
- New Squad Member:
- Needs: Conversational Q&A chat to query historical project decisions and architecture without disturbing senior devs.
The application is structured into conteinerized, local microservices:
+-----------------------+
| Frontend (React 19) |
| Port 5173 (Vite SPA) |
+-----------+-----------+
| HTTP REST / Auth JWT
v
+------------------+ n8n Sync +-----------------------+ SQL / pgvector +-----------------------+
| n8n Orquestra- |<----------->| Backend (Node 20/TS) |<---------------->| PostgreSQL 16 + |
| dor (Port 5678) | | Port 3001 (Express) | | pgvector (Port 55432) |
+------------------+ +-----------+-----------+ +-----------------------+
| HTTP REST / Internal
v
+-------------------------+ Ollama API +-----------------------+
| Serviço IA (Python 3.11|-------------->| Ollama Runtime (Local)|
| FastAPI - Port 8000) | | Port 11434 (bge-m3) |
+-------------------------+ +-----------------------+
| Component | Stack | Local Port | Main Responsibility |
|---|---|---|---|
| Database | PostgreSQL 16 + pgvector |
55432 (host) |
Relational persistence & vector embeddings (vector_cosine_ops, HNSW index). |
| Backend | Node.js 20+ / Express / TS | 3001 |
REST API, Auth JWT, CRUD, deterministic quality engine, sole persistent writer to business tables. |
| Frontend | React 19 / Vite / TS | 5173 |
SPA for POs (requirements hierarchy, quality indicators, acervo search, chat). |
| AI Service | Python 3.11+ / FastAPI | 8000 |
Chunking source of truth, RAG retrieval, bge-m3 embedding calculation, PRO4TECH Harness. |
| n8n | n8n latest |
5678 |
Asynchronous file ingestion workflow (/files), GitOps versioned via n8n-local-sync. |
| Ollama | Host runtime | 11434 |
Local LLM (qwen2.5:1.5b) and Embedding (bge-m3) runtime, executed outside Docker. |
PROJETO EPICO FEATURE PBI CRITERIO_ACEITACAO.
projeto:id(UUID),nome,cliente,descricao,status(ativo,em_andamento,concluido,arquivado),created_at.epico:id(UUID),projeto_id(FK),titulo,objetivo,escopo_macro,prioridade(Must,Should,Could,Won't),status(rascunho,pronto,concluido,arquivado).feature:id(UUID),epico_id(FK),titulo,objetivo,prioridade,status.pbi:id(UUID),feature_id(FK),codigo(unique, ex:PBI-01.1.1),titulo(verb in infinitive),historia_como_um,historia_eu_quero,historia_para_que,regras_observacoes,tipo(Funcional,Nao-Funcional),prioridade,score_completude(0-100),provenance(human-authored,ai-accepted,ai-edited),requer_interface(boolean),status.criterio_aceitacao:id(UUID),entidade_tipo(epico,feature,pbi),entidade_id(UUID),ordem,texto,dado(BDD Given),quando(BDD When),entao(BDD Then).documento:id(UUID),projeto_id(FK),nome,mime,caminho,status_processamento.chunk:id(UUID),projeto_id(FK desnormalizado),entidade_tipo,entidade_id,texto,metadados_json(JSONB),embedding(vector(1024)indexed with HNSWvector_cosine_ops).usuario/desenvolvedor/competencia/tecnologia: Team competence graph (senioridade,bio,nivel,evidencia).organizacao_configuracao: Versioned quality organizational policy rules.
The completeness score (GET /api/v1/quality/configuration/pbi):
- Title Format: Must start with an infinitive verb (e.g., Cadastrar, Consultar, Validar).
- User Story Completeness: Must contain non-empty
COMO UM,EU QUERO, andPARA QUEfields. - Acceptance Criteria (BDD): Must have at least 1 BDD scenario with non-empty
DADO,QUANDO,ENTÃO. - Vague Terms Dictionary: Must not contain vague/ambiguous terms (e.g., fácil, rápido, amigável, adequado, se possível).
- Prototype Link (
prototipo_vinculado): Evaluated only whenrequer_interface = true. Checks if a record exists inprototipotable for the PBI. Ifrequer_interface = false, this rule is marked non-applicable and omitted from the denominator.
- Selected Model:
BAAI/bge-m3via Ollama. - Vector Dimension: 1024 (100% matched to
chunk.embedding vector(1024)in Postgrespgvector). - Context Window: 8,192 tokens.
- PT-BR Benchmark: 100% Top-1 accuracy with +0.81 margin over distractor noise.
-
Ingestion: Document upload
$\rightarrow$ n8n watcher$\rightarrow$ POST /ingest(Pythonai-service)$\rightarrow$ Chunking (paragraph boundary aware)$\rightarrow$ Calculate 1024d embedding viabge-m3$\rightarrow$ Store in Postgreschunktable withprojeto_idmetadata. -
Retrieval: Query
$\rightarrow$ bge-m3vector$\rightarrow$ Hybrid search in Postgres (HNSW Cosine Similarityembedding <=> query_vec+ SQL Full-Text Searchtsvector) with mandatoryWHERE projeto_id = $1$\rightarrow$ Top-5 chunks. -
Synthesis: Top-5 chunks injected into Python PRO4TECH Harness prompt
$\rightarrow$ Local LLM (qwen2.5:1.5b)$\rightarrow$ Response with explicit source citations.
GraphRAG combines vector search with relational knowledge graph expansion:
-- Knowledge Graph Tables in PostgreSQL
CREATE TABLE knowledge_entity (
id UUID PRIMARY KEY,
project_id UUID NOT NULL REFERENCES projeto(id) ON DELETE CASCADE,
entity_type VARCHAR(50) NOT NULL, -- TECHNOLOGY, PERSON, PROJECT, DECISION
name TEXT NOT NULL,
normalized_name TEXT NOT NULL
);
CREATE TABLE knowledge_relation (
id UUID PRIMARY KEY,
project_id UUID NOT NULL REFERENCES projeto(id) ON DELETE CASCADE,
source_entity_id UUID NOT NULL REFERENCES knowledge_entity(id),
relation_type VARCHAR(80) NOT NULL, -- USES, WORKED_ON, DEPENDS_ON, JUSTIFIES
target_entity_id UUID NOT NULL REFERENCES knowledge_entity(id),
source_chunk_id UUID REFERENCES chunk(id),
confidence REAL
);Traversal Rule: project_id scoping is enforced prior to graph traversal (depth 1-2 hops max) to answer complex multi-hop queries (e.g., "Who worked on PIX integration and what architectural decisions were made?").
The frontend React application follows a dark-mode palette extracted from PRO4TECH guidelines:
- Background (
surface-base):#0A0D14(Dark Blue/Black) - Primary Brand (
brand-primary):#F97316(Vibrant Orange CTA, borders, highlights) - Text Primary (
text-primary):#FFFFFF - Text Secondary (
text-secondary):#9CA3AF - Stepper Colors (
step-1tostep-5):- Step 1 (Descobrimos):
#F28C68 - Step 2 (Projetamos):
#D97354 - Step 3 (Construímos):
#BD5A40 - Step 4 (Implantamos):
#944230 - Step 5 (Evoluímos):
#6E2D22
- Step 1 (Descobrimos):
- Typography:
Inter, system-ui, sans-serif. - Border Radius:
radius-full(9999px) for pill buttons/badges,radius-md(8px) for cards.
# 1. Environment variables
cp .env.example .env
# 2. Start core docker services
docker compose up -d
# 3. Start the optional AI service and pull host Ollama models separately
docker compose --profile local-ai up -d
ollama pull bge-m3
ollama pull qwen2.5:1.5b| Verification | Command | Location |
|---|---|---|
| Backend Migrations | npm run migrate |
backend/ |
| Backend Unit/Int Tests | npm test |
backend/ |
| Backend Integrated S1 | npm run test:integration:s1 |
backend/ |
| Backend Typecheck | npm run typecheck |
backend/ |
| Backend Security Audit | npm run audit:security |
backend/ |
| Frontend Tests | npm test |
frontend/ |
| Frontend Production Build | npm run build |
frontend/ |
| AI Service Tests | python -m unittest discover -s tests |
ai-service/ |
| n8n Workflow Sync | n8n-sync validate |
Root |
-
Active Sprint State:
- Auth JWT (login, logout, session restoration
/auth/me, role guardsadmin,po,dev) is fully operational. - Requirements hierarchy CRUD (Project, Epic, Feature, PBI, Acceptance Criteria) is complete.
- Archival cascading (
PATCH /archive) with transaction locks and impact previews is active. - Quality configuration endpoints and score calculation are live.
- Backward compatibility routes are maintained in
backend/src/modules/epics/epics.compat.routes.ts.
- Auth JWT (login, logout, session restoration
-
Binding Rules for AI Agents:
- Never guess API contracts or DB schemas. Read
database/init.sqlanddocs/api/openapi.yaml. - Preserve legacy compatibility adapters when updating backend endpoints.
- Enforce Node.js as the sole persistent writer. Python AI service sends suggestions; Node backend validates and writes.
- Enforce project isolation in all RAG / DB queries via
WHERE project_id = $1. - Always run verification commands (
npm test,npm run typecheck) after editing code.
- Never guess API contracts or DB schemas. Read