137 lines
3.0 KiB
Markdown
137 lines
3.0 KiB
Markdown
# Bakery Forecasting Platform - Microservices
|
|
|
|
## Overview
|
|
AI-powered demand forecasting platform for bakeries in Madrid, Spain using microservices architecture.
|
|
|
|
## Architecture
|
|
- **API Gateway**: Central entry point for all client requests
|
|
- **Auth Service**: User authentication and authorization
|
|
- **Training Service**: ML model training for demand forecasting
|
|
- **Forecasting Service**: Generate predictions using trained models
|
|
- **Data Service**: External data integration (weather, traffic, events)
|
|
- **Tenant Service**: Multi-tenant management
|
|
- **Notification Service**: Email and WhatsApp notifications
|
|
|
|
## Quick Start
|
|
|
|
### Prerequisites
|
|
- Docker and Docker Compose
|
|
- Python 3.11+
|
|
- Node.js 18+
|
|
|
|
### Setup
|
|
```bash
|
|
# Run setup script (this script!)
|
|
./scripts/setup.sh
|
|
|
|
# Start services
|
|
docker-compose up -d
|
|
|
|
# Check service health
|
|
curl http://localhost:8000/health
|
|
```
|
|
|
|
### Services
|
|
- **Gateway**: http://localhost:8000
|
|
- **API Docs**: http://localhost:8000/docs
|
|
- **Grafana**: http://localhost:3002
|
|
- **Prometheus**: http://localhost:9090
|
|
- **RabbitMQ Management**: http://localhost:15672
|
|
|
|
### Development
|
|
|
|
#### Running Tests
|
|
```bash
|
|
./scripts/test.sh
|
|
```
|
|
|
|
#### Building Services
|
|
```bash
|
|
docker-compose build
|
|
```
|
|
|
|
#### Viewing Logs
|
|
```bash
|
|
# All services
|
|
docker-compose logs -f
|
|
|
|
# Specific service
|
|
docker-compose logs -f auth-service
|
|
```
|
|
|
|
#### Service URLs (Development)
|
|
- Gateway: http://localhost:8000
|
|
- Auth Service: http://localhost:8001
|
|
- Training Service: http://localhost:8002
|
|
- Forecasting Service: http://localhost:8003
|
|
- Data Service: http://localhost:8004
|
|
- Tenant Service: http://localhost:8005
|
|
- Notification Service: http://localhost:8006
|
|
|
|
## Environment Variables
|
|
|
|
Copy `.env.example` to `.env` and update the following:
|
|
|
|
```bash
|
|
# External API Keys
|
|
AEMET_API_KEY=your-aemet-api-key
|
|
MADRID_OPENDATA_API_KEY=your-madrid-opendata-key
|
|
|
|
# Email Configuration
|
|
SMTP_USER=your-email@gmail.com
|
|
SMTP_PASSWORD=your-email-password
|
|
|
|
# WhatsApp API
|
|
WHATSAPP_API_KEY=your-whatsapp-api-key
|
|
|
|
# JWT Secret (change in production!)
|
|
JWT_SECRET_KEY=your-super-secret-jwt-key-change-in-production
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Services won't start
|
|
```bash
|
|
# Check if ports are available
|
|
docker-compose ps
|
|
netstat -tulpn | grep :8000
|
|
|
|
# Restart services
|
|
docker-compose down
|
|
docker-compose up -d
|
|
```
|
|
|
|
### Database connection issues
|
|
```bash
|
|
# Check database containers
|
|
docker-compose logs auth-db
|
|
docker-compose logs training-db
|
|
|
|
# Reset databases
|
|
docker-compose down -v
|
|
docker-compose up -d
|
|
```
|
|
|
|
### Service communication issues
|
|
```bash
|
|
# Check service health
|
|
curl http://localhost:8000/health
|
|
curl http://localhost:8001/health
|
|
curl http://localhost:8002/health
|
|
|
|
# Check RabbitMQ
|
|
open http://localhost:15672
|
|
# User: bakery, Password: forecast123
|
|
```
|
|
|
|
## Next Steps
|
|
|
|
1. **Configure External APIs**: Add your AEMET and Madrid Open Data API keys
|
|
2. **Test Authentication**: Register a user and test login
|
|
3. **Upload Sales Data**: Import historical sales data
|
|
4. **Train Models**: Start your first training job
|
|
5. **Generate Forecasts**: Create demand predictions
|
|
|
|
## License
|
|
MIT License
|