Where does biologically active nitrogen come from

What you’re looking for are “nitrogen fixers”. A class of oceanic algae are nitrogen fixers, as well as (more recently, geologically speaking) legumes.

The process is called diazotrophy. Beyond that, my memory’s a bit rusty, biochemistry was a set of courses I didn’t pay as much attention to as I should have as an undergrad.