{"id":42340377,"url":"https://github.com/sendhello/order-service","last_synced_at":"2026-01-27T14:46:41.158Z","repository":{"id":312544963,"uuid":"1047708671","full_name":"sendhello/order-service","owner":"sendhello","description":"A microservice for managing orders with multi-tenant architecture support.","archived":false,"fork":false,"pushed_at":"2026-01-19T04:10:53.000Z","size":282,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-19T13:33:25.125Z","etag":null,"topics":["fastapi","orders"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sendhello.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-31T03:27:26.000Z","updated_at":"2025-08-31T11:20:06.000Z","dependencies_parsed_at":"2025-08-31T13:16:35.557Z","dependency_job_id":"7e7a8a40-074a-4a03-adf6-fc86a25a646b","html_url":"https://github.com/sendhello/order-service","commit_stats":null,"previous_names":["sendhello/order-service"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sendhello/order-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendhello%2Forder-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendhello%2Forder-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendhello%2Forder-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendhello%2Forder-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sendhello","download_url":"https://codeload.github.com/sendhello/order-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendhello%2Forder-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28815380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","orders"],"created_at":"2026-01-27T14:46:40.554Z","updated_at":"2026-01-27T14:46:41.147Z","avatar_url":"https://github.com/sendhello.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Order Service\n\n[![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/release/python-3130/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.115.14-green.svg)](https://fastapi.tiangolo.com/)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE.md)\n[![CodeQL](https://github.com/sendhello/order-service/actions/workflows/codeql.yml/badge.svg)](https://github.com/sendhello/order-service/actions/workflows/codeql.yml)\n\nA microservice for managing orders with multi-tenant architecture support.\n\n## Table of Contents\n\n- [Features](#features)\n- [Tech Stack](#tech-stack)\n- [Architecture](#architecture)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API Documentation](#api-documentation)\n- [Development](#development)\n- [Testing](#testing)\n- [Environment Variables](#environment-variables)\n- [Deployment](#deployment)\n- [Security](#security)\n- [Contributing](#contributing)\n- [License](#license)\n- [Authors](#authors)\n\n## Features\n\n- 🚚 **Order Management**: Create, read, update, and delete delivery orders\n- 👥 **Multi-tenant Architecture**: Support for multiple organizations\n- 📦 **Package Details**: Detailed package information including dimensions and weight\n- 📍 **Location Tracking**: GPS coordinates for pickup and delivery locations\n- 🕐 **Time Windows**: Flexible delivery time scheduling\n- 💳 **Payment Integration**: Multiple payment methods support\n- 🔐 **JWT Authentication**: Secure API access\n- 📊 **Distributed Tracing**: OpenTelemetry integration with Jaeger\n- 🔍 **Order Tracking**: Real-time order status tracking\n- 📱 **RESTful API**: Clean and well-documented API endpoints\n\n## Tech Stack\n\n- **Backend Framework**: [FastAPI](https://fastapi.tiangolo.com/) 0.115.14\n- **Language**: Python 3.13\n- **Database**: PostgreSQL with [SQLAlchemy](https://www.sqlalchemy.org/) ORM\n- **Cache**: Redis\n- **Authentication**: JWT with async-fastapi-jwt-auth\n- **Migration**: Alembic\n- **Validation**: Pydantic v2\n- **Tracing**: OpenTelemetry + Jaeger\n- **ASGI Server**: Uvicorn\n- **Containerization**: Docker \u0026 Docker Compose\n\n## Architecture\n\n```\n  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐\n  │   Client Apps   │    │   Web Client    │    │   Mobile Apps   │\n  └─────────┬───────┘    └────────┬────────┘    └─────────┬───────┘\n            │                     │                       │\n            └─────────────────────┼───────────────────────┘\n                                  │\n                    ┌─────────────┴─────────────┐\n                    │      Auth Service         │\n                    │   (FastAPI + JWT + OAuth) │\n                    └─────────────┬─────────────┘\n                                  │\n                    ┌─────────────┴─────────────┐\n                    │    Order Service          │\n                    │  (Consumes JWT tokens)    │\n                    └───────────────────────────┘\n                                  │\n              ┌───────────────────┼───────────────────┐\n              │                   │                   │\n    ┌─────────▼─────────┐ ┌───────▼────────┐ ┌────────▼─────────┐\n    │   PostgreSQL      │ │     Redis      │ │   Other Services │\n    │   (Order Data)    │ │    (Cache)     │ │ (Future Services)│\n    └───────────────────┘ └────────────────┘ └──────────────────┘\n```\n\n## Prerequisites\n\n- **Python**: 3.13 or higher\n- **Docker**: 20.10 or higher\n- **Docker Compose**: 2.0 or higher\n- **PostgreSQL**: 14 or higher (if running locally)\n- **Redis**: 6.2 or higher (if running locally)\n\n## Installation\n\n### Option 1: Docker (Recommended)\n\n1. **Clone the repository**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd order-service\n   ```\n\n2. **Build and start services**\n   ```bash\n   docker compose up --build\n   ```\n\nThe service will be available at `http://localhost:8000`\n\n### Option 2: Local Development\n\n1. **Clone the repository**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd order-service\n   ```\n\n2. **Create virtual environment**\n   ```bash\n   python3.13 -m venv .venv\n   source .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n   ```\n\n3. **Install dependencies**\n   ```bash\n   pip install -r requirements.txt\n   # or if using poetry\n   poetry install\n   ```\n\n4. **Set up environment variables**\n   ```bash\n   cp .env.example .env.local\n   # Edit .env.local with your configuration\n   export $(grep -v -E '^\\s*(#|$)' .env.local | xargs)\n   ```\n\n5. **Start infrastructure services**\n   ```bash\n   docker compose -f docker-compose-dev.yml up -d\n   ```\n\n6. **Run database migrations**\n   ```bash\n   python manage.py migrate\n   ```\n\n7. **Start the application**\n   ```bash\n   uvicorn main:app --host 0.0.0.0 --port 8000 --reload\n   ```\n\n## Usage\n\n### Basic API Usage\n\n```bash\n# Create an order\ncurl -X POST \"http://localhost:8000/api/v1/orders/\" \\\n  -H \"Authorization: Bearer \u003cyour-jwt-token\u003e\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"title\": \"Package Delivery\",\n    \"recipient\": {\n      \"first_name\": \"John\",\n      \"last_name\": \"Doe\",\n      \"phone\": \"+1234567890\",\n      \"address\": \"123 Main St, City, State\"\n    },\n    \"package_details\": [{\n      \"type\": \"package\",\n      \"weight\": 1.5,\n      \"description\": \"Electronics\"\n    }]\n  }'\n\n# Get order by ID\ncurl -X GET \"http://localhost:8000/api/v1/orders/{order_id}\" \\\n  -H \"Authorization: Bearer \u003cyour-jwt-token\u003e\"\n\n# Track order\ncurl -X GET \"http://localhost:8000/api/v1/orders/tracking/{tracking_id}\" \\\n  -H \"Authorization: Bearer \u003cyour-jwt-token\u003e\"\n```\n\n\n### Swagger Interface Preview\n\n![Swagger API Documentation](swagger.png)\n\n*Interactive API documentation interface showing all available endpoints, request/response schemas, and the ability to test API calls directly from the browser.*\n\n\n## API Documentation\n\nOnce the service is running, you can access:\n\n- **Swagger UI**: [http://localhost:8000/api/orders/openapi](http://localhost:8000/api/orders/openapi)\n- **OpenAPI JSON**: [http://localhost:8000/api/orders/openapi.json](http://localhost:8000/api/orders/openapi.json)\n\n### Main Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| `POST` | `/api/v1/orders/` | Create a new order |\n| `GET` | `/api/v1/orders/` | Get list of orders (paginated) |\n| `GET` | `/api/v1/orders/{order_id}` | Get order by ID |\n| `GET` | `/api/v1/orders/tracking/{tracking_id}` | Get order by tracking ID |\n| `PUT` | `/api/v1/orders/{order_id}` | Update order |\n| `DELETE` | `/api/v1/orders/{order_id}` | Delete order |\n| `POST` | `/api/v1/orders/{order_id}/assign` | Assign courier |\n| `POST` | `/api/v1/orders/{order_id}/start` | Start delivery |\n| `POST` | `/api/v1/orders/{order_id}/complete` | Complete delivery |\n| `POST` | `/api/v1/orders/{order_id}/cancel` | Cancel order |\n\n## Development\n\n### Code Quality Tools\n\nWe use several tools to maintain code quality:\n\n```bash\n# Format code\nblack --skip-string-normalization .\n\n# Sort imports\nisort .\n\n# Lint code (modern alternative to flake8)\nruff check .\n\n# Type checking\nmypy .\n\n# Security scanning\nbandit -r .\n```\n\n### Pre-commit Hooks\n\nInstall pre-commit hooks to ensure code quality:\n\n```bash\npre-commit install\n```\n\n### Database Migrations\n\n```bash\n# Create new migration\nalembic revision --autogenerate -m \"Description of changes\"\n\n# Apply migrations\nalembic upgrade head\n\n# Downgrade migration\nalembic downgrade -1\n```\n\n### Project Structure\n\n```\norder-service/\n├── api/                    # API endpoints\n│   └── v1/                # API version 1\n├── constants/             # Application constants\n├── core/                  # Core application logic\n├── db/                    # Database configuration\n├── middleware/            # Custom middleware\n├── migrations/            # Database migrations\n├── models/                # SQLAlchemy models\n├── schemas/               # Pydantic schemas\n├── security/              # Authentication logic\n├── services/              # Business logic\n├── main.py                # Application entry point\n├── manage.py              # Management commands\n└── pyproject.toml         # Project configuration\n```\n\n## Testing\n\n### Running Tests\n\n```bash\n# Run all tests\npytest -vv\n\n# Run tests with coverage\npytest --cov=. --cov-report=html\n\n# Run specific test file\npytest tests/test_orders.py -v\n\n# Run tests in parallel\npytest -n auto\n```\n\n### Test Structure\n\n```\ntests/\n├── conftest.py           # Test configuration\n├── test_orders.py        # Order endpoint tests\n├── test_models.py        # Model tests\n└── test_services.py      # Service layer tests\n```\n\n## Environment Variables\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `DEBUG` | `false` | Enable debug mode |\n| `PROJECT_NAME` | `Order Service` | Service name (displayed in docs) |\n| `POSTGRES_HOST` | `localhost` | PostgreSQL hostname |\n| `POSTGRES_PORT` | `5432` | PostgreSQL port |\n| `POSTGRES_DB` | `orders` | Database name |\n| `POSTGRES_USER` | `app` | Database username |\n| `POSTGRES_PASSWORD` | - | Database password |\n| `REDIS_HOST` | `localhost` | Redis hostname |\n| `REDIS_PORT` | `6379` | Redis port |\n| `AUTHJWT_SECRET_KEY` | - | JWT secret key |\n| `JAEGER_TRACE` | `false` | Enable Jaeger tracing |\n| `JAEGER_AGENT_HOST` | `localhost` | Jaeger agent hostname |\n| `JAEGER_AGENT_PORT` | `6831` | Jaeger agent port |\n\n## Deployment\n\n### Docker Production Build\n\n```bash\n# Build production image\ndocker build -t order-service:latest .\n\n# Run with production settings\ndocker run -d \\\n  --name order-service \\\n  -p 8000:8000 \\\n  --env-file .env.prod \\\n  order-service:latest\n```\n\n### System Requirements\n\n- **Minimum**: 1 CPU, 1GB RAM\n- **Recommended**: 2 CPU, 2GB RAM\n- **Storage**: 10GB for logs and temporary files\n\n## Security\n\nSecurity is a top priority for this project. We have implemented multiple security measures and follow best practices to ensure the safety of your data.\n\n### Security Features\n\n- **Multi-tenant Architecture**: Row Level Security (RLS) ensures data isolation between organizations\n- **JWT Authentication**: Secure token-based authentication system\n- **Input Validation**: All API inputs are validated using Pydantic schemas\n- **SQL Injection Protection**: SQLAlchemy ORM with parameterized queries\n- **Distributed Tracing**: OpenTelemetry integration for audit trails\n- **Secure Error Handling**: Error responses don't leak sensitive information\n\n### Reporting Security Vulnerabilities\n\nIf you discover a security vulnerability, please follow our responsible disclosure process outlined in our [Security Policy](SECURITY.md).\n\n**Please do not create public GitHub issues for security vulnerabilities.** Instead, email us directly at bazhenov.in@gmail.com with details about the vulnerability.\n\n### Security Best Practices\n\nWhen deploying and using this service:\n\n- Use strong, unique JWT secret keys\n- Enable HTTPS in production\n- Keep dependencies up to date\n- Use secure database connections (SSL/TLS)\n- Implement proper network security measures\n- Regular security audits and monitoring\n\nFor detailed security information, please see our [Security Policy](SECURITY.md).\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Add tests for new functionality\n5. Ensure all tests pass (`pytest`)\n6. Run code quality checks (`ruff check .`, `mypy .`)\n7. Commit your changes (`git commit -m 'Add amazing feature'`)\n8. Push to the branch (`git push origin feature/amazing-feature`)\n9. Open a Pull Request\n\n### Code Style Guidelines\n\n- Follow PEP 8 style guide\n- Use type hints for all functions\n- Write docstrings for all public methods\n- Maintain test coverage above 80%\n- Use meaningful commit messages\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Authors\n\n- **Ivan Bazhenov** - *Initial work* - [@sendhello](https://github.com/sendhello)\n  - Email: bazhenov.in@gmail.com\n\n## Support\n\nFor support and questions:\n\n- Create an issue on GitHub\n- Contact the maintainer via email\n- Check the documentation at `/docs` endpoint\n\n---\n\nBuilt with ❤️ using FastAPI and Python 3.13\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendhello%2Forder-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsendhello%2Forder-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendhello%2Forder-service/lists"}