Skip to content

Commit

Permalink
docs: explain the folder structure of web application
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Aug 22, 2024
1 parent fa01656 commit 85a485a
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 5 deletions.
Binary file added docs/assets/folder-structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 17 additions & 5 deletions docs/getting-started/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Getting Started with MetaSSR

Welcome to the MetaSSR Getting Started guide! This folder provides essential information to help you quickly set up and begin working with the MetaSSR framework.

## Overview

MetaSSR is a powerful framework for building Server-Side Rendered (SSR) web applications that is built on [Metacall](https://github.com/metacall/core). It was built as a real-world use-case for [Metacall](https://github.com/metacall/core) and polyglot programming. This guide will walk you through the installation process and provide an overview of the command-line interface (CLI) to help you get started.
### Table of Contents

## Contents
- [Overview](#overview)
- [Installation Guide](#installation-guide)
- [Folder Structure](#folder-structure)
- [Command-Line Interface (CLI) Documentation](#command-line-interface-cli-documentation)
- [Getting Help](#getting-help)

## Overview

MetaSSR is a powerful framework for building Server-Side Rendered (SSR) web applications that is built on [Metacall](https://github.com/metacall/core). It was developed as a real-world use-case for [Metacall](https://github.com/metacall/core) and polyglot programming. This guide will walk you through the installation process and provide an overview of the command-line interface (CLI) to help you get started.


## Installation Guide

To get MetaSSR up and running on your system, follow the detailed installation instructions provided in the `installation.md` file. This guide covers:
Expand All @@ -21,6 +24,15 @@ To get MetaSSR up and running on your system, follow the detailed installation i

You can find the installation guide [here](installation.md).

## Folder Structure

Understanding the folder structure of a MetaSSR project is crucial for effective development. The `folder-structure.md` file provides a detailed overview of the default directory setup and the purpose of each folder. This section covers:

- The root directory and its contents
- Important directories such as `src`, `static`, and `dist`

You can explore the folder structure guide [here](folder-structure.md).

## Command-Line Interface (CLI) Documentation

The MetaSSR CLI is an essential tool for managing your MetaSSR projects. It allows you to perform various tasks such as building, running, and creating projects. The `cli.md` file provides comprehensive documentation on how to use the CLI, including:
Expand Down
143 changes: 143 additions & 0 deletions docs/getting-started/folder-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@

# MetaSSR Folder Structure

Understanding the folder structure of a MetaSSR project is crucial for effective development and organization. This guide provides an overview of the default structure and the purpose of each directory and file.

## Table of Contents

- [Overview](#overview)
- [Root Directory](#root-directory)
- [src](#src)
- [pages](#pages)
- [Special Files](#special-files)
- [static](#static)
- [dist](#dist)

## Overview

When you create a new MetaSSR project, the framework sets up a standard folder structure to organize your code and resources. This structure helps manage your application logic, static files, build outputs, and configurations in a clean and scalable way.

![overview-for-folder-structure](../assets/folder-structure.png)

## Root Directory

The root directory contains the core configuration files and directories necessary for your project. It typically looks like this:

```plaintext
my-metassr-project/
├── src/
├── static/
├── dist/
├── node_modules/
├── package.json
└── README.md
```

### src

The `src` directory contains the main source code for your application. Here, you'll write your server-side logic, React components, and other core functionalities.

```plaintext
my-metassr-project/
└── src/
├── pages/
├── _head.jsx
└── _app.jsx
```

- **_app.jsx**: The entry point for your application.
- **_head.jsx**: Contains the content of the HTML header for global pages.

### pages

The `pages` directory is a crucial part of the MetaSSR project. It contains the React components that represent different pages in your application. Each file inside this directory corresponds to a specific route in your application.

```plaintext
my-metassr-project/
└── src/
└── pages/
├── index.jsx
└── about.jsx
```

- **index.jsx**: Typically represents the homepage of your application.
- **about.jsx**: An example of a secondary page in your application.

These files will be automatically mapped to the respective routes, such as `/` for `index.jsx` and `/about` for `about.jsx`.

### Special Files

MetaSSR uses several special files that help customize the behavior and appearance of your application across different pages:

- **_app.jsx**: This file serves as the main entry point for your application. It wraps all the pages in your application, layout, and other shared functionality. Any changes made here will apply across your entire application.

- **_head.jsx**: This file contains the content for the HTML `<head>` tag, which is included on every page. It's the place to include global meta tags, styles, and scripts that should be consistent across all pages.

- **pages/_notfound.jsx**: This is a special page component that handles 404 errors when a user navigates to a route that doesn't exist. It helps provide a custom and user-friendly error page instead of a generic browser error.

```plaintext
my-metassr-project/
└── src/
├── _head.jsx
├── _app_.jsx
└── pages/
├── _notfound.jsx
├── index.jsx
└── about.jsx
```

### static

The `static` directory holds static assets like images, fonts, and other files that won't change during runtime. These files are served directly to the client.

```plaintext
my-metassr-project/
└── static/
├── images/
├── css/
└── favicon.ico
```

This directory is served under the `/static/` endpoint like this:
```
localhost:<PORT>/static/favicon.ico
```

### dist

The `dist` directory is where the compiled output of your project is stored after running [the build command](./cli.md#build). It contains the optimized and minified versions of your assets and code. It's used to render your web application on the server-side.

```plaintext
dist/
├── cache
│ ├── head.js
│ ├── head.js.map
│ └── pages
│ ├── index.js
│ ├── index.server.css
│ ├── index.server.css.map
│ ├── index.server.js
│ ├── index.server.js.map
│ └── _notfound
│ ├── index.js
│ ├── index.server.css
│ ├── index.server.css.map
│ ├── index.server.js
│ └── index.server.js.map
├── manifest.json
└── pages
├── index.js.css
├── index.js.css.map
├── index.js.js
├── index.js.js.map
└── _notfound
├── index.js.css
├── index.js.css.map
├── index.js.js
└── index.js.js.map
```

---

By understanding and utilizing the default folder structure of MetaSSR, you'll be able to maintain a clean and scalable codebase, making your development process smoother and more efficient.

0 comments on commit 85a485a

Please sign in to comment.