Skip to content

malinjr07/Creato-Air-Front-End

Repository files navigation

Project Structure

For managing the project in a more concise way, we can create these folders for more manageable code:

Files and Folders Structure

  • components
    • core
    • common
    • layouts
  • pages
  • stories
  • styles
  • pages
  • utils
    • hooks
    • lib
    • services
    • store
    • types

Components

This folder contains reusable UI components used throughout the application. It has three folders:

  Core

The core folder contains the unbreakable components such as buttons, inputs, svg icons etc.

  Common

The common folder contains common components that combine multiple core components. These are shared across different layouts in the application. Examples include various types of cards, dropdowns, tabs, accordions, and modals.

  Layouts

The layouts folder contains components that define the structure of pages. These components often include headers, footers, or sidebars and are used across multiple pages. Layout components are usually made up of multiple common and core components.

Pages

The pages folder contains the main pages of the application. Each file in this folder represents a route in the application. These pages are composed of various components from the components folder and are responsible for rendering the content that users interact with. The structure of the pages folder follows the Official Next.js Project Structure and Organization.

  Example

Here is an example of a simple page component:

// filepath: /path/to/pages/Home.js
import { NextPage } from 'next';
import React from 'react';
import Header from '../components/layouts/Header';
import Footer from '../components/layouts/Footer';
import MainContent from '../components/common/MainContent';

const Home: NextPage = () => {
  return (
    <div>
      <Header />
      <MainContent />
      <Footer />
    </div>
  );
};

export default Home;

Stories

The stories folder contains Storybook stories for the components in the application. These stories are used to document and visually test components in isolation. Each component typically has a corresponding story file that demonstrates its various states and uses.

Styles

The styles folder contains global styles, theme definitions, and any other styling-related code. This includes CSS, SCSS, or styled-components files that define the look and feel of the application. It helps maintain a consistent design system across the entire project.

Utils

The utils folder contains utility functions and helpers that are used throughout the application.

  Hooks

The hooks folder contains custom React hooks that encapsulate reusable logic and state management.

  Lib

The lib folder contains utility functions, helpers, or any other code that doesn't fit into the other categories but is still shared across the application.

  Services

The services folder contains code related to making API calls, handling authentication, or any other service-related logic.

  Store

The store folder contains code related to state management in the application using Zustand.

    Structure

  • Store Configuration: Set up and configure the Zustand store.
  • Slices: Organize state into logical slices for better modularity and maintainability.

    Example

Here is an example of how to set up a Zustand store:

// filepath: /path/to/store/useStore.js
import create from 'zustand';

const useStore = create((set) => ({
  // Define your state and actions here
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 })),
}));

export default useStore;

  Types

The types folder contains TypeScript type definitions and interfaces used throughout the application. This helps in maintaining type safety and consistency across the codebase. By defining types in a centralized location, it becomes easier to manage and update them as the application evolves.

  Example

Here is an example of a simple type definition:

// filepath: /path/to/types/index.d.ts
export interface User {
  id: number;
  name: string;
  email: string;
}

These type definitions can then be imported and used in various parts of the application to ensure that the data structures are consistent and type-safe.