System Zarządzania Energią (EMS) to profesjonalny projekt demonstracyjny pokazujący:
- REST API w FastAPI do zbierania danych telemetrycznych
- IoT Device Simulator z mechanizmem buforowania
- Automatyczne alerty przy wysokiej temperaturze (>80°C)
- Kompletne testy z pytest
- Konteneryzacja z Docker & docker-compose
- Profesjonalna dokumentacja gotowa na rozmowy rekrutacyjne
docker-compose -f docker-compose.minimal.yml up --builddocker-compose up --build# API będzie dostępne na:
http://localhost:8000/docs # Swagger UI
http://localhost:8000/redoc # ReDoc
# Test endpoint:
curl -X POST "http://localhost:8000/telemetry" \
-H "Content-Type: application/json" \
-d '{"device_id": "test-001", "temperature": 25.5, "voltage": 12.1}'ems_demo/
├── 📄 api.py # FastAPI server z alertami
├── 🤖 device_sim.py # Symulator urządzeń IoT
├── 🧪 test_ems_extended.py # Podstawowe testy pytest
├── 🧪 test_qa_advanced.py # Zaawansowane testy QA
├── 📋 TEST_CASES.md # Dokumentacja przypadków testowych
├── 📚 DOKUMENTACJA_EMS.md # Pełna dokumentacja techniczna
├── 📮 EMS_API_Postman_Collection.json # Kolekcja Postman
├── 🐳 Dockerfile # Konteneryzacja aplikacji
├── 🐳 docker-compose.yml # Pełna infrastruktura (Redis, PostgreSQL, Grafana)
├── 🐳 docker-compose.minimal.yml # Proste uruchomienie (tylko API)
├── 📦 requirements.txt # Zależności Python
├── 🚫 .dockerignore # Wykluczenia Docker build
├── 🚫 .gitignore # Wykluczenia Git
├── 🔧 .github/workflows/ci.yml # GitHub Actions CI/CD
└── 📖 README.md # Dokumentacja główna
- Python 3.13+
- pip
# 1. Klonuj repozytorium
git clone https://github.com/TWÓJ-USERNAME/ems_demo.git
cd ems_demo
# 2. Utwórz wirtualne środowisko
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Linux/Mac
# 3. Zainstaluj zależności
pip install -r requirements.txt# Terminal 1: API Server (zawsze port 8000)
python api.py
# ⚠️ Pamiętaj: Zatrzymaj serwer CTRL+C przed kolejnym uruchomieniem!
# Terminal 2: Device Simulator
python device_sim.py
# Terminal 3: Testy
pytest test_ems_extended.py -v💡 WAŻNE: API uruchamia się zawsze na porcie 8000. Jeśli widzisz błąd "port already in use", zatrzymaj poprzedni proces przez CTRL+C lub zamknij terminal.
# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
# Simulator Configuration
SIMULATOR_INTERVAL=5
API_BASE_URL=http://localhost:8000# Wszystkie testy podstawowe
pytest test_ems_extended.py -v
# Zaawansowane testy QA
pytest test_qa_advanced.py -v
# Wszystkie testy razem
pytest -v
# Konkretny test
pytest test_ems_extended.py::test_temperature_alert -v- Zaimportuj
EMS_API_Postman_Collection.json - Ustaw environment variable
base_url=http://localhost:8000 - Uruchom testy w kolekcji
# Test telemetrii
curl -X POST http://localhost:8000/telemetry \
-H "Content-Type: application/json" \
-d '{"device_id": "dev-001", "temperature": 85.0}'
# Test batch
curl -X POST http://localhost:8000/telemetry/batch \
-H "Content-Type: application/json" \
-d '[{"device_id": "dev-001", "temperature": 25.0}, {"device_id": "dev-002", "temperature": 90.0}]'- Multi-stage build - optymalizacja rozmiaru
- Non-root user - bezpieczeństwo
- Health checks - monitorowanie
- Alpine Linux - minimalna powierzchnia ataku
# Build image
docker build -t ems-demo .
# Run container
docker run -p 8000:8000 ems-demo
# Check health
docker ps # Status powinien być "healthy"
# View logs
docker-compose logs -f ems-api| Endpoint | Method | Opis | Body |
|---|---|---|---|
/telemetry |
POST | Pojedynczy pomiar | {"device_id": "str", "temperature": float, "voltage?": float} |
/telemetry/batch |
POST | Batch pomiarów | [{telemetry_objects}] |
/alerts/device/{id} |
GET | Alerty urządzenia | - |
/health |
GET | Status API + statystyki | - |
/docs |
GET | Swagger UI | - |
/redoc |
GET | ReDoc | - |
Automatyczne alerty gdy temperatura > 80°C:
{
"status": "success",
"message": "Telemetry received",
"alert": "TEMPERATURE WARNING: Device dev-001 temperature 85.5°C exceeds 80°C threshold!"
}graph TB
A[IoT Devices] -->|HTTP POST| B[FastAPI Server]
B --> C[Validation Layer]
C --> D[Alert System]
C --> E[Data Storage]
F[Device Simulator] -->|Telemetry| B
G[Health Checks] --> B
Kluczowe komponenty:
- FastAPI: Szybki, nowoczesny framework
- Pydantic: Walidacja danych z type hints
- Uvicorn: ASGI server dla produkcji
- Docker: Konteneryzacja i orkiestracja
- Interview Demo: Pokaż znajomość FastAPI, Docker, testów
- IoT Prototype: Baza dla systemu telemetrii
- Learning Project: Nauka best practices
- Portfolio Piece: Profesjonalny kod do prezentacji
Projekt zawiera:
- ✅ Testy automatyczne (pytest basic + advanced QA)
- ✅ GitHub Actions workflow (.github/workflows/ci.yml)
- ✅ Docker containerization (simple, production-ready)
- ✅ Health checks (API status monitoring)
- ✅ API dokumentacja (automatyczna OpenAPI/Swagger)
- ✅ Test case documentation (TEST_CASES.md)
- ✅ Security best practices (environment variables, no hardcoded secrets)
- Fork repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push branch:
git push origin feature/amazing-feature - Open Pull Request
Barton License
Twoje Imię
- LinkedIn: [Bartosz Jasnos] https://www.linkedin.com/in/bartosz-jasnos-1a0097217/