# rafaelm229/moura-solar architecture

> Architecture diagram of the GitHub repository rafaelm229/moura-solar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rafaelm229/moura-solar
- Repository: https://github.com/rafaelm229/moura-solar

## Overview

Moura Solar is an integrated solar-project CRM and operations platform. Users work through a web interface backed by a NestJS API: the documented business stages span customer/opportunity management, design and sizing, proposals and contracts, finance and procurement, engineering and installation, then after-sales support. Identity and permissions govern access across these capabilities. The README describes the integrated process, but most feature implementations were not sampled; dashed links mark documented or plausible connections without source-level relationship evidence.

Main entry points: [`apps/api/src/database/prisma.service.ts`](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/database/prisma.service.ts) (PostgreSQL data), [`apps/api/src/proposal/proposal.service.ts`](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/proposal/proposal.service.ts) (Proposal generation), [`apps/api/src/commercial/commercial.service.ts`](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/commercial/commercial.service.ts) (Customers and opportunities), [`apps/api/src/design/design.service.ts`](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/design/design.service.ts) (Sizing and costs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_identity_web["Identity screens"]
  node_identity_client["API client<br/>[client.ts]"]
  node_identity_api["Authentication and RBAC<br/>[auth.service.ts]"]
  node_identity_guard["Permission guard<br/>[identity.guard.ts]"]
end

subgraph group_commercial["Commercial journey"]
  node_commercial_web["CRM workspace"]
  node_commercial_api["Customers and opportunities"]
  node_design_web["Solar design"]
  node_design_api["Sizing and costs<br/>[design.service.ts]"]
  node_proposal_web["Proposals<br/>[proposals.tsx]"]
  node_proposal_api["Proposal generation"]
  node_contract_web["Contracts<br/>[contracts.tsx]"]
  node_contract_api["Contract management"]
end

subgraph group_delivery["Project delivery"]
  node_engineering_web["Engineering workspace<br/>[engineering.tsx]"]
  node_engineering_api["Engineering and installation"]
  node_aftersales_web["After-sales workspace<br/>[after-sales.tsx]"]
  node_aftersales_api["Support and monitoring"]
end

subgraph group_operations["Operations and governance"]
  node_financial_web["Financial workspace<br/>[financial.tsx]"]
  node_financial_api["Financial governance"]
  node_inventory_web["Inventory workspace<br/>[inventory.tsx]"]
  node_inventory_api["Inventory and purchasing"]
  node_automation_web["Automation console<br/>[automations.tsx]"]
  node_automation_api["Versioned automations"]
  node_database[("PostgreSQL data<br/>[prisma.service.ts]")]
  node_object_storage[("S3 or MinIO files<br/>[storage.service.ts]")]
end

node_user(("Platform user"))

node_user -.->|"signs in"| node_identity_web
node_user -.->|"manages customers"| node_commercial_web
node_user -.->|"designs systems"| node_design_web
node_user -.->|"prepares proposals"| node_proposal_web
node_user -.->|"manages contracts"| node_contract_web
node_user -.->|"reviews finances"| node_financial_web
node_user -.->|"manages stock"| node_inventory_web
node_user -.->|"runs projects"| node_engineering_web
node_user -.->|"handles support"| node_aftersales_web
node_user -.->|"configures rules"| node_automation_web
node_identity_web -.->|"uses"| node_identity_client
node_identity_client -.->|"authenticates"| node_identity_api
node_identity_api -->|"provides context"| node_identity_guard
node_identity_guard -.->|"guards access"| node_commercial_api
node_identity_guard -->|"guards access"| node_engineering_api
node_commercial_web -.->|"calls API"| node_commercial_api
node_commercial_api -.->|"reads and writes"| node_database
node_design_web -.->|"calls API"| node_design_api
node_design_api -.->|"reads and writes"| node_database
node_proposal_web -.->|"calls API"| node_proposal_api
node_proposal_api -.->|"reads and writes"| node_database
node_proposal_api -.->|"stores documents"| node_object_storage
node_contract_web -.->|"calls API"| node_contract_api
node_contract_api -.->|"reads and writes"| node_database
node_financial_web -.->|"calls API"| node_financial_api
node_financial_api -.->|"reads and writes"| node_database
node_inventory_web -.->|"calls API"| node_inventory_api
node_inventory_api -.->|"reads and writes"| node_database
node_engineering_web -->|"calls API"| node_engineering_api
node_engineering_api -->|"reads and writes"| node_database
node_aftersales_web -.->|"calls API"| node_aftersales_api
node_aftersales_api -->|"reads and writes"| node_database
node_automation_web -.->|"calls API"| node_automation_api
node_automation_api -->|"reads and writes"| node_database
node_commercial_api -.->|"advances journey"| node_design_api
node_design_api -.->|"supports proposals"| node_proposal_api
node_proposal_api -.->|"leads to contracts"| node_contract_api
node_contract_api -.->|"gates finance"| node_financial_api
node_engineering_api -.->|"continues to support"| node_aftersales_api

click node_identity_web "https://github.com/rafaelm229/moura-solar/tree/main/apps/web/src/features/identity"
click node_identity_client "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/identity/client.ts"
click node_identity_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/identity/auth.service.ts"
click node_identity_guard "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/identity/identity.guard.ts"
click node_commercial_web "https://github.com/rafaelm229/moura-solar/tree/main/apps/web/src/features/commercial"
click node_commercial_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/commercial/commercial.service.ts"
click node_design_web "https://github.com/rafaelm229/moura-solar/tree/main/apps/web/src/features/design"
click node_design_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/design/design.service.ts"
click node_proposal_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/proposal/proposals.tsx"
click node_proposal_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/proposal/proposal.service.ts"
click node_contract_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/contract/contracts.tsx"
click node_contract_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/contract/contract.service.ts"
click node_financial_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/financial/financial.tsx"
click node_financial_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/financial/financial.service.ts"
click node_inventory_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/inventory/inventory.tsx"
click node_inventory_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/inventory/inventory.service.ts"
click node_engineering_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/engineering/engineering.tsx"
click node_engineering_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/engineering/engineering.service.ts"
click node_aftersales_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/after-sales/after-sales.tsx"
click node_aftersales_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/after-sales/after-sales.service.ts"
click node_automation_web "https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/automations/automations.tsx"
click node_automation_api "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/automations/automations.service.ts"
click node_database "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/database/prisma.service.ts"
click node_object_storage "https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/proposal/storage.service.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_identity_web,node_identity_client,node_identity_api,node_identity_guard,node_user toneBlue
class node_commercial_web,node_commercial_api,node_design_web,node_design_api,node_proposal_web,node_proposal_api,node_contract_web,node_contract_api toneAmber
class node_engineering_web,node_engineering_api,node_aftersales_web,node_aftersales_api toneMint
class node_financial_web,node_financial_api,node_inventory_web,node_inventory_api,node_automation_web,node_automation_api,node_database,node_object_storage toneRose
```

## Components

### Identity and access

- [Identity screens](https://github.com/rafaelm229/moura-solar/tree/main/apps/web/src/features/identity): `apps/web/src/features/identity`
- [API client](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/identity/client.ts): `apps/web/src/features/identity/client.ts`
- [Authentication and RBAC](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/identity/auth.service.ts): `apps/api/src/identity/auth.service.ts`
- [Permission guard](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/identity/identity.guard.ts): `apps/api/src/identity/identity.guard.ts`

### Commercial journey

- [CRM workspace](https://github.com/rafaelm229/moura-solar/tree/main/apps/web/src/features/commercial): `apps/web/src/features/commercial`
- [Customers and opportunities](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/commercial/commercial.service.ts): `apps/api/src/commercial/commercial.service.ts`
- [Solar design](https://github.com/rafaelm229/moura-solar/tree/main/apps/web/src/features/design): `apps/web/src/features/design`
- [Sizing and costs](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/design/design.service.ts): `apps/api/src/design/design.service.ts`
- [Proposals](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/proposal/proposals.tsx): `apps/web/src/features/proposal/proposals.tsx`
- [Proposal generation](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/proposal/proposal.service.ts): `apps/api/src/proposal/proposal.service.ts`
- [Contracts](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/contract/contracts.tsx): `apps/web/src/features/contract/contracts.tsx`
- [Contract management](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/contract/contract.service.ts): `apps/api/src/contract/contract.service.ts`

### Project delivery

- [Engineering workspace](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/engineering/engineering.tsx): `apps/web/src/features/engineering/engineering.tsx`
- [Engineering and installation](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/engineering/engineering.service.ts): `apps/api/src/engineering/engineering.service.ts`
- [After-sales workspace](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/after-sales/after-sales.tsx): `apps/web/src/features/after-sales/after-sales.tsx`
- [Support and monitoring](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/after-sales/after-sales.service.ts): `apps/api/src/after-sales/after-sales.service.ts`

### Operations and governance

- [Financial workspace](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/financial/financial.tsx): `apps/web/src/features/financial/financial.tsx`
- [Financial governance](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/financial/financial.service.ts): `apps/api/src/financial/financial.service.ts`
- [Inventory workspace](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/inventory/inventory.tsx): `apps/web/src/features/inventory/inventory.tsx`
- [Inventory and purchasing](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/inventory/inventory.service.ts): `apps/api/src/inventory/inventory.service.ts`
- [Automation console](https://github.com/rafaelm229/moura-solar/blob/main/apps/web/src/features/automations/automations.tsx): `apps/web/src/features/automations/automations.tsx`
- [Versioned automations](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/automations/automations.service.ts): `apps/api/src/automations/automations.service.ts`
- [PostgreSQL data](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/database/prisma.service.ts): `apps/api/src/database/prisma.service.ts`
- [S3 or MinIO files](https://github.com/rafaelm229/moura-solar/blob/main/apps/api/src/proposal/storage.service.ts): `apps/api/src/proposal/storage.service.ts`

### Other components

- **Platform user**

## Connections

- Platform user → Identity screens: signs in
- Platform user → CRM workspace: manages customers (evidence: `README.md`)
- Platform user → Solar design: designs systems (evidence: `README.md`)
- Platform user → Proposals: prepares proposals (evidence: `README.md`)
- Platform user → Contracts: manages contracts (evidence: `README.md`)
- Platform user → Financial workspace: reviews finances (evidence: `README.md`)
- Platform user → Inventory workspace: manages stock (evidence: `README.md`)
- Platform user → Engineering workspace: runs projects (evidence: `README.md`)
- Platform user → After-sales workspace: handles support (evidence: `README.md`)
- Platform user → Automation console: configures rules (evidence: `README.md`)
- Identity screens → API client: uses (evidence: `apps/web/src/features/identity/sessions.tsx`)
- API client → Authentication and RBAC: authenticates
- Authentication and RBAC → Permission guard: provides context (evidence: `apps/api/src/identity/identity.guard.ts`)
- Permission guard → Customers and opportunities: guards access
- Permission guard → Engineering and installation: guards access (evidence: `apps/api/src/engineering/engineering.controller.ts`)
- CRM workspace → Customers and opportunities: calls API
- Customers and opportunities → PostgreSQL data: reads and writes
- Solar design → Sizing and costs: calls API
- Sizing and costs → PostgreSQL data: reads and writes
- Proposals → Proposal generation: calls API
- Proposal generation → PostgreSQL data: reads and writes
- Proposal generation → S3 or MinIO files: stores documents
- Contracts → Contract management: calls API
- Contract management → PostgreSQL data: reads and writes (evidence: `apps/api/src/contract/contract.service.ts`)
- Financial workspace → Financial governance: calls API
- Financial governance → PostgreSQL data: reads and writes
- Inventory workspace → Inventory and purchasing: calls API
- Inventory and purchasing → PostgreSQL data: reads and writes
- Engineering workspace → Engineering and installation: calls API (evidence: `apps/web/src/features/engineering/engineering.tsx`)
- Engineering and installation → PostgreSQL data: reads and writes (evidence: `apps/api/src/engineering/engineering.service.ts`)
- After-sales workspace → Support and monitoring: calls API
- Support and monitoring → PostgreSQL data: reads and writes (evidence: `apps/api/src/after-sales/after-sales.service.ts`)
- Automation console → Versioned automations: calls API
- Versioned automations → PostgreSQL data: reads and writes (evidence: `apps/api/src/automations/automations.service.ts`)
- Customers and opportunities → Sizing and costs: advances journey (evidence: `README.md`)
- Sizing and costs → Proposal generation: supports proposals (evidence: `README.md`)
- Proposal generation → Contract management: leads to contracts (evidence: `README.md`)
- Contract management → Financial governance: gates finance (evidence: `README.md`)
- Engineering and installation → Support and monitoring: continues to support (evidence: `README.md`)
