Electrum derives your 'Master Private Key' to start its keypool derivation.
From your 12-word 'Seed Phrase', it does these exact steps to get your 'Seed' except the default passphrase is "electrum" instead of "mnemonic".
Mnemonic to Seed: https://learnmeabitcoin.com/technical/keys/hd-wallets/mnemonic-seed/#mnemonic-to-seed
With the 'Seed', create the 'Master Private Key'.
Seed to Master Private Key: https://learnmeabitcoin.com/technical/keys/hd-wallets/extended-keys/#master-extended-key
Then with the Master Private Key (m), derive the Extended Private Key at: m/0h
Notes: You can get it with getmasterprivate() command in the console or CLI (Electrum calls it "Master Private Key");
Its pair 'Master Public Key' can be seen in "Wallet->Information" window and its derivation path.
With the Extended (Master) Private Key (m), derive the 1st to 20th receiving addresses with the derivation path: m/0/0 to m/0/19
And the 1st to 10th change address with the derivation path: m/1/0 to m/1/9 (generate more if the last one is used)
(you can check that with each address' "Right-click->Details" in 'Addresses' tab)
Child key derivation is explained here: https://learnmeabitcoin.com/technical/keys/hd-wallets/extended-keys/#child-key-derivation
- But since you're going to create a tool, skip the terminologies used by Electrum and go straight from the actual master private key created from the seed.
Which gives you the derivation path: Seed --seed-to-master-prvKey--> m/0h/0/0 (for the first receiving address) and m/0h/1/0 (for the first change address)
With the child private key of your (first) address derived, calculate its pair Public key in compressed format.
More info here: https://learnmeabitcoin.com/technical/keys/public-key/
With that compressed public key, encode the Native SegWit (bech32 - P2WPKH) address.
Bech32 encoded address step by step guide: https://bitcointalksearch.org/topic/step-by-step-guide-to-go-from-public-key-to-a-bech32-encoded-address-4992632
Tool: https://learnmeabitcoin.com/technical/keys/address/#p2wpkh
Note: Those are specific to the latest default "Standard" wallet, other wallet types including "old" and legacy p2pkh electrum wallet have different derivation path from the master private key.