How sayuru99/energy_optimizer works
This is a FastAPI energy-optimization API for factories: users can authenticate and manage factory energy inputs, while the product also exposes schedule optimization, dashboards, and reports. The sampled optimizer chooses machine run times using tariff rates; cost calculation estimates current-schedule costs. The API router dispatches to these domain endpoints, and startup creates database tables and seeds example data. Endpoint implementations for factories, machines, tariffs, optimization, dashboards, and reports were not sampled, so their internal calls and persistence wiring are not inferred.
Main entry points: api.py API router · main.py API application · auth.py Authentication · deps.py Request dependencies
Components 18
API and access
- API application
app/main.py - API router
app/api/v1/api.py - Authentication
app/api/v1/endpoints/auth.py - Request dependencies
app/core/deps.py - Token security
app/core/security.py - API schemas
app/schemas
Factory operations
- Factory management
app/api/v1/endpoints/factories.py - Machine management
app/api/v1/endpoints/machines.py - Tariff management
app/api/v1/endpoints/tariffs.py
Energy analysis
- Schedule optimization
app/api/v1/endpoints/optimization.py - Schedule solver
app/services/optimizer.py - Cost estimation
app/services/cost.py - Energy dashboard
app/api/v1/endpoints/dashboard.py - Energy reports
app/api/v1/endpoints/reports.py
Persistence
- Database sessions
app/db/session.py - Domain models
app/models - Relational database
Other components
- Factory user
Connections 17
- Factory user → API application: uses API
- API application → API router: mounts routes
- API router → Authentication: dispatches
- API router → Factory management: dispatches
- API router → Machine management: dispatches
- API router → Tariff management: dispatches
- API router → Schedule optimization: dispatches
- API router → Energy dashboard: dispatches
- API router → Energy reports: dispatches
- Authentication → Request dependencies: requests session
- Authentication → Token security: checks credentials
- Request dependencies → Token security: decodes token
- Request dependencies → Database sessions: opens session
- Database sessions → Relational database: connects
- API application → Database sessions: initializes
- API application → Domain models: creates tables
- Schedule solver → Cost estimation