Getting Started
The fastest way to get started with a Ludic project is to use the Cookiecutter template. Follow the steps below to set up your project quickly.
Prerequisites
#Before you begin, ensure you have the following installed on your machine:
- Python 3.12
- Poetry
- Cookiecutter (optional for generating a new project)
Installation Steps
#- Install Cookiecutter
If you don't have the Cookiecutter library installed, you can install it by running:
pip install cookiecutter
For more information, refer to the Cookiecutter documentation.
- Generate a Ludic Project
Use the Cookiecutter template to create a new Ludic project. Run the following command in your terminal:
cookiecutter gh:getludic/template
- Install Dependencies
Navigate to your project directory and install the required dependencies using Poetry:
poetry install
- Run the Project
Start your project using Uvicorn with the following command:
poetry run uvicorn src.main:app --reload
- Access the Application
Open your browser and visit http://localhost:8000 to see your running application.
Structure
#The cookiecutter template generates a somewhat opinionated project structure. Feel free to adjust it or suggest a different one on GitHub. Here is the structure:
. ├── src │ ├── __init__.py │ ├── endpoints │ │ ├── __init__.py | | ├── errors.py │ │ ├── index.py │ │ └── ... │ ├── components.py │ ├── main.py │ ├── pages.py │ └── ... ├── static ├── tests ├── README.md └── pyproject.toml
For larger applications, the structure can vary significantly. Additionally, many modules are missing, such as models and database connections. However, if you're just beginning, this still serves as a good starting point.
pages.py
The idea is to create a few pages (regular components) that render as valid HTML documents using the <html>
root tag.
endpoints
The endpoints module contains all the application's endpoints. The index module includes endpoints that render when users open the site, serving as the root of your web application. The errors module contains error handlers, such as displaying the 404 page.
components.py
Any component you want to use in your application should be registered here. For example, a Navigation
component and its attributes could be registered in the components.py
file.
main.py
The module instantiates the LudicApp
class and registers routes by importing the endpoints
module.
What's Next?
#In the following sections of this documentation, you will learn more about writing components and endpoints, as well as the various other tools available. You will also learn about the Catalog, which can be used to quickly create the basic layout of your web application.