---
title: "First Project with Autohand Code"
description: "Build your first complete full-stack web application with AI assistance. Learn how to create a task management app from scratch using Autohand Code."
sidebar:
  label: "First Project"
seo:
  description: "Build your first complete application with Autohand Code. Step-by-step tutorial to create a full-stack web app with AI assistance."
---

:::tip
**What we'll build:** A complete task management web application with React frontend, Node.js backend, and database integration. **Estimated time:** 45 minutes
:::

## Project Overview

We'll build a modern task management application called "TaskFlow" with the following features:

**Task Management**

Create, edit, delete, and organize tasks

**Categories & Priority**

Organize tasks by categories and set priorities

**Due Dates & Reminders**

Set deadlines and get notifications

**Search & Filter**

Find tasks quickly with advanced search

### Technology Stack

- **Frontend:** React 18, TypeScript, Tailwind CSS
- **Backend:** Node.js, Express.js, TypeScript
- **Database:** PostgreSQL with Prisma ORM
- **Authentication:** JWT tokens
- **Deployment:** Docker containers

## Step 1: Project Setup [#setup-project]

Let's start by creating the project structure with Autohand Code:

### Create Project Directory

```bash
# Create the project directory and a git repository
mkdir taskflow-app
cd taskflow-app
git init

# Create an AGENTS.md with project instructions for Autohand Code
autohand init

# Then describe the stack in AGENTS.md so every run follows it:
# - frontend/ (React, TypeScript, Tailwind CSS)
# - backend/ (Node.js, Express, TypeScript, Prisma)
# - PostgreSQL database
# - Docker for deployment
```

### Generate Project Structure

```bash
# Ask Autohand Code to scaffold the project structure
autohand -p "Create a full-stack project structure for a task management app: a React app in frontend/, a Node.js API in backend/, a docker-compose.yml and a README.md"

# Or create the package.json files one at a time
autohand -p "Create frontend/package.json for a React app with TypeScript"
autohand -p "Create backend/package.json for a Node.js API with TypeScript"
```

Each `autohand -p` call runs one instruction and exits. Name the file or folder in the prompt and Autohand Code writes it there. To work through several steps in one conversation, run `autohand` on its own to start an interactive session.

### Install Dependencies

```bash
# Install frontend dependencies
cd frontend
npm install
npm install @types/react @types/react-dom typescript tailwindcss

# Install backend dependencies
cd ../backend
npm install
npm install express prisma @prisma/client jsonwebtoken bcryptjs cors
npm install @types/express @types/jsonwebtoken @types/bcryptjs @types/cors typescript ts-node

# Return to root
cd ..
```

## Step 2: Database Setup [#database-setup]

Let's create the database schema with Autohand Code:

### Generate Database Schema

```bash
# Generate the Prisma schema
autohand -p "Create backend/prisma/schema.prisma for a task management app with users, tasks and categories"
```

This generates a complete schema file:

```prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  username  String   @unique
  password  String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  
  tasks     Task[]
  categories Category[]
  
  @@map("users")
}

model Category {
  id          String   @id @default(cuid())
  name        String
  color       String   @default("#3B82F6")
  userId      String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  
  user        User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  tasks       Task[]
  
  @@unique([userId, name])
  @@map("categories")
}

model Task {
  id          String   @id @default(cuid())
  title       String
  description String?
  priority    Priority @default(MEDIUM)
  status      Status   @default(TODO)
  dueDate     DateTime?
  categoryId  String
  userId      String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  
  user        User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  category    Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
  
  @@map("tasks")
}

enum Priority {
  LOW
  MEDIUM
  HIGH
  URGENT
}

enum Status {
  TODO
  IN_PROGRESS
  DONE
  CANCELLED
}
```

### Initialize Database

```bash
# Initialize Prisma
cd backend
npx prisma init

# Generate Prisma client
npx prisma generate

# Create and run migrations
npx prisma migrate dev --name init

# Seed database (optional)
npx prisma db seed
```

## Step 3: Backend API Development [#backend-api]

Now let's build the backend API with Autohand Code:

### Generate Express Server

```bash
# Generate the main server file
autohand -p "Create backend/server.js: an Express.js server with CORS, JSON parsing and error handling"

# Generate API routes
autohand -p "Create backend/routes/tasks.js with REST routes for tasks (CRUD)"
autohand -p "Create backend/routes/users.js with REST routes for users, including authentication"
```

This creates a complete server setup:

```ts
import express from 'express';
import cors from 'cors';
import { PrismaClient } from '@prisma/client';
import authRoutes from './routes/auth';
import taskRoutes from './routes/tasks';
import categoryRoutes from './routes/categories';
import { errorHandler } from './middleware/errorHandler';
import { notFound } from './middleware/notFound';

const app = express();
const prisma = new PrismaClient();

// Middleware
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// Health check
app.get('/health', (req, res) => {
  res.json({ status: 'OK', timestamp: new Date().toISOString() });
});

// Routes
app.use('/api/auth', authRoutes);
app.use('/api/tasks', taskRoutes);
app.use('/api/categories', categoryRoutes);

// Error handling
app.use(notFound);
app.use(errorHandler);

const PORT = process.env.PORT || 3001;

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`);
});

export default app;
```

### Generate Authentication Routes

```bash
# Generate authentication routes
autohand -p "Create backend/src/routes/auth.ts: Express.js authentication routes with JWT, bcrypt and validation"
```

### Generate Task Routes

```bash
# Generate task CRUD routes
autohand -p "Create backend/src/routes/tasks.ts: Express.js CRUD routes for tasks with validation and error handling"
```

### Generate Category Routes

```bash
# Generate category CRUD routes
autohand -p "Create backend/src/routes/categories.ts: Express.js CRUD routes for categories with validation"
```

### Generate Middleware

```bash
# Generate authentication middleware
autohand -p "Create backend/src/middleware/auth.ts: JWT authentication middleware for Express.js"

# Generate error handling middleware
autohand -p "Create backend/src/middleware/errorHandler.ts: error handling middleware for Express.js"
```

## Step 4: Frontend Development [#frontend-development]

Let's build the React frontend with Autohand Code:

### Generate React App Structure

```bash
# Generate the main App component
autohand -p "Create frontend/src/App.tsx: a React App component with routing and layout"

# Generate the TaskList component
autohand -p "Create frontend/src/components/TaskList.tsx: a React task list with filtering and sorting"

# Generate the TaskForm component
autohand -p "Create frontend/src/components/TaskForm.tsx: a React task form with validation"

# Or build the frontend step by step in an interactive session
autohand
```

### Main App Component

```ts
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { AuthProvider } from './contexts/AuthContext';
import { ThemeProvider } from './contexts/ThemeContext';
import Layout from './components/Layout/Layout';
import Login from './pages/Login';
import Register from './pages/Register';
import Dashboard from './pages/Dashboard';
import Tasks from './pages/Tasks';
import Categories from './pages/Categories';
import Profile from './pages/Profile';
import ProtectedRoute from './components/Auth/ProtectedRoute';
import './index.css';

const queryClient = new QueryClient();

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <ThemeProvider>
        <AuthProvider>
          <Router>
            <Routes>
              <Route path="/login" element={<Login />} />
              <Route path="/register" element={<Register />} />
              <Route path="/" element={
                <ProtectedRoute>
                  <Layout>
                    <Routes>
                      <Route index element={<Dashboard />} />
                      <Route path="tasks" element={<Tasks />} />
                      <Route path="categories" element={<Categories />} />
                      <Route path="profile" element={<Profile />} />
                    </Routes>
                  </Layout>
                </ProtectedRoute>
              } />
            </Routes>
          </Router>
        </AuthProvider>
      </ThemeProvider>
    </QueryClientProvider>
  );
}

export default App;
```

### Generate Task Components

```bash
# Generate the task list component
autohand -p "Create frontend/src/components/Tasks/TaskList.tsx: a React task list with filtering, sorting and search"

# Generate the task form component
autohand -p "Create frontend/src/components/Tasks/TaskForm.tsx: a React task form with validation, in TypeScript"

# Generate the task card component
autohand -p "Create frontend/src/components/Tasks/TaskCard.tsx: a React task card with priority indicators and actions"
```

### Generate Authentication Components

```bash
# Generate the login page
autohand -p "Create frontend/src/pages/Login.tsx: a React login form in TypeScript with validation and error handling"

# Generate the register page
autohand -p "Create frontend/src/pages/Register.tsx: a React register form in TypeScript with validation"
```

## Step 5: Styling with Tailwind CSS [#styling]

Let's add beautiful styling with Tailwind CSS:

### Configure Tailwind

```bash
# Initialize Tailwind CSS
cd frontend
npx tailwindcss init -p
cd ..

# Customize the Tailwind configuration
autohand -p "Update frontend/tailwind.config.js with custom colors and component styles"
```

### Generate CSS Styles

```bash
# Generate the main CSS file
autohand -p "Write Tailwind CSS styles for the task management app, with custom components, in frontend/src/index.css"
```

### Generate Component Styles

```bash
# Generate component styles
autohand -p "Create frontend/src/components/Tasks/Tasks.css with Tailwind utility classes for the task components"

# Generate layout styles
autohand -p "Create frontend/src/components/Layout/Layout.css with Tailwind styles for the layout components"
```

## Step 6: Testing with Autohand Code [#testing]

Let's generate comprehensive tests for our application:

### Backend Tests

```bash
# Generate API tests
autohand -p "Write Jest tests for every route in backend/src/routes"

# Generate authentication tests
autohand -p "Write Jest tests for backend/src/routes/auth.ts"

# Generate task management tests
autohand -p "Write Jest tests for backend/src/routes/tasks.ts"
```

### Frontend Tests

```bash
# Generate React component tests
autohand -p "Write React Testing Library tests for the components in frontend/src/components"

# Generate page tests
autohand -p "Write React Testing Library tests for the pages in frontend/src/pages"

# Generate end-to-end tests
autohand -p "Write Cypress end-to-end tests for the main user flows and add a test:e2e script to frontend/package.json"
```

### Run Tests

```bash
# Run backend tests
cd backend
npm test

# Run frontend tests
cd ../frontend
npm test

# Run integration tests
npm run test:e2e
```

## Step 7: Deployment [#deployment]

Let's prepare our application for deployment:

### Generate Docker Configuration

```bash
# Preview the Docker setup as a patch before changing any files
autohand -p "Create backend/Dockerfile for the Node.js TypeScript API, frontend/Dockerfile that serves the React build with Nginx, and a docker-compose.yml with PostgreSQL" --patch --output docker.patch

# Review the patch, then apply it
git apply docker.patch
```

### Backend Tests

```bash
# Generate API tests
autohand -p "Write Jest API tests for the Express.js routes, including authentication, in backend/tests/api.test.ts"

# Generate model tests
autohand -p "Write Jest tests for the Prisma models with CRUD operations in backend/tests/models.test.ts"
```

### Deploy Application

```bash
# Build and run with Docker
docker-compose up --build

# Deploy to production
docker-compose -f docker-compose.prod.yml up -d
```

## Next Steps & Enhancements [#next-steps]

Congratulations! You've built your first full-stack application with Autohand Code. Here are some ideas for enhancements:

**Real-time Updates**

Add WebSocket support for real-time task updates and notifications

```bash
autohand --worktree websocket -p "Add WebSocket support in backend/src/websocket/ for real-time task updates"
```

**Mobile App**

Create a React Native mobile version of TaskFlow

```bash
autohand --worktree mobile -p "Create a React Native task management app in mobile/ that uses the TaskFlow API"
```

**Analytics Dashboard**

Add analytics and reporting features for task insights

```bash
autohand -p "Plan an analytics dashboard with charts and metrics in frontend/src/components/Analytics/" --plan
```

**Team Collaboration**

Add team features, sharing, and collaboration tools

```bash
# Work on team features interactively in an isolated git worktree
autohand --worktree teams
```

## Project Summary [#summary]

What you've accomplished with Autohand Code:

**Complete Project Structure**

Generated a full-stack project with proper organization and configuration

**Database Design**

Created a comprehensive database schema with relationships and constraints

**Backend API**

Built a complete REST API with authentication, validation, and error handling

**Frontend Application**

Created a modern React app with routing, state management, and responsive design

**Testing Suite**

Generated comprehensive unit and integration tests for the entire application

**Deployment Ready**

Prepared Docker configuration and deployment scripts for production

:::tip
**Time Saved:** Building this application manually would take 40-60 hours. With Autohand Code, you completed it in under 45 minutes!
:::
