This is a simple React application using Vite as the build tool. Candidates are expected to build a Todo List UI by consuming the provided API. The scaffold includes basic setup and configurations to get started quickly.
This project provides a development environment using devContainers. Open the repository in a devContainer using your preferred IDE (e.g., VS Code). The devContainer will have all dependencies pre-installed.
- MartΓn FernΓ‘ndez (mfernandez@crunchloop.io)
We strongly believe in giving back π. Let's work together Get in touch.
This is a modern TodoList application built with React, TypeScript, and Tailwind CSS. The application allows users to create multiple todo lists, add tasks with descriptions, mark them as complete, and perform bulk operations like completing all tasks in a list.
- React 19 - UI library
- TypeScript - Type safety
- Vite - Build tool and dev server
- Tailwind CSS v4 - Styling
- FastAPI - Backend API (separate repository)
- Create and manage multiple todo lists
- Add tasks with names and descriptions
- Toggle individual task completion status
- Complete all tasks in a list at once
- Edit and delete lists and tasks
- Real-time progress tracking
- Toast notifications for user feedback
- Responsive design
Before running this project, ensure you have:
- Node.js (v22 or higher recommended)
- npm or yarn
- Backend API running - The FastAPI backend must be running and accessible
Create a .env file in the root directory with the following configuration:
VITE_API_URL=http://localhost:8080This URL should point to your running FastAPI backend server.
- Install dependencies:
npm installnpm run devThe application will be available at http://localhost:5173
This project includes a dev container configuration for consistent development environments.
Dev Container Configuration (.devcontainer/devcontainer.json):
{
"name": "Node.js & TypeScript",
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
"forwardPorts": [5173],
"postCreateCommand": [
"bash",
".devcontainer/postCreate.sh"
],
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bradlc.vscode-tailwindcss"
]
}
}
}Steps to run with Docker:
- Open the project in VS Code
- Install the "Dev Containers" extension
- Press
F1and select "Dev Containers: Reopen in Container" - Once the container is built, run
npm run dev
npm run dev- Start development servernpm run build- Build for productionnpm run lint- Run ESLintnpm run preview- Preview production build
src/
βββ assets/
β βββ logo.png
βββ components/
β βββ common/ # Reusable UI components
β β βββ LoadingSpinner.tsx
β β βββ Modal.tsx
β β βββ ToastContainer.tsx
β βββ TodoItem/ # Task-related components
β β βββ TodoItemForm.tsx
β β βββ TodoItemsPanel.tsx
β βββ TodoList/ # List-related components
β βββ TodoListForm.tsx
β βββ TodoListHeader.tsx
β βββ TodoListPanel.tsx
βββ hooks/ # Custom React hooks
β βββ useAsync.ts # Async operation handler
β βββ useToast.ts # Toast notifications
β βββ useTodoItems.ts # Todo items state management
β βββ useTodoLists.ts # Todo lists state management
βββ services/ # API integration layer
β βββ api.ts # Base API client
β βββ todoItemService.ts # Todo items API calls
β βββ todoListService.ts # Todo lists API calls
βββ types/ # TypeScript type definitions
β βββ todoItem.types.ts
β βββ todoList.types.ts
βββ App.tsx # Main application component
βββ index.css # Global styles
βββ main.tsx # Application entry point
βββ vite-env.d.ts # Vite type definitions.env- Environment variablesindex.html- HTML entry pointpackage.json- Dependencies and scriptspackage-lock.json- Dependency lock fileREADME.md- Project documentationtailwind.config.js- Tailwind CSS configurationtsconfig.app.json- TypeScript configuration for apptsconfig.node.json- TypeScript configuration for Nodevite.config.ts- Vite configuration.gitignore- Git ignore ruleseslint.config.js- ESLint configuration
The application follows a clean architecture pattern:
-
Components - Presentational layer, separated into:
- Common components (reusable UI elements)
- Feature-specific components (TodoList, TodoItem)
-
Hooks - Business logic and state management:
useAsync- Generic async operation handleruseToast- Toast notification systemuseTodoItems- Todo items CRUD operationsuseTodoLists- Todo lists CRUD operations
-
Services - API communication layer:
api.ts- Base HTTP client with error handlingtodoItemService.ts- Todo items API endpointstodoListService.ts- Todo lists API endpoints
-
Types - TypeScript definitions for type safety
The frontend connects to a FastAPI backend. The base API client (api.ts) handles:
- HTTP requests (GET, POST, PUT, DELETE)
- Error handling with custom
ApiErrorclass - JSON serialization/deserialization
- Response status validation
API Base URL Configuration:
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8080';Todo Lists:
GET /api/todolists- Get all listsGET /api/todolists/:id- Get list by IDPOST /api/todolists- Create new listPUT /api/todolists/:id- Update listDELETE /api/todolists/:id- Delete list
Todo Items:
GET /api/todolists/:todoListId/items- Get all items in a listGET /api/todolists/:todoListId/items/:itemId- Get item by IDPOST /api/todolists/:todoListId/items- Create new itemPUT /api/todolists/:todoListId/items/:itemId- Update itemDELETE /api/todolists/:todoListId/items/:itemId- Delete itemPOST /api/todolists/:todoListId/items/complete-all- Complete all items
The project uses custom Vite configuration for Docker compatibility:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
server: {
host: '0.0.0.0', // Allow external connections
port: 5173,
strictPort: true,
watch: {
usePolling: true // Required for Docker file watching
}
}
});.env file before starting the frontend.
vite.config.ts.
.env file before running the application. Without it, API calls will fail.
If you encounter API connection errors:
- Verify the backend is running
- Check the
VITE_API_URLin your.envfile - Ensure there are no CORS issues on the backend
- Check browser console for detailed error messages
If port 5173 is already in use:
- Stop the process using that port
- Or modify the port in
vite.config.ts
If the dev container fails to start:
- Ensure Docker is running
- Check the
.devcontainer/postCreate.shscript exists and is executable - Try rebuilding the container: "Dev Containers: Rebuild Container"
- Use TypeScript strict mode for type safety
- Follow the existing component structure
- Keep hooks focused on single responsibilities
- Handle all API errors with user-friendly messages
- Use toast notifications for user feedback
- Test changes with both empty and populated states
When contributing to this project:
-
Follow the existing code structure
-
Maintain TypeScript type definitions
-
Add appropriate error handling
-
Update this documentation if needed
-
Test with the backend API
