fix #16: cleanup - remove old/dead code and update docs
- Delete apps/telegram-bot/storage.py (replaced by adapters/storage/json_file.py) - Delete apps/telegram-bot/__init__.py (empty file) - Delete apps/telegram-bot/requirements-dev.txt (dev deps in pyproject.toml) - Update SPEC.md with new hexagonal architecture (core, adapters, apps) - Update SPEC.md command reference: /update -> /edit - Update README.md with new project structure and quick start - Update CONTRIBUTING.md with new architecture and dev setup
This commit is contained in:
59
SPEC.md
59
SPEC.md
@@ -20,7 +20,7 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
|
||||
### Stack
|
||||
- **Bot**: `python-telegram-bot` (pure Python, no C extensions)
|
||||
- **Storage**: Per-group JSON files (zero-setup, no DB server)
|
||||
- **Storage**: Per-group JSON files via `adapters/storage/json_file.py`
|
||||
- **Date parsing**: `dateparser`
|
||||
- **Runtime**: Python 3.10+
|
||||
- **Deployment**: Any $5 VPS with Python 3.10+
|
||||
@@ -28,19 +28,40 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
~/.jigaido/ # Data root (~/.jigaido/)
|
||||
├── {group_id}/
|
||||
│ ├── group.json # Group bounties
|
||||
│ └── {user_id}.json # User tracking within this group
|
||||
└── {user_id}/
|
||||
└── user.json # User's personal bounties (DM mode)
|
||||
jigaido/
|
||||
├── core/ # Domain layer
|
||||
│ ├── models.py # Domain dataclasses (Bounty, Tracking)
|
||||
│ ├── ports.py # Port interfaces (abstract base classes)
|
||||
│ └── services.py # Domain services (BountyService, TrackingService)
|
||||
├── adapters/ # Infrastructure adapters
|
||||
│ └── storage/
|
||||
│ └── json_file.py # JSON file storage implementation
|
||||
├── apps/
|
||||
│ └── telegram-bot/ # Telegram bot CLI application
|
||||
│ ├── bot.py # Bot entry point
|
||||
│ └── commands.py # Command handlers
|
||||
├── config.py # Configuration management
|
||||
└── tests/ # Unit tests
|
||||
```
|
||||
|
||||
**Note:** Data directory is at `~/.jigaido/` (home directory), NOT inside the repository or app directory.
|
||||
### Hexagonal Architecture
|
||||
|
||||
### Storage Design
|
||||
- **Core** (`core/`): Pure domain logic, no external dependencies
|
||||
- `models.py`: Domain dataclasses
|
||||
- `ports.py`: Abstract interfaces for storage
|
||||
- `services.py`: Business logic
|
||||
|
||||
**File: `data/{group_id}/group.json`**
|
||||
- **Adapters** (`adapters/`): Implementations of ports
|
||||
- `storage/json_file.py`: JSON file-based storage
|
||||
|
||||
- **Apps** (`apps/`): CLI applications
|
||||
- `telegram-bot/`: Telegram bot interface
|
||||
|
||||
### Data Storage
|
||||
|
||||
Data is stored at `~/.jigaido/` (home directory), NOT inside the repository.
|
||||
|
||||
**File: `~/.jigaido/{group_id}/group.json`**
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -58,7 +79,7 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
}
|
||||
```
|
||||
|
||||
**File: `data/{group_id}/{user_id}.json`**
|
||||
**File: `~/.jigaido/{group_id}/{user_id}.json`**
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -68,7 +89,7 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
}
|
||||
```
|
||||
|
||||
**File: `data/{user_id}/user.json`**
|
||||
**File: `~/.jigaido/{user_id}/user.json`**
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -87,10 +108,10 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
|
||||
**Key design decisions:**
|
||||
|
||||
1. **Group-isolated storage** — Each group has its own directory. No cross-group access.
|
||||
2. **Bounty IDs are sequential per group.json** — Not global. Each group's file has its own ID counter.
|
||||
3. **Atomic writes** — Uses `tempfile` + `rename` for safe writes.
|
||||
4. **No reminders in v1** — Dropped for simplicity.
|
||||
1. **Hexagonal architecture** — Core domain is isolated from infrastructure
|
||||
2. **Group-isolated storage** — Each group has its own directory. No cross-group access.
|
||||
3. **Bounty IDs are sequential per group.json** — Not global. Each group's file has its own ID counter.
|
||||
4. **Atomic writes** — Uses `tempfile` + `rename` for safe writes.
|
||||
|
||||
---
|
||||
## Commands
|
||||
@@ -102,7 +123,7 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
| `/bounty` | anyone | List all bounties in this group |
|
||||
| `/my` | anyone | List bounties tracked by you in this group |
|
||||
| `/add <text> [link] [due date]` | anyone | Add a new bounty to the group |
|
||||
| `/update <bounty_id> [text] [link] [due_date]` | creator only | Update an existing bounty |
|
||||
| `/edit <bounty_id> [text] [link] [due_date]` | creator only | Edit an existing bounty |
|
||||
| `/delete <bounty_id>` | creator only | Delete a bounty |
|
||||
| `/track <bounty_id>` | anyone | Track a group bounty |
|
||||
| `/untrack <bounty_id>` | anyone | Stop tracking a bounty |
|
||||
@@ -114,7 +135,7 @@ JIGAIDO is a Telegram bot that lets groups and individuals track bounties — ta
|
||||
| `/bounty` | List all your personal bounties |
|
||||
| `/my` | List all your personal bounties |
|
||||
| `/add <text> [link] [due date]` | Add a personal bounty |
|
||||
| `/update <bounty_id> [text] [link] [due_date]` | Update a personal bounty |
|
||||
| `/edit <bounty_id> [text] [link] [due_date]` | Edit a personal bounty |
|
||||
| `/delete <bounty_id>` | Delete a personal bounty |
|
||||
| `/track <bounty_id>` | Track a personal bounty |
|
||||
|
||||
@@ -149,7 +170,7 @@ Stored as Unix timestamp. User-facing display can be localized/converted to any
|
||||
## Error Handling
|
||||
|
||||
- Unknown command → help text with available commands
|
||||
- `/update`/`/delete` by non-creator → "⛔ Only the creator can edit/delete this bounty."
|
||||
- `/edit`/`/delete` by non-creator → "⛔ Only the creator can edit/delete this bounty."
|
||||
- `/track` already tracked → "Already tracking" (idempotent)
|
||||
- `/untrack` not tracked → "Not tracking" (idempotent)
|
||||
- Bounty not found → "Bounty not found"
|
||||
|
||||
Reference in New Issue
Block a user