How does the economy of a city work? I'm interested in learning how the economy of a town is analyzed. For instance, some occupations serve only people in the town, for instance the town grocer, baker, restaurant, dry cleaner, etc. Their income must come from other people in the town. But other people's jobs will have them sell externally, like someone with an online store.

I've read things discussing how if Amazon's HQ2 brings 50,000 high paying jobs to a city, that also will cause there to be, say 100,000 new secondary jobs (restaurants, dry cleaners, etc that cater to the additional 50k people)

What is this area of study called and what papers or books are good to learn more about it?
Answering your question involves the various sub-fields of Regional Economics, such as Spatial Competition theory (Hotelling, 1929), Economic Geography, Urban
Economics (Alonso, 1964), New Economic Geography (Krugman, 1991), preferably in an integrated way.

Indeed, each of these subfields relate to considerations that complement each other. As stated by Thisse (2010), integrating space in economic analyses relates to (i) the use of a computable general equibrium (CGE) framework to endogenize the formation of incomes and relative prices, (ii) the realism of the modeled geographical space, the necessity of being multidimensional, asymmetric and empirically grounded and (iii) the number of encompassed spatial scales. Otherwise, it is difficult to figure out how spatial forces shape the so-called Space-economy (Isard, 1949) and, a fortiori, what policy or what institutional change can influence them if they are judged to go in an undesired direction.

I would reformulate your question as 


  What to do to model a city, a priori itself within a system of cities in interaction.


Incorporating CGE theory

The modeling architecture to develop in order to spatialize a GE is implicitly specified by Thisse (2010), who, instead of soft-linking compact descriptions of the economy and spatial formalisms, insist on the necessity of their full entanglement. This intellectual movement is the same as the movement toward hybrid models approach to couple GE models and engineering-based energy models (Hourcade et al., 2006). In the case of spatial economics, this hybridization passes through the use of New Economic Geography (NEG), which intrinsically implies GE theory. Indeed, GE concerns are what makes Economic Geography New (Krugman, 1998).

Involving geographical realism

At the scale (implicitly) involved in Urban Economics (UE), i.e. the urban scale, you can read Anas and Xu (1999), Nitzsche
and Tscharaktschiew (2013), Choi et al. (2015), Anas and Liu
(2007). If we collapse the internal structure of a metropolitan area into a single point, we conventionally jump to the field and the scale of analysis of New Economic Geography (NEG). Because at its early stages the analytic tractability of the spatial processes governing the interactions of areas was a key objective, one NEG’s notable feature is its lack of realism with
respect to the geographical distribution of areas, e.g. distributed in a mono-dimensional world as in Krugman (1993)’s Racetrack economy or in a part of it as in Fujita et al. (1999b)’s Line economy, as well as in a bi-dimensional world as in Puga (1999)’s side-by-side Equidistant Economy (EE). Since then, adding more real spaces components to NEG has been thought of as the main step for future development (Behrens and Thisse, 2007; Fujita and Krugman, 2003). You may also want to read Behrens et al. (2007), Bosker et al. (2007), Stelder (2005), Brakman et al. (2006), Sheng et al. (2016), Mercenier et al. (2016).

Involving multiple spatial scales

Both UE- or NEG-related models rely on exogenous signals coming from upper geographical scales, be them national, regional or global. But it is harder to find modeling approaches in which these links are explicitly involved. Attempts to bridge this gap can be found in Waisman et al. (2013), Allio (2015, 2016) and Faucheux (2018). 


Waisman, Allio and Faucheux integrate (i), (ii) and (iii) in their modeling exercices.