Files
dev-procfile/README.md
T

181 lines
5.4 KiB
Markdown

# Darano
Multi-service monorepo for the Darano financial/crypto platform.
## Services
| Process | Directory | Stack | Local Port |
|---------|-----------|-------|------------|
| `api` | `api/` | Go / Gin (REST gateway) | **8000** |
| `auth` | `auth/` | Go / gRPC | 8100 |
| `wallet` | `wallet/` | Go / gRPC | 8200 |
| `wallet-market` | `wallet/` | Go / gRPC | 8300 |
| `wallet-alert` | `wallet/` | Go / gRPC | 8400 |
| `wallet-internal` | `wallet/` | Go / gRPC | 8500 |
| `wallet-stream` | `wallet/` | Go (background) | — |
| `admin` | `AdminPanel/` | Python / Django | 8080 |
| `ui` | `ui/` | TypeScript / Next.js | 3000 |
`api` is the only public-facing HTTP service. All other Go services communicate over gRPC. `AdminPanel` reads Postgres directly.
## Prerequisites
- Go 1.22+
- Node.js 20+ with Yarn
- Python 3.11+ with [uv](https://github.com/astral-sh/uv)
- [air](https://github.com/air-verse/air) — Go hot reload (`go install github.com/air-verse/air@latest`)
- [buf](https://buf.build/docs/installation) — protobuf code generation
- [overmind](https://github.com/DarthSim/overmind) or [foreman](https://github.com/ddollar/foreman) — Procfile runner
- PostgreSQL 16, Redis, RabbitMQ running locally (or via Docker)
## Clone the Workspace
The Darano workspace is an aggregate of independent Git repositories. These
commands reproduce the current directory layout and select the branches used by
this refactor. They expect the local branches to have been pushed first and
require SSH access to `git.darano.ir`.
```bash
mkdir darano
cd darano
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/AdminPanel.git AdminPanel
git clone --branch m2 git@git.darano.ir:Kahroba/DevOps.git DevOps
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/GL.git GL
git clone --branch main git@git.darano.ir:KuknosNode/Scripts.git Kuknos-Node-scripts
git clone --branch dev git@git.darano.ir:Kahroba/alert.git alert
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/api.git api
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/auth.git auth
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/dev-procfile.git dev-procfile
git clone --branch dev git@git.darano.ir:Kahroba/docs.git docs
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/proto.git proto
git clone --branch dev git@git.darano.ir:Kahroba/ui.git ui
git clone --branch feat/refactor-v1 git@git.darano.ir:Kahroba/wallet.git wallet
```
`private-chain/` is not included because the current local repository has no
`origin` remote configured.
Recreate the root documentation links after cloning:
```bash
ln -s dev-procfile/AGENTS.md AGENTS.md
ln -s dev-procfile/CLAUDE.md CLAUDE.md
ln -s dev-procfile/README-REFACTORING.md README-REFACTORING.md
ln -s dev-procfile/README.md README.md
ln -s dev-procfile/REFACTORING-AUDIT.md REFACTORING-AUDIT.md
ln -s dev-procfile/REFACTORING-PLAN.md REFACTORING-PLAN.md
ln -s dev-procfile/REFACTORING-TODO.md REFACTORING-TODO.md
ln -s dev-procfile/گزارش-زیرساخت-توکنسازی-دارانو.md گزارش-زیرساخت-توکنسازی-دارانو.md
```
## Infrastructure
Start the shared infrastructure (Postgres, Redis, RabbitMQ, MinIO):
```bash
cd DevOps/dev
docker compose -f infra-compose.yml up -d
```
## Running Everything
From the repo root:
```bash
overmind start
# or
foreman start
```
`air` handles the initial build and restarts Go services on any `.go` file change. Next.js and Django have their own built-in reloaders.
To tail a specific service:
```bash
overmind connect api
```
## Building Protos
Each Go service and the UI depend on generated protobuf code. Run this before the first build or after any `.proto` change:
```bash
# inside each Go service directory
make build-proto
# inside ui/
yarn build-proto
```
## Individual Services
### Go services (`api`, `auth`, `wallet`)
```bash
make dep # install tools (buf, air, swag, protoc plugins)
make build # generate protos + compile binary
make dev # hot reload via air
make test # run tests
```
### Wallet sub-services (separate processes sharing one binary)
```bash
cd wallet
make dev-wallet # wallet → :8200
make dev-market # market → :8300
make dev-alert # alert → :8400 (alias; use air -c .alert.air.toml)
make dev-stream # stream
```
### AdminPanel
```bash
cd AdminPanel
uv run python src/manage.py migrate
uv run python src/manage.py runserver 0.0.0.0:8080
```
### UI
```bash
cd ui
yarn dev # starts Next.js on :3000; buf generate runs automatically
```
## Configuration
Each service reads a TOML config file loaded by `fig`:
| Service | Config file |
|---------|-------------|
| `api` | `api/cfg.toml` |
| `auth` | `auth/cfg.toml` |
| wallet | `wallet/wallet.cfg.toml` |
| market | `wallet/market.cfg.toml` |
| alert | `wallet/alert.cfg.toml` |
| internal wallet | `wallet/wallet.internal.cfg.toml` |
| stream | `wallet/cfg.toml` |
The canonical reference for all credential values is `DevOps/services/srv-dev/cfg/fig.toml` (used by Docker deployments).
JWT keys for local dev are read from `DevOps/services/srv-dev/cfg/jwt/`.
## Environment Variables (UI)
`ui/.env.development.local` is pre-configured for local development:
```
NEXT_PUBLIC_API_URL=http://localhost:8000/
NEXTAUTH_URL=http://localhost:3000/
```
## Log Directories
Go services write logs to `./log/` relative to their directory. Create these before first run:
```bash
mkdir -p api/log auth/log wallet/log
```