Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/user-service/README.md

rUv296a5a4ac410
diff --git a/user-service/README.md b/user-service/README.md
new file mode 100644
index 0000000000..b1c88168e4
--- /dev/null
+++ b/user-service/README.md
@@ -0,0 +1,314 @@
+# User Service
+
+A comprehensive, production-ready user management service built with Node.js, TypeScript, and Express. Features clean architecture, comprehensive testing, and Docker support.
+
+## Features
+
+- **User Management**: Complete CRUD operations for user accounts
+- **Authentication**: JWT-based authentication with secure password hashing
+- **Authorization**: Role-based access control (Admin, Moderator, User, Guest)
+- **Validation**: Comprehensive input validation using Joi
+- **Error Handling**: Centralized error handling with proper HTTP status codes
+- **Logging**: Structured logging with Winston
+- **Security**: Helmet, CORS, rate limiting, and security best practices
+- **Testing**: Unit and integration tests with Jest
+- **Docker**: Production-ready Docker configuration
+- **Documentation**: Comprehensive API documentation
+
+## Architecture
+
+```
+user-service/
+β”œβ”€β”€ src/
+β”‚ β”œβ”€β”€ config/ # Configuration management
+β”‚ β”œβ”€β”€ controllers/ # Request handlers
+β”‚ β”œβ”€β”€ middleware/ # Express middleware
+β”‚ β”œβ”€β”€ models/ # Data models
+β”‚ β”œβ”€β”€ repositories/ # Data access layer
+β”‚ β”œβ”€β”€ routes/ # API routes
+β”‚ β”œβ”€β”€ services/ # Business logic
+β”‚ β”œβ”€β”€ types/ # TypeScript types
+β”‚ β”œβ”€β”€ utils/ # Utility functions
+β”‚ β”œβ”€β”€ app.ts # Express app setup
+β”‚ └── index.ts # Server entry point
+β”œβ”€β”€ tests/
+β”‚ β”œβ”€β”€ unit/ # Unit tests
+β”‚ └── integration/ # Integration tests
+β”œβ”€β”€ docs/ # Additional documentation
+β”œβ”€β”€ scripts/ # Utility scripts
+└── package.json # Project dependencies
+```
+
+## Quick Start
+
+### Prerequisites
+
+- Node.js 18+
+- npm or yarn
+- Docker (optional)
+
+### Installation
+
+1. Clone the repository:
+```bash
+cd /workspaces/claude-code-flow/user-service
+```
+
+2. Install dependencies:
+```bash
+npm install
+```
+
+3. Create environment file:
+```bash
+cp .env.example .env
+# Edit .env with your configuration
+```
+
+4. Run in development mode:
+```bash
+npm run dev
+```
+
+5. Run tests:
+```bash
+npm test
+npm run test:coverage
+```
+
+6. Build for production:
+```bash
+npm run build
+npm start
+```
+
+### Docker Deployment
+
+1. Build and run with Docker Compose:
+```bash
+docker-compose up -d
+```
+
+2. Or build manually:
+```bash
+docker build -t user-service .
+docker run -p 3000:3000 --env-file .env user-service
+```
+
+## API Documentation
+
+### Authentication
+
+All protected endpoints require a Bearer token in the Authorization header:
+```
+Authorization: Bearer <token>
+```
+
+### Endpoints
+
+#### Public Endpoints
+
+**POST /api/register**
+Register a new user
+```json
+{
+ "email": "[email protected]",
+ "username": "johndoe",
+ "password": "SecurePass123!",
+ "firstName": "John",
+ "lastName": "Doe"
+}
+```
+
+**POST /api/login**
+Authenticate user
+```json
+{
+ "email": "[email protected]",
+ "password": "SecurePass123!"
+}
+```
+
+#### Protected Endpoints
+
+**GET /api/profile**
+Get current user profile
+- Authentication: Required
+
+**POST /api/change-password**
+Change user password
+- Authentication: Required
+```json
+{
+ "oldPassword": "OldPass123!",
+ "newPassword": "NewPass456!"
+}
+```
+
+**POST /api/verify-email**
+Verify user email
+- Authentication: Required
+
+**GET /api/users**
+List all users (paginated)
+- Authentication: Required
+- Authorization: Admin, Moderator
+- Query params: page, limit, sortBy, sortOrder, role, status, search
+
+**GET /api/users/:id**
+Get user by ID
+- Authentication: Required
+- Authorization: Owner or Admin
+
+**PUT /api/users/:id**
+Update user
+- Authentication: Required
+- Authorization: Owner or Admin
+```json
+{
+ "firstName": "Updated",
+ "lastName": "Name",
+ "avatar": "https://example.com/avatar.jpg"
+}
+```
+
+**DELETE /api/users/:id**
+Delete user
+- Authentication: Required
+- Authorization: Admin
+- Query params: soft (default: true)
+
+**GET /api/users/stats**
+Get user statistics
+- Authentication: Required
+- Authorization: Admin
+
+### Response Format
+
+Success Response:
+```json
+{
+ "success": true,
+ "data": {},
+ "message": "Operation successful"
+}
+```
+
+Error Response:
+```json
+{
+ "success": false,
+ "error": {
+ "message": "Error description"
+ }
+}
+```
+
+Paginated Response:
+```json
+{
+ "success": true,
+ "data": [],
+ "meta": {
+ "total": 100,
+ "page": 1,
+ "limit": 10,
+ "totalPages": 10
+ }
+}
+```
+
+## Configuration
+
+Environment variables (see .env.example):
+
+| Variable | Description | Default |
+|----------|-------------|---------|
+| NODE_ENV | Environment (development/production) | development |
+| PORT | Server port | 3000 |
+| HOST | Server host | localhost |
+| JWT_SECRET | Secret key for JWT tokens | Required |
+| JWT_EXPIRES_IN | Token expiration time | 24h |
+| BCRYPT_ROUNDS | Password hashing rounds | 10 |
+| LOG_LEVEL | Logging level | info |
+| CORS_ORIGIN | CORS allowed origins | * |
+| RATE_LIMIT_WINDOW_MS | Rate limit window | 900000 |
+| RATE_LIMIT_MAX_REQUESTS | Max requests per window | 100 |
+
+## Security Features
+
+- Password hashing with bcrypt
+- JWT token authentication
+- Rate limiting
+- CORS protection
+- Helmet security headers
+- Input validation
+- SQL injection prevention
+- XSS protection
+- Environment variable validation
+
+## Testing
+
+Run all tests:
+```bash
+npm test
+```
+
+Run with coverage:
+```bash
+npm run test:coverage
+```
+
+Run in watch mode:
+```bash
+npm run test:watch
+```
+
+## Scripts
+
+- `npm run dev` - Start development server with hot reload
+- `npm run build` - Build for production
+- `npm start` - Start production server
+- `npm test` - Run tests
+- `npm run lint` - Run ESLint
+- `npm run format` - Format code with Prettier
+- `npm run typecheck` - Type check with TypeScript
+
+## User Roles
+
+- **Admin**: Full system access
+- **Moderator**: User management access
+- **User**: Standard user access
+- **Guest**: Limited access
+
+## User Status
+
+- **Active**: Normal user status
+- **Inactive**: Temporarily inactive
+- **Suspended**: Account suspended
+- **Deleted**: Soft deleted
+
+## Error Codes
+
+- 400: Bad Request (validation error)
+- 401: Unauthorized (authentication required)
+- 403: Forbidden (insufficient permissions)
+- 404: Not Found
+- 409: Conflict (duplicate resource)
+- 500: Internal Server Error
+
+## Contributing
+
+1. Fork the repository
+2. Create your feature branch
+3. Commit your changes
+4. Push to the branch
+5. Create a Pull Request
+
+## License
+
+MIT
+
+## Support
+
+For issues and questions, please create an issue in the repository.
\ No newline at end of file