This project demonstrates how to set up and configure a Directus backend with MySQL, create basic functionalities for user authentication and task management, and integrate a frontend using Svelte and Flowbite.
Directus Setup with MySQL
User Login
Task Management
Frontend Integration with Svelte and Flowbite
Install Directus
Follow the Directus installation guide to install Directus.
Configure MySQL
Ensure you have a MySQL database set up. Configure Directus to use your MySQL database by updating the .env
file with your database credentials:
DB_CLIENT=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USER=your_database_user
DB_PASSWORD=your_database_password
Access the Directus Admin Panel
Open your web browser and navigate to your Directus admin panel. This is typically accessible at http://localhost:8055
or the URL where you have Directus hosted.
Create a New Collection for Tasks
Navigate to Collections & Fields: In the admin panel, go to the sidebar and select Collections & Fields
.
Add a New Collection: Click the + Add Collection
button.
Configure Collection Settings:
Tasks
for the collection name.Add Fields to the Collection:
Title:
Text
title
Title
Description:
Text Area
description
Description
Status:
Enumeration
status
Status
pending
completed
pending
Due Date:
Date
due_date
Due Date
Save the Collection: Once all fields are added, click the Save Collection
button.
Configure Authentication Settings
Navigate to Authentication Settings: In the admin panel, go to Settings
and then Authentication
.
Set Up Authentication:
Create User Roles: Optionally, set up roles and permissions for different types of users to manage access to the tasks.
Test the Setup
Add Sample Tasks: Go to the Tasks
collection and add a few sample tasks to ensure everything is working correctly.
Verify User Authentication: Test the login and logout functionalities to ensure users can authenticate properly.
To get started, download the repository and open it in your preferred code editor:
Navigate to the Svelte project directory and install the required dependencies:
npm install
Create a .env file in your Svelte project root and add your Directus API URL:
VITE_DIRECTUS_API_URL=http://localhost:8055
Start the development server:
npm run dev
The project should now be running at http://localhost:3000.
Users can log in using the login form provided in the Svelte frontend. The authentication is handled by Directus.
Users can add, view, and delete tasks. Tasks are managed through Directus and displayed in the Svelte frontend.