# Sendico [![Build Status](https://ci.sendico.io/api/badges/1/status.svg?branch=main)](https://ci.sendico.io/repos/1)


Financial services platform providing payment orchestration, ledger accounting, FX conversion, and multi-rail payment processing.

## Architecture

- **Backend**: Go microservices with gRPC inter-service communication
- **Frontend**: Flutter/Dart web application
- **Infrastructure**: Woodpecker CI/CD, Docker, MongoDB, NATS, Vault

## Services

| Service | Path | Description |
|---------|------|-------------|
| Discovery | `api/discovery/` | Service registry |
| Ledger | `api/ledger/` | Double-entry accounting |
| Orchestrator | `api/payments/orchestrator/` | Payment orchestration |
| Quotation | `api/payments/quotation/` | Payment quotation |
| Billing Fees | `api/billing/fees/` | Fee calculation |
| Billing Documents | `api/billing/documents/` | Billing documents |
| FX Oracle | `api/fx/oracle/` | FX quote provider |
| FX Ingestor | `api/fx/ingestor/` | FX rate ingestion |
| Gateway Chain | `api/gateway/chain/` | EVM blockchain gateway |
| Gateway TRON | `api/gateway/tron/` | TRON blockchain gateway |
| Gateway MNTX | `api/gateway/mntx/` | Card payouts |
| Gateway TGSettle | `api/gateway/tgsettle/` | Settlements |
| Notification | `api/notification/` | Notifications |
| BFF | `api/server/` | Backend for frontend |
| Frontend | `frontend/pweb/` | Flutter web UI |

## Development

Development uses Docker Compose via the Makefile. Run `make help` for all available commands.

### Quick Start

```bash
make init       # First-time setup (generates keys, .env.dev, builds images)
make up         # Start all services
make vault-init # Initialize Vault (if needed)
```

### Common Commands

```bash
make build                # Build all service images
make up                   # Start all services
make down                 # Stop all services
make restart              # Restart all services
make status               # Show service status
make logs                 # View all logs
make logs SERVICE=dev-ledger  # View logs for a specific service
make rebuild SERVICE=dev-ledger # Rebuild and restart a specific service
make clean                # Remove all containers and volumes
```

### Selective Start

```bash
make infra-up      # Start infrastructure only (MongoDB, NATS, Vault)
make services-up   # Start application services only (assumes infra is running)
```

### Build Groups

```bash
make build-core       # discovery, ledger, fees, documents
make build-fx         # oracle, ingestor
make build-payments   # orchestrator
make build-gateways   # chain, tron, mntx, tgsettle
make build-api        # notification, bff
make build-frontend   # Flutter web UI
```

### Code Generation

```bash
make generate            # Generate all code (protobuf + Flutter)
make generate-api        # Generate protobuf code only
make generate-frontend   # Generate Flutter code only (build_runner)
make proto               # Alias for generate-api
```

### Testing

```bash
make test           # Run all tests (API + frontend)
make test-api       # Run Go API tests only
make test-frontend  # Run Flutter tests only
```

### Update Dependencies

```bash
make update            # Update all Go and Flutter dependencies
make update-api        # Update Go dependencies only
make update-frontend   # Update Flutter dependencies only
```
