Question: a bit of background to the question, I'm a junior developer and we have recently been given flexitime which so far is working well as I get to start at 8am and leave at 4:30pm.

Today I arrived at 7:30 (I like to be early so I can have a coffee in the office before I start my work) however no one arrived to open the office until 9am.

So my question is, should I leave at the the normal time (5:30 pm) or when I would usually leave(4:30 pm)?

Answer: 
With all implementations of flextime that I know, there is a set of rules, in particular **core and maximum work hours**. You need to be there at least during core hours (e.g. 10am-2pm), and you may only work during a certain window (e.g. 7am-7pm). Was that not communicated?

If not, then talk to your manager and ask them to set this policy. Then everyone will know what is or is not possible with flextime.

As to today: If you normally start at 8 and leave at 4:30, I don't see why you cannot leave at 4:30 today, too. The time from 7:30 to 8 is probably on you, because it was not clear whether you can start before 8, but if your normal day starts at 8 am, and the door is locked, that's not your fault.
Just ask your manager.

Don't assume anything and simply ask. Something odd happened today and you want to know how to proceed as well as set up an example for future instances should it happen again. This is the exact situation where the only correct thing to do is ask your manager.

You shouldn't "just do the work" without asking because depending on your company guidelines that could push you into overtime hours or the like, which may or may not be "ok".

You shouldn't assume the opposite either, since you don't want to short-change your workplace work-hours.

Just ask.