Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From Grid Saturation to GitOps: Engineering a R...

From Grid Saturation to GitOps: Engineering a Renewable Energy Community Platform

Europe's electrical grids face a dual crisis: surging demand from EVs and heat pumps, combined with volatile renewable supply. Upgrading physical infrastructure would cost billions. The smarter alternative is software-driven flexibility, and that's where SPARklE comes in.
SPARklE is a cloud-native microservice platform (Java/Spring Boot core, Python optimization algorithms) that manages Renewable Energy Communities (RECs) and participates in energy flexibility markets. This talk explores the domain challenges that shaped our architecture and the production engineering decisions behind them.

We will dive into three core areas:
Time-Series Data at Scale: TimescaleDB hypertables and retention policies for high-frequency IoT ingestion from smart meters.
Hardened Multi-Tenancy: PostgreSQL Row-Level Security with session variable propagation through a connection pool (and some subtle edge cases we hit).
GitOps via FluxCD: Kubernetes deployments in a multi-party project where components are owned by external partners.

An honest look at production trade-offs made by a small team building software that impacts real-world grid stability. Includes a live demo.

Target Audience: Java/backend developers, DevOps engineers, and architects working on data-intensive or multi-tenant systems. No prior energy domain knowledge required.
Key Takeaways: Production-tested PostgreSQL RLS multi-tenancy; real TimescaleDB adoption patterns at IoT scale; GitOps strategies for multi-party projects.

Avatar for smirne

smirne

June 02, 2026

More Decks by smirne

Other Decks in Programming

Transcript

  1. ๏ Energy management ๏ What is SPARklE? ๏ Architecture ๏

    TimescaleDB ๏ Multitenancy ๏ FluxCD Today’s goals: AGENDA_ 2
  2. DISTRIBUTION CHALLENGES_ 5 Source: Areti SpA RomeFlex Project Peak Demand

    ๏ 2022: 2,000 MW ๏ 2032: 3,300 MW ๏ > 2,500 MW for 750h
  3. Approaches DISTRIBUTION CHALLENGES_ ๏ Handle the 3,300 MW peak ๏

    Approx. €1,000M investment Infrastructure upgrade 6 Source: Areti SpA – RomeFlex Project Technical Report
  4. Approaches DISTRIBUTION CHALLENGES_ ๏ Handle the 3,300 MW peak ๏

    Approx. €1,000M investment ๏ Use demand response to reduce the peak ๏ Upgrade infrastructure to handle 2,500 MW ๏ Total investment of approximately €500M Infrastructure upgrade Flexibility & energy management 7 Source: Areti SpA – RomeFlex Project Technical Report
  5. What is a REC? RENEWABLE ENERGY COMMUNITES_ 9 ๏ Group

    of end users ๏ Limited geographic area ๏ Renewable energy generation ๏ Virtual energy sharing ๏ Self-consumption incentives
  6. How Does it Work? ENERGY FLEXIBILITY_ 12 GRID CONGESTION FORECASTS

    DSO PUBLISHES FLEXIBILITY REQUESTS USERS CAN BID A SHARE PAYMENT BASED ON RESULTS
  7. 14

  8. Full REC management SPARKLE_ 16 Advanced algorithms (REC optimization) IoT

    (easy device integration) Community (REC as a user community) Incentive calculation
  9. Flexibility management SPARKLE_ 17 Problem ๏ Imbalance between generation and

    consumption ๏ Grid overloads ๏ Lack of storage capacity ๏ Fragmented platforms Solution ๏ Single integrated platform ๏ Smart management of energy storage systems ๏ Generation & consumption forecasting ๏ Optimization
  10. Variabili in gioco SPARKLE_ 18 ๏ Energy price ๏ Historical

    trends ๏ Weather forecasts ๏ Storage capacity ๏ Self-consumption incentives ๏ Flexibility incentives
  11. Challenges SPARKLE_ 22 ๏ Reading and storing large volumes of

    data from heterogeneous devices ๏ Collaboration across 4 companies ๏ Different tech stacks and models for forecasting & optimization
  12. Data management SPARKLE_ 25 TimescaleDB ๏ High write throughput ๏

    Optimized for time-based queries ๏ Retention policy ๏ Built-in time functions ๏ PostgreSQL extension
  13. Multitenancy SPARKLE_ 27 Problema ๏ Managing multiple RECs ๏ Full

    data isolation for end users ๏ Users with visibility across multiple RECs ๏ Full data access for analytics and audits ๏ Avoid relying on a WHERE clause
  14. Service - auth MULTITENANCY_ 29 ๏ Decode tenantID with auth

    filter ๏ Store in ThreadLocal variable @Override protected void doFilterInternal( HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull FilterChain filterChain){ String authorizationHeader = request.getHeader(AUTHORIZATION); String tokenString = authorizationHeader.substring(BEARER.length()); Optional<JWTClaimsSet> claims = jwtTokenDecoder.decodeToken(tokenString); String tenantId = claims.get() .getClaim(KEYCLOAK_TENANT_ID_CLAIM).toString(); TenantThreadLocal.setContext( new TenantContext(tenantId)); filterChain.doFilter(request, response); }
  15. DB access MULTITENANCY_ 30 ๏ Add a variable with the

    tenant id each time a connection is acquired @Override public @NotNull Connection acquire() { Connection connection = super.acquire(); String tenantId = TenantThreadLocal.getContext().getTenantId(); if (tenantId == null) { //raise exception } String sql = "SET app.current_tenant_id = NULL"; try (Statement stmt = connection.createStatement()) { stmt.execute(sql); } catch (SQLException e) { throw new DataAccessException("aaargh!"); } return connection; }
  16. Multitenancy - row level policy MULTITENANCY_ 31 ALTER TABLE member

    ENABLE ROW LEVEL SECURITY; CREATE POLICY admin_bypass_tenant_policy ON public.member FOR ALL USING ( -- READ filter current_setting('app.current_tenant_id', true)::VARCHAR = '<SECRET>' OR tenant_id = current_setting('app.current_tenant_id', true)::VARCHAR ) WITH CHECK ( -- WRITE guard current_setting('app.current_tenant_id', true)::VARCHAR = '<SECRET>' OR tenant_id = current_setting('app.current_tenant_id', true)::VARCHAR );
  17. Automate all the things GITOPS_ 33 ๏ Monorepo: shared pipelines

    + service-specific pipelines ๏ Automated Docker image builds ๏ GitOps: declarative infrastructure and application
  18. Roadmap SPARKLE_ 36 September 2025 Pilot Project December 2025 Research

    project conclusion and dissemination September 2026 Sparkle as a product March 2026 Fist REC onboarding
  19. Feature list SPARKLE_ 37 RECs ๏ Optimization algorithm ๏ Multi-REC

    management ๏ Asset onboarding ๏ User registration Monitoring ๏ Extended asset hierarchy ๏ Analytics dashboards ๏ Specialized charts ๏ Device integration without MQTT
  20. 38 Contacts CONTACT_US Via Campagna 13, CH-6982 - Agno [email protected]

    www.welld.ch Via Pastrengo 14, 20154 - Milano http://sparkle.energy