|
| 1 | +# XMPP.atl.chat |
| 2 | + |
| 3 | +Docker-based XMPP server with Prosody, PostgreSQL database, and automated SSL certificate management. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +| Component | Technology | Purpose | |
| 8 | +|-----------|------------|---------| |
| 9 | +| XMPP Server | Prosody 0.12.4 | XMPP daemon | |
| 10 | +| Database | PostgreSQL 16 | Data persistence | |
| 11 | +| Web Client | ConverseJS | Browser-based XMPP client | |
| 12 | +| SSL/TLS | Let's Encrypt + Cloudflare | Certificate management | |
| 13 | +| Container | Docker + Compose | Deployment | |
| 14 | + |
| 15 | +## Quick Start |
| 16 | + |
| 17 | +```bash |
| 18 | +# 1. Clone and configure |
| 19 | +git clone https://github.com/allthingslinux/xmpp.atl.chat |
| 20 | +cd xmpp.atl.chat |
| 21 | +cp .env.development .env |
| 22 | + |
| 23 | +# 2. Edit configuration |
| 24 | +# BE SURE TO READ THIS CAREFULLY AND DOUBLE CHECK ALL VARIABLES |
| 25 | +# PROSODY WILL NOT START WITHOUT PROPER DATABASE CREDENTIALS |
| 26 | +vim .env |
| 27 | + |
| 28 | +# 3. Setup Cloudflare DNS credentials |
| 29 | +cp cloudflare-credentials.ini.template cloudflare-credentials.ini |
| 30 | +chmod 600 cloudflare-credentials.ini |
| 31 | +vim cloudflare-credentials.ini # Add your Cloudflare API token |
| 32 | + |
| 33 | +# 4. Setup SSL certificates (required before starting) |
| 34 | +make ssl-setup |
| 35 | + |
| 36 | +# 5. Start services |
| 37 | +make dev |
| 38 | +``` |
| 39 | + |
| 40 | +**Note**: SSL setup must be completed before starting services, as Prosody configuration expects SSL certificates to exist. |
| 41 | + |
| 42 | +## Configuration |
| 43 | + |
| 44 | +### Environment Variables |
| 45 | + |
| 46 | +Copy `.env.development` to `.env` and configure: |
| 47 | + |
| 48 | +```bash |
| 49 | +# Server Settings |
| 50 | +PROSODY_DOMAIN=atl.chat |
| 51 | +PROSODY_C2S_PORT=5222 |
| 52 | +PROSODY_S2S_PORT=5269 |
| 53 | +PROSODY_C2S_DIRECT_TLS_PORT=5223 |
| 54 | +PROSODY_S2S_DIRECT_TLS_PORT=5270 |
| 55 | + |
| 56 | +# Network Identity |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +# SSL/TLS |
| 61 | + |
| 62 | + |
| 63 | +# Database |
| 64 | +PROSODY_DB_DRIVER=PostgreSQL |
| 65 | +PROSODY_DB_HOST=xmpp-postgres |
| 66 | +PROSODY_DB_PORT=5432 |
| 67 | +PROSODY_DB_NAME=prosody |
| 68 | +PROSODY_DB_USER=prosody |
| 69 | +PROSODY_DB_PASSWORD=your-database-password |
| 70 | +``` |
| 71 | + |
| 72 | +## Configuration Workflow |
| 73 | + |
| 74 | +Configuration files are automatically generated from templates using your `.env` file: |
| 75 | + |
| 76 | +- **Templates**: `app/config/prosody/*.template` files |
| 77 | +- **Generated**: `app/config/prosody/*.conf` files (gitignored) |
| 78 | +- **Process**: `envsubst` substitutes variables from `.env` into templates |
| 79 | +- **Automation**: `make dev` runs configuration generation automatically |
| 80 | + |
| 81 | +**Never edit the `.conf` files directly** - they will be overwritten. Always modify the `.env` file and run `make dev` to regenerate. |
| 82 | + |
| 83 | +## Commands |
| 84 | + |
| 85 | +### Service Management |
| 86 | +```bash |
| 87 | +make dev # Start development environment |
| 88 | +make prod # Start production environment |
| 89 | +make down # Stop all services |
| 90 | +make restart # Restart services |
| 91 | +make status # Check service status |
| 92 | +make logs # View all logs |
| 93 | +``` |
| 94 | + |
| 95 | +### Development |
| 96 | +```bash |
| 97 | +make dev-build # Build development containers |
| 98 | +make dev-clean # Clean development environment |
| 99 | +make test # Run test suite |
| 100 | +make lint # Run linting |
| 101 | +``` |
| 102 | + |
| 103 | +### SSL Management |
| 104 | +```bash |
| 105 | +make ssl-setup # Setup SSL certificates |
| 106 | +make ssl-status # Check certificate status |
| 107 | +make ssl-renew # Force renewal |
| 108 | +make ssl-logs # View SSL logs |
| 109 | +``` |
| 110 | + |
| 111 | +### Module Management |
| 112 | +```bash |
| 113 | +make list-modules # List available modules |
| 114 | +make enable-module # Enable a module |
| 115 | +make update-modules # Update module collection |
| 116 | +``` |
| 117 | + |
| 118 | +### Database Operations |
| 119 | +```bash |
| 120 | +make db-backup # Backup database |
| 121 | +make db-restore # Restore database |
| 122 | +``` |
| 123 | + |
| 124 | +## Project Structure |
| 125 | + |
| 126 | +``` |
| 127 | +xmpp.atl.chat/ |
| 128 | +โโโ app/ |
| 129 | +โ โโโ config/ |
| 130 | +โ โโโ prosody/ # Prosody configuration |
| 131 | +โโโ prosody-modules/ # Community modules |
| 132 | +โโโ web/ # Web client assets |
| 133 | +โ โโโ assets/ # Static files |
| 134 | +โ โโโ conversejs/ # ConverseJS web client |
| 135 | +โโโ scripts/ # Management scripts |
| 136 | +โโโ config/ # Service configurations |
| 137 | +โโโ database/ # Database initialization |
| 138 | +โโโ .runtime/ # Runtime data |
| 139 | +โ โโโ certs/ # SSL certificates |
| 140 | +โ โโโ logs/ # Service logs |
| 141 | +โ โโโ db/ # Database files |
| 142 | +โโโ tests/ # Test suite |
| 143 | +``` |
| 144 | + |
| 145 | +## Ports |
| 146 | + |
| 147 | +| Port | Protocol | Service | Purpose | |
| 148 | +|------|----------|---------|---------| |
| 149 | +| 5222 | XMPP | Prosody | Client connections | |
| 150 | +| 5269 | XMPP | Prosody | Server-to-server | |
| 151 | +| 5223 | XMPP+TLS | Prosody | Direct TLS client | |
| 152 | +| 5270 | XMPP+TLS | Prosody | Direct TLS server | |
| 153 | +| 5280 | HTTP | Prosody | HTTP upload/admin | |
| 154 | +| 5281 | HTTPS | Prosody | HTTPS upload/admin | |
| 155 | +| 8080 | HTTP | Web Client | ConverseJS interface | |
| 156 | + |
| 157 | +## Usage |
| 158 | + |
| 159 | +### Connect to XMPP |
| 160 | + |
| 161 | +```bash |
| 162 | +# Standard XMPP connection |
| 163 | + |
| 164 | + |
| 165 | +# Web client |
| 166 | +# URL: http://your-server:8080 |
| 167 | +``` |
| 168 | + |
| 169 | +### Web Interface |
| 170 | + |
| 171 | +- URL: `http://your-server:8080` |
| 172 | +- Purpose: Browser-based XMPP client |
| 173 | + |
| 174 | +### XMPP Services |
| 175 | + |
| 176 | +- **Registration**: Account creation (if enabled) |
| 177 | +- **MUC**: Multi-user chat rooms |
| 178 | +- **HTTP Upload**: File sharing |
| 179 | +- **Push Notifications**: Mobile notifications |
| 180 | + |
| 181 | +## Troubleshooting |
| 182 | + |
| 183 | +### Services Not Starting |
| 184 | +```bash |
| 185 | +make logs |
| 186 | +make status |
| 187 | +``` |
| 188 | + |
| 189 | +### SSL Issues |
| 190 | +```bash |
| 191 | +make ssl-status |
| 192 | +make ssl-logs |
| 193 | +``` |
| 194 | + |
| 195 | +### Configuration Issues |
| 196 | +```bash |
| 197 | +make restart |
| 198 | +# Check if configuration was generated properly |
| 199 | +ls -la app/config/prosody/prosody.cfg.lua |
| 200 | + |
| 201 | +# If configs are missing, regenerate from templates |
| 202 | +make dev-build |
| 203 | +``` |
| 204 | + |
| 205 | +## Development |
| 206 | + |
| 207 | +### Running Tests |
| 208 | +```bash |
| 209 | +make test |
| 210 | +``` |
| 211 | + |
| 212 | +#### Test Structure |
| 213 | +XMPP.atl.chat uses a comprehensive testing framework organized by testing level: |
| 214 | + |
| 215 | +- **`tests/unit/`** - Unit tests for individual components |
| 216 | + - Configuration validation, Docker setup, environment testing |
| 217 | +- **`tests/integration/`** - Integration tests using controlled XMPP servers |
| 218 | + - `test_protocol.py` - XMPP protocol compliance (RFC6120, RFC6121) |
| 219 | + - `test_clients.py` - Client library integration |
| 220 | + - `test_services.py` - Service integration (MUC, HTTP upload) |
| 221 | + - `test_monitoring.py` - Server monitoring and admin functionality |
| 222 | + - `test_performance.py` - Performance and load testing |
| 223 | + - `test_infrastructure.py` - Infrastructure and deployment tests |
| 224 | +- **`tests/e2e/`** - End-to-end workflow tests |
| 225 | + |
| 226 | +### Linting |
| 227 | +```bash |
| 228 | +make lint |
| 229 | +``` |
| 230 | + |
| 231 | +### Building |
| 232 | +```bash |
| 233 | +make dev-build |
| 234 | +``` |
| 235 | + |
| 236 | +## Documentation |
| 237 | + |
| 238 | +### ๐ Getting Started |
| 239 | +- [Quick Start](README.md#quick-start) - Basic installation and setup |
| 240 | +- [Configuration](README.md#configuration) - Environment variables and settings |
| 241 | +- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions |
| 242 | + |
| 243 | +### ๐๏ธ Core Components |
| 244 | +- [Prosody Server](./docs/PROSODY.md) - XMPP server configuration and management |
| 245 | +- [Modules](./docs/MODULES.md) - Prosody module system and third-party extensions |
| 246 | +- [Web Client](./docs/WEBCLIENT.md) - ConverseJS configuration and customization |
| 247 | +- [Database](./docs/DATABASE.md) - PostgreSQL setup and management |
| 248 | + |
| 249 | +### ๐ณ Infrastructure |
| 250 | +- [Docker Setup](./docs/DOCKER.md) - Containerization, volumes, and networking |
| 251 | +- [Makefile Commands](./docs/MAKE.md) - Build automation and management commands |
| 252 | +- [Configuration](./docs/CONFIG.md) - Template system and environment variables |
| 253 | +- [CI/CD Pipeline](./docs/CI_CD.md) - GitHub Actions workflows and automation |
| 254 | +- [Testing](./docs/TESTING.md) - Comprehensive test suite and framework |
| 255 | + |
| 256 | +### ๐ Security & Operations |
| 257 | +- [SSL Certificates](./docs/SSL.md) - Let's Encrypt automation and certificate management |
| 258 | +- [Secret Management](./docs/SECRET_MANAGEMENT.md) - Passwords, API tokens, and security practices |
| 259 | +- [Backup & Recovery](./docs/BACKUP_RECOVERY.md) - Data protection and disaster recovery |
| 260 | + |
| 261 | +### ๐ APIs & Integration |
| 262 | +- [API Reference](./docs/API.md) - HTTP API and admin interface |
| 263 | +- [Scripts](./docs/SCRIPTS.md) - Management and utility scripts |
| 264 | + |
| 265 | +### ๐ ๏ธ Development |
| 266 | +- [Development Guide](./docs/DEVELOPMENT.md) - Local setup, contribution guidelines, and workflow |
| 267 | + |
| 268 | +## License |
| 269 | + |
| 270 | +Apache License 2.0 |
0 commit comments