A temple is a place designed to bring all beings and non-beings together through both verbal and non-verbal expression of dharma, kama, artha, moksa, and karma. The reason for this is because, unlike humans (who communicate primarily with words), not all beings use words. This coming together creates a world where all beings and non-beings, no matter their home world, may work together. "World" does not mean "planet," but a state of place or time and non-place or non-time.
This is why its construction typically utilizes symbolism to convey its purpose. Its architecture itself typically becomes a means for understanding those basic concepts of Time, Space, Force, Matter, Energy and other concepts of existence, and the more profound concepts of non-existence. The architecture then becomes a tool for studying how all the worlds, all the forces, all the beings both interact and do not interact, and how they may work together - and how they cannot.
The Vedas, Upanishads, Brhat Samhita, and the Vastu Sastras provide guidance on accomplishing this architecture, but ultimately discretion is left to express the concepts in a way that they are most accessible to the beings and non-beings depending on their culture: symbolism changes from culture to culture. Yet there are similarities among the cultures: though the practice of mathematics may change from world to world, the process of logic does not. There are also similarities in the presentation of the various non-beings: the non-being of Garuda is often depicted as a large bird of prey, for example; and the Nagas are often depicted as hooded poisonous snakes. Within these presentations of logic and image, however, subtle details can have profound impacts: if the Buddha Gotama is presented at the moment of achievement, it may impact the understanding of adjacent images: Time (before or after this event) is established. Several images can result in a directionality, or an Axis, of Time in the Temple.
Sometimes a mathematical fractal pattern is used so that architectural and other elements repeat in various scales: this presents a fifth Axis of non-space non-time. The presentation of interacting wave-forms in these fractals that increase or minimize their peaks and troughs can present a sixth Axis and aid understanding of concepts of co-arising, co-terminating, auto-arising, auto-terminating, and other subtle natures of causation and reaction, of Karma.
Temples are naturally places for the practice of Tirtha, or pilgrimage. The word is different than the Judeo/Christian/Muslim concept of "pilgrimage," a better word would be a "ford," or "crossing-place;" a necessary "pass" from here to there. An Ashram is the place where Yoga is practiced, but Temples are the object of the practice of Tirtha: Tirtha, when perfected, permits observing how the numerous worlds both touch and do not touch each other - and is necessary for obtaining final knowledge. The Skanda Purana describes three kinds of Tirtha: Jangam Tirtha (a time not locked in space, movable, such as the teachings of a sadhu, a rishi, a guru), Sthawar Tirtha (a place not locked in time, such as a city, or mountain, a river), and Manas Tirtha (a state of being neither in time nor space, such as truth, generosity, benevolence, love, etc.).
It is impossible to accomplish the pilgrimage without having vowed to do so first: the intention to reach that place, time or state of being is essential to success. Simply coming upon it is insufficient for the practice of Tirtha: just as "Om!" can be said and not understood, the journey to the destination itself is essential to the spiritual practice undertaken at the Temple. Otherwise, a person will arrive at the Temple, perform various rituals, and not understand or gain benefit from the practice. Similar to Yoga, it is also not necessary to arrive at the very locus or center or exact spot of the destination: it is sufficient to come to the district of the destination, as close as possible. In this respect, Tirtha is like Yoga: perfection is not the goal, the goal is good practice.
Oversimplifying things, the Temple is organized in four dimensions: height, width, depth, and time. The "middle axis" of the space-continuum is curved in on itself like a circle. This represents a two-dimensional representation of a sphere, as if a planet itself were imposed upon a flat plane. It is presented like a gathering place, or a settlement: the center of this circle is reserved for the non-beings, beyond this a space for Devas, beyond this a space for humans, beyond this (the inside of the outerwall) is reserved for the Asuras, beyond this a space for plants and animals and similar spirits and beings possessing form, and at the gates is a space reserved for the unformed beings such as Ghosts, beyond this is a space reserved for the beings without form such as Demons. The innermost part of the Temple is connected by an Axis of Time with the outermost area beyond the walls to form a continuum. This Axis is not presented in a physical sense, though. The area reserved for humans is the "middle axis" of this time-continuum and also the space-continuum. It is therefore linearly oriented, positioned in the middle like a transect; it also exists circularly, in the middle of the space between the inner wall and the physical center. The height axis is divided similarly, providing spaces for beings that live in the ground and on it and above it. Space is provided for the beings and non-beings who require water.
The circular Axes are then squared to present ease in geometric analysis: new Axes are like hidden knowledge, "discovered" by logical and geometric analysis. Understanding the connection between the four axes of time and space reveal understandings of logic, mathematics and other concepts which transcend all worlds, and illuminate the causes for and means by which the suffering of any world originates and may be escaped -the very reason for the gathering of every world, and the combination of their forces.
Each area is consecrated by describing the achievements and failures of each type of being, and their worlds; the human state of being is governed by Dharma, Artha and Kama - and images of these are usually sufficient. In a similar way, the center is not decorated at all. In every area, the beings and non-beings are implored by their shortcomings and achievements, their commonality in purpose, the compelling argument of logic to join their forces together.
The separation of each world is essential to this. It is necessary for each world to perfect itself; the beings of each world are uniquely suited to work in their own place, time, non-place, and non-time. "Invasions" of the several worlds, "conflicts" between the worlds, even "interventions" of the several worlds prevent the goal. Hence, the layout of the Temple is designed to encourage harmony between the beings and non-beings and their nature and their environment - these three harmonies (inter-being/inter-non-being, nature and environment) present three additional Axes. Homes and cities are organized by similar principles; the sciences of urban planning and interior design are similar enough to present an analog.
Most Temples are designed to service one type of being or non-being, or one individual in particular. Most Temples are designed for use by humans, and therefore are square: this is representative of human nature and environment. It is oriented along the four cardinal directions. This square is then divided into numerous areas suitable for the various beings and non-beings - it is very similar to planning a party and organizing which tables the guests will sit at.
But some Temples are designed to service two beings or non-beings, and within the square is placed an image of the "other" individual or group of individuals being serviced.
Yet not all Temples are designed for humans, or even for just one or two entities. Sometimes instead of squares emulating human houses or human cities, they are made to appear like mountains, or caves, or empty spaces, or oceans, or other "habitats" or "environments" suited for beings or non-beings of a particular sort. Sometimes in deference to all the beings, they are purely geometrical. Sometimes, they are designed just for one individual, and may in all appearances seem like a house.
There are numerous sizes of Temples: some smaller than a person, some larger than a city. Some even encompass entire cities! Some are constructed by sound, or by image or are otherwise intangible.
But there are also those Temples which are "natural" and which have not been constructed by humans; some have been built by other types of beings. But there are many natural gathering places, or individuals to whom all beings gravitate, or states of being to which all beings and non-beings gravitate, which were not constructed at all.