# Routing in FastAPI [chapter 2]

In this second chapter we are going to do a route management. We will follow specific clean architecture and specification

```plaintext
# Create the api folder in root of the project
>> mkdir api
>> cd api

# Create the routes folder inside the api folder
>> mkdir routes

# Also make a main.py file in api folder which will hold all the routes
>> touch main.py

# Now go inside the routes folder and create the routes file. 
# For instance, We will make the Admin.py file which will hold the all
# routes needed for the admin page in frontend.
>> cd routes
>> touch admin.py
```

Let’s revise the process and move to the Folder structure.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728606858507/b398351f-ebbb-4ad4-9aa0-e0f28de788d9.png align="center")

You can watch the folder structure for proper reference if you are confused. Let me explain the folder structure. The **init**.py file is empty file we create to tell the python that this folder should be treated as python package, and pycache can be ignored as it is auto created by python for storing bytecode about the compilation.

Also as shown in the above picture, The code inside the admin.py file. Here we are making route for the “GET” request. “async” function is what make the fastapi fast, so we will be using this for creating route.

Again, inside the api folder in main.py file we are importing different routes like admin.py for maintainable and collection of routes.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728614325473/3c90ab88-5b8b-4e32-b9e9-24999f090072.png align="center")

So, if you want to add new route just import as “*from app.api.routes import fileName*” and then integrate as “*api\_router.include\_router(fileName.router, prefix=’/urlname’, tags=\[‘route detail‘\])*”

Now In main.py file in app folder have to add above main.py file for complete integratio

```plaintext
## app/main.py
from app.api.main import api_router

app = FastAPI()

prefix = "/api/v1"
app.include_router(api_router, prefix=prefix) 
```
