feat(architecture): add complete technical architecture for SimpleNote
- ARCHITECTURE.md: main architecture document - api-spec.yaml: full OpenAPI 3.0 spec - folder-structure.md: detailed folder layout - data-format.md: JSON schemas for .meta.json, .library.json, .tag-index.json - env-template.md: environment variables documentation - cli-protocol.md: CLI-to-API communication protocol
This commit is contained in:
116
env-template.md
Normal file
116
env-template.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# SimpleNote - Variables de Entorno
|
||||
|
||||
## Template: `.env.example`
|
||||
|
||||
Copia este archivo a `.env` en la raíz de `simplenote-web/`.
|
||||
|
||||
```env
|
||||
# ============ SERVER ============
|
||||
PORT=3000
|
||||
HOST=0.0.0.0
|
||||
|
||||
# ============ DATA ============
|
||||
# Raíz donde se almacenan documentos y archivos de índice
|
||||
# Default: ./data (relativo al proyecto)
|
||||
DATA_ROOT=./data
|
||||
|
||||
# ============ AUTH ============
|
||||
# Token admin inicial (generado en setup). No exponer en cliente.
|
||||
ADMIN_TOKEN=snk_initial_admin_token_change_me
|
||||
|
||||
# ============ LOGGING ============
|
||||
LOG_LEVEL=info
|
||||
# Opciones: trace, debug, info, warn, error, fatal
|
||||
|
||||
# ============ CORS ============
|
||||
# Orígenes permitidos para requests cross-origin
|
||||
# Default: * (permitir todos)
|
||||
CORS_ORIGIN=*
|
||||
|
||||
# Para desarrollo local:
|
||||
# CORS_ORIGIN=http://localhost:5173
|
||||
|
||||
# Para producción:
|
||||
# CORS_ORIGIN=https://simplenote.example.com
|
||||
|
||||
# ============ API ============
|
||||
# Versión del API en URLs
|
||||
API_PREFIX=/api/v1
|
||||
|
||||
# ============ RATE LIMITING (opcional) ============
|
||||
# Requests por minuto por IP
|
||||
# RATE_LIMIT_ENABLED=true
|
||||
# RATE_LIMIT_WINDOW_MS=60000
|
||||
# RATE_LIMIT_MAX=100
|
||||
```
|
||||
|
||||
## Detalle de Variables
|
||||
|
||||
### `PORT`
|
||||
- **Tipo**: integer
|
||||
- **Default**: `3000`
|
||||
- **Descripción**: Puerto TCP donde Express escucha conexiones entrantes.
|
||||
|
||||
### `HOST`
|
||||
- **Tipo**: string
|
||||
- **Default**: `0.0.0.0`
|
||||
- **Descripción**: Host de binding. `0.0.0.0` = todas las interfaces.
|
||||
|
||||
### `DATA_ROOT`
|
||||
- **Tipo**: string (ruta)
|
||||
- **Default**: `./data`
|
||||
- **Descripción**: Directorio raíz donde se guardan:
|
||||
- `libraries/` — estructura de carpetas con documentos
|
||||
- `.tag-index.json` — índice global de tags
|
||||
- `.auth-tokens.json` — tokens de API
|
||||
|
||||
### `LOG_LEVEL`
|
||||
- **Tipo**: enum
|
||||
- **Default**: `info`
|
||||
- **Opciones**: `trace`, `debug`, `info`, `warn`, `error`, `fatal`
|
||||
- **Descripción**: Nivel mínimo de logs que se emiten.
|
||||
|
||||
### `CORS_ORIGIN`
|
||||
- **Tipo**: string
|
||||
- **Default**: `*`
|
||||
- **Descripción**: Valor del header `Access-Control-Allow-Origin`. Usar dominio
|
||||
específico en producción para seguridad.
|
||||
|
||||
### `API_PREFIX`
|
||||
- **Tipo**: string
|
||||
- **Default**: `/api/v1`
|
||||
- **Descripción**: Prefijo para todas las rutas del API. Cambiar permite versionado.
|
||||
|
||||
---
|
||||
|
||||
## CLI Config: `~/.config/simplenote/config.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"apiUrl": "http://localhost:3000/api/v1",
|
||||
"token": "snk_your_token_here",
|
||||
"activeLibrary": "550e8400-e29b-41d4-a716-446655440000"
|
||||
}
|
||||
```
|
||||
|
||||
| Campo | Descripción |
|
||||
|-------|-------------|
|
||||
| `apiUrl` | URL base del API (sin trailing slash) |
|
||||
| `token` | Token Bearer para autenticación |
|
||||
| `activeLibrary` | ID de librería activa por defecto |
|
||||
|
||||
---
|
||||
|
||||
## Flags de Línea de Comandos (CLI)
|
||||
|
||||
```bash
|
||||
# Override apiUrl
|
||||
simplenote --api-url http://custom:3000/api/v1 doc list
|
||||
|
||||
# Modo verbose
|
||||
simplenote --verbose doc list
|
||||
|
||||
# Help
|
||||
simplenote help
|
||||
simplenote doc help create
|
||||
```
|
||||
Reference in New Issue
Block a user