Developer Documentation
Conventions
Conventions
  • File and Folder Structure
  • Logging
  • Code Quality
  • Security
  • Code Style
  • Tools and Platforms
Powered by GitBook
On this page
  • Introduction
  • Regular Routes
  • Routing Groups
  • Dynamic Routes
  • Parallel Routes
  • Files
  • Components

Was this helpful?

File and Folder Structure

This document outlines the file andfolder structure for the Urapolku Next.js 13 project. It includes directories for routing, layout, pages, loading UI, error UI, API endpoints, and more.

NextLogging

Last updated 1 year ago

Was this helpful?

Introduction

Everything placed inside the app within files/folders will be included in the URL structure. To ensure compliance with Next.js it is necessary to follow the naming conventions outlined in the documentation.

Regular Routes

We have regular routes, which are named like this: name, and they represent actual routes within NextJS.

Routing Groups

Routing groups are named using parentheses, like (name). These groups do not have a specific URL associated with them, but serve to organize related pages.

Dynamic Routes

Dynamic routes, are named using square brackets, like [name]. These routes accept parameters, which will be included as part of the URL structure. For instance, [company] could represent the name of a company within the URL.

Parallel Routes

Parallel routes are named like @name and will help in conditionally or simultaniously showing a page.

Files

Each Page.tsx file within a route is responsible for a specific page within that route.

Each Layout.tsx file is responsible for a specific layout within that route.

Each Error.tsx file is responsible for handling errors within that route.

Each Loading.tsx file is responsible for handling the loading UI within that route.

Components

Within each route, you can have components that are specific to that route. Only when a component is not commonly used and is not shared between pages, should a component be created within a route.

Say for example you have a Searchbar component that is part of the Core Components. But this searchbar is uniquely styled and works unique to the open-jobs page. Then that means that the open-jobs page can have a component inside of it called: _searchbar.

urapolku/
│
├── src/                                       
|     ├── app/
|     |     ├── Layout.tsx                           # Default layout for the site (where the footer/header/content goes etc.) These can also be nested inside of each route...
|     |     ├── (jobs)
|     |     |     ├── open-jobs                      # https://urapolku.fi/open-jobs
|     |     |     |     ├── Loading.tsx
|     |     |     |     ├── Page.tsx
|     |     |     |     ├──_searchbar                # The unique searchbar component for the open-jobs page with a underscore in front of it to keep it private and non-routable.
|     |     |     |     |    |— searchbar.tsx
|     |     |     |     |    |— searchbar.module.css

Here is how we’ve currently created routes according to the structure outlined above within our application:

urapolku/
│
├── src/                                       
|     ├── app/
|     |     ├── Layout.tsx                                               # Default layout for the site (where the footer/header/content goes etc.) These can also be nested inside of each route...
|     |     ├── (jobs)
|     |     |     ├── open-jobs                                          # https://urapolku.fi/open-jobs
|     |     |     |     ├── Loading.tsx
|     |     |     |     ├── Page.tsx
|     |     |     |     ├── _searchbar
|     |     |     |     |    ├── Searchbar.tsx
|     |     |     |     |    └── Searchbar.module.css
|     |     |     |     ├── [company]
|     |     |     |     |    ├── [job]                                   # https://urapolku.fi/open-jobs/company-name/job-name>
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    ├── Page.tsx
|     |     |     |     |    |    ├── application
|     |     |     |     |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    ├── Page.tsx
|     |     |     |     |    |    |    ├── @personal-data
|     |     |     |     |    |    |    |    ├── [step]
|     |     |     |     |    |    |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    |    |    └── Page.tsx            # https://urapolku.fi/open-jobs/company-name/job-name/application/personal-data/1>
|     |     |     |     |    |    |    ├── @skills
|     |     |     |     |    |    |    |    ├── [step]
|     |     |     |     |    |    |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    |    └──  └── Page.tsx 
|     |     |     |     |    |    |    ├── @experience
|     |     |     |     |    |    |    |    ├── [step]
|     |     |     |     |    |    |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    |    └──  └── Page.tsx 
|     |     |     |     |    |    |    ├── @company-questions
|     |     |     |     |    |    |    |    ├── [step]
|     |     |     |     |    |    |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    |    └──  └── Page.tsx 
|     |     |     |     |    |    |    ├── @review
|     |     |     |     |    |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    |    └── Page.tsx 
|     |     |     |     |    |    |    ├── @overview
|     |     |     |     |    |    |    |    ├── Loading.tsx
|     |     |     |     |    |    |    |    └── Page.tsx 
|     |     |     |     |    |    |    ├── @submitted
|     |     |     |     |    |    |    |    ├── Loading.tsx
|     |     |     |     └──  └──  └──  └──  └── Page.tsx 
|     |     |     ├── (post-job)
|     |     |     |     ├── create-job                                 # https://urapolku.fi/create-job>
|     |     |     |     |    ├── @choose-template                      # https://urapolku.fi/create-job/choose-template>
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @basic-info
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @job-info
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @description
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @audience
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @salary
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @preferences
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    |    └── Page.tsx
|     |     |     |     |    ├── @submitted
|     |     |     |     |    |    ├── Loading.tsx
|     |     |     |     |    └──  └── Page.tsx
|     |     |     |     ├── edit-job
|     |     |     |     |    ├── Loading.tsx
|     |     |     └──   └──  └── Page.tsx
|     |     ├── (authentication)
|     |     |     ├── @login                               # https://urapolku.fi/login <- this will render conditionally based on the user's logon state
|     |     |     |     ├── Loading.tsx
|     |     |     |     └── Page.tsx
|     |     |     ├── @sign-up                             # https://urapolku.fi/sign-up
|     |     |     |     ├── Loading.tsx
|     |     |     |     └── Page.tsx
|     |     |     ├── @choose-account                      # https://urapolku.fi/choose-account
|     |     |     |     ├── Loading.tsx
|     |     |     └──   └── Page.tsx    
|     |     ├── (dashboard)
|     |     |     ├── @administrator
|     |	    |     |     ├── dashboard                # https://urapolku.fi/administrator/dashboard
|     |     |     |     |     ├── Loading.tsx
|     |     |     |     └──   └── Page.tsx  
|     |     |     ├── @employer
|     |     |     |	├── dashboard                # https://urapolku.fi/employer/dashboard
|     |     |     |     |     ├── Loading.tsx
|     |     |     |     |     ├── Page.tsx
|     |     |     |     |     ├── @owner             # https://urapolku.fi/employer/dasbhboard/owner
|     |     |     |     |     |    └── Page.tsx
|     |     |     |     |     ├── @editor            # https://urapolku.fi/employer/dashboard/editor
|     |     |     |     |     |    └── Page.tsx
|     |     |     |     |     ├── @viewer            # https://urapolku.fi/employer/dashboard/viewer
|     |     |     |     |     |    └── Page.tsx
|     |     |     |     |     ├── @customized        # https://urapolku.fi/employer/dashboard/customized
|     |     |     |     └──   └──  └── Page.tsx
|     |     |     ├── @candidate
|     |     |     |	├── dashboard                # https://urapolku.fi/candidate/dashboard
|     |     |     |     |     ├── Loading.tsx
|     |     |     └──   └──   └── Page.tsx 
|     |     ├── on-boarding                               
|     |     |     ├── @employer                             
|     |     |     |    ├── profile                   # https://urapolku.fi/on-boarding/employer/profile
|     |     |     |    |    ├── Loading.tsx                 
|     |     |     |    |    └── Page.tsx                    
|     |     |     ├── @candidate                            
|     |     |     |    ├── @profile                  # https://urapolku.fi/on-boarding/candidate/profile
|     |     |     |    |    ├── Loading.tsx
|     |     |     |    |    └── Page.tsx
|     |     |     |    ├── @skills
|     |     |     |    |    ├── Loading.tsx
|     |     |     |    |    └── Page.tsx
|     |     |     |    ├── @eduction
|     |     |     |    |    ├── Loading.tsx
|     |     |     |    |    └── Page.tsx
|     |     |     |    ├── @work
|     |     |     |    |    ├── Loading.tsx
|     |     |     └──  └──  └── Page.tsx
|     |     ├── api                                  # https://urapolku.fi/api
|     |     |     ├── auth                           # https://urapolku.fi/api/auth
└──   └──   └──   └──   └── Route.tsx                # Route for the auth api from Auth0: https://urapolku.fi/api/auth
|     |
|     ├── lib/                                       # Utility functions, shared code, configurations
└──   └──   └── ...
|     |
|     └── context/                                   # React context providers and consumers
└──   └──   └── ...
|     |
|     |── components/                                # Components
|     |     |     ├── core/                          # Re-usable Components
|     |     |     |     |── button/                  # Button component
|     |     |     |     |    ├── Button.tsx          # Typescript file for the button component
|     |     |     |     |    └── Button.module.css   # Css module for the button component 
│     │     |     |     |── searchbar/
|     |     |     |     |    ├── Searchbar.tsx          # Typescript file for the button component
|     |     |     |     └──  └── Searchbar.module.css  
│     │     |     ├── common/                        # Commonly Used Components
│     │     |     |     ├── header/                  # Header Component
|     |     |     |     |     ├── Header.tsx         # Typescript file for the header component
|     |     |     |     |     └── Header.module.css  # Css module for the header component
└──   └──   └──   └──   └── footer/
|
├── public/                                          # Static files like images, favicons, etc.
│     ├── favicon.ico
│     ├── logo.png
└──   └── ...
|── next.config.js                                   # Configuration file for Next.js
|── package.json                                     # Project dependencies and scripts
|── instrumentation.ts                               # OpenTelemetry and Instrumentation file
|── middleware.ts                                    # Next.js request middleware
|── .env                                             # Environment variables
|── .env.local                                       # Local environment variables
|── .env.production                                  # Production environment variables
|── .env.development                                 # Development environment variables
|── .eslintrc.json                                   # Configuration file for ESLint
|── .gitignore                                       # Git files and folders to ignore
|── next-env.d.ts                                    # TypeScript declaration file for Next.js
|── tsconfig.json                                    # Configuration file for TypeScript
|── jsconfig.json                                    # Configuration file for JavaScript
└── ...

We want to make sure that each unique component that is unique to a route has a underscore in front of the directory name to make it private, to make sure it can not be individually routed to

NextJS
(see Next.js documentation).