bash
# Setup Instructions
# 1. Create the project using Vite + Vue 3 TypeScript template
npm create vue@latest project-management-app -- --template vue-ts
cd project-management-app
# 2. Install dependencies
npm install vue-router@4 pinia
npm install lucide-vue-next # Icons for UI
npm install -D tailwindcss postcss autoprefixer @tailwindcss/typography
# 3. Initialize Tailwind
npx tailwindcss init -p
# 4. Update tailwind.config.js (content shown below)
# 5. Run the dev server
npm run dev
Project Overview
This is a scalable Project Management Dashboard application built with:
- Vue 3 (Composition API +
<script setup> everywhere)
- TypeScript (strict mode)
- Vite (fast HMR, optimized builds)
- Vue Router 4 (lazy-loaded routes, nested routing, route guards)
- Pinia (modular stores for auth, projects, tasks)
- Tailwind CSS (responsive, utility-first styling)
- Lucide Vue Next (icons)
- Mock API (localStorage + async delays for realism; easily replaceable with real backend)
- Large-scale patterns:
- Modular folder structure (composables, stores, types, layouts, views)
- Route meta for guards
- Composables for API, auth, modals
- Error boundaries, loading states
- Responsive design (mobile-first)
- Type-safe everything (interfaces, generics)
- Lazy loading for performance
- Extensible (add more stores, plugins easily)
Features:
- Authentication (login/logout)
- Dashboard: List projects
- Project details: View tasks, mark complete
- Create/Edit projects & tasks (modals)
- Protected routes
- Responsive sidebar layout
- Persistent state (localStorage)
Folder Structure:
code
src/
├── assets/
├── components/
│ ├── ui/ # Reusable UI (Button, Modal, Spinner)
│ ├── ProjectCard.vue
│ └── TaskItem.vue
├── composables/
│ ├── useApi.ts
│ ├── useAuth.ts
│ └── useModal.ts
├── layouts/
│ └── DefaultLayout.vue
├── router/
│ └── index.ts
├── stores/
│ ├── auth.ts
│ ├── projects.ts
│ └── index.ts
├── types/
│ └── index.ts
├── views/
│ ├── Login.vue
│ ├── Dashboard.vue (redirects to projects)
│ ├── ProjectList.vue
│ └── ProjectDetail.vue
├── App.vue
├── main.ts
└── style.css
Key Files & Code
1. tailwind.config.js
js
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [require('@tailwindcss/typography')],
}
2. postcss.config.js (auto-generated, verify)
js
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
3. vite.config.ts
ts
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
4. tsconfig.json (key strict settings)
json
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
5. src/style.css
css
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.btn {
@apply px-4 py-2 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2;
}
.btn-primary { @apply bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500; }
.btn-secondary { @apply bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-500; }
}
6. src/main.ts
ts
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import router from '@/router'
import App from './App.vue'
import '@/style.css'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.mount('#app')
7. src/App.vue
vue
<template>
<router-view />
</template>
<script setup lang="ts">
// Root layout handled by router
</script>
8. src/types/index.ts
ts
export interface User {
id: number
name: string
email: string
}
export interface Task {
id: number
title: string
description?: string
completed: boolean
projectId: number
}
export interface Project {
id: number
name: string
description: string
tasks: Task[]
}
export interface ApiResponse<T> {
data: T
error?: string
}
9. src/composables/useApi.ts (Type-safe HTTP client)
ts
import type { ApiResponse } from '@/types'
export const useApi = () => {
const baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:3000/api' // Mock or real
const request = async <T>(url: string, options: RequestInit = {}): Promise<ApiResponse<T>> => {
try {
// Mock delay for realism
await new Promise(resolve => setTimeout(resolve, 500 + Math.random() * 500))
const response = await fetch(`${baseUrl}${url}`, {
...options,
headers: {
'Content-Type': 'application/json',
...options.headers,
},
})
if (!response.ok) throw new Error(`HTTP ${response.status}`)
const data = await response.json()
return { data }
} catch (error) {
console.error('API Error:', error)
return { data: null as T, error: (error as Error).message }
}
}
const get = <T>(url: string) => request<T>(url, { method: 'GET' })
const post = <T>(url: string, body: any) => request<T>(url, { method: 'POST', body: JSON.stringify(body) })
const put = <T>(url: string, body: any) => request<T>(url, { method: 'PUT', body: JSON.stringify(body) })
const del = <T>(url: string) => request<T>(url, { method: 'DELETE' })
return { get, post, put, del }
}
10. src/stores/auth.ts
ts
import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { User } from '@/types'
import { useApi } from '@/composables/useApi'
export const useAuthStore = defineStore('auth', () => {
const user = ref<User | null>(null)
const isLoggedIn = ref(false)
const loading = ref(false)
const api = useApi()
const login = async (email: string, password: string) => {
loading.value = true
const res = await api.post<{ user: User }>('/auth/login', { email, password })
if (res.error) throw new Error(res.error)
user.value = res.data.user
isLoggedIn.value = true
localStorage.setItem('token', 'mock-jwt') // Persist
loading.value = false
}
const logout = () => {
user.value = null
isLoggedIn.value = false
localStorage.removeItem('token')
}
const init = () => {
// Check localStorage on app start
if (localStorage.getItem('token')) {
isLoggedIn.value = true
user.value = { id: 1, name: 'Demo User', email: 'user@example.com' }
}
}
return { user, isLoggedIn, loading, login, logout, init }
})
11. src/stores/projects.ts
ts
import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { Project, Task } from '@/types'
import { useApi } from '@/composables/useApi'
export const useProjectsStore = defineStore('projects', () => {
const projects = ref<Project[]>([])
const loading = ref(false)
const error = ref<string | null>(null)
const api = useApi()
const fetchProjects = async () => {
loading.value = true
error.value = null
const res = await api.get<{ projects: Project[] }>('/projects')
if (res.error) {
error.value = res.error
} else {
projects.value = res.data.projects || []
}
loading.value = false
}
const createProject = async (name: string, description: string) => {
const res = await api.post<{ project: Project }>('/projects', { name, description })
if (!res.error && res.data.project) {
projects.value.push(res.data.project)
}
return res
}
const toggleTask = async (taskId: number, projectId: number, completed: boolean) => {
const project = projects.value.find(p => p.id === projectId)
if (!project) return
const task = project.tasks.find(t => t.id === taskId)
if (!task) return
task.completed = !completed
// Optimistic update; persist with PUT
await api.put(`/projects/${projectId}/tasks/${taskId}`, { completed: task.completed })
}
const addTask = async (projectId: number, title: string) => {
const res = await api.post<{ task: Task }>('/tasks', { projectId, title })
if (!res.error && res.data.task) {
const project = projects.value.find(p => p.id === projectId)
if (project) project.tasks.push(res.data.task)
}
return res
}
return { projects, loading, error, fetchProjects, createProject, toggleTask, addTask }
})
12. src/router/index.ts
ts
import { createRouter, createWebHistory } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
redirect: '/login'
},
{
path: '/login',
name: 'Login',
component: () => import('@/views/Login.vue')
},
{
path: '/dashboard',
component: () => import('@/layouts/DefaultLayout.vue'),
meta: { requiresAuth: true },
children: [
{
path: '',
name: 'ProjectList',
component: () => import('@/views/ProjectList.vue')
},
{
path: 'project/:id',
name: 'ProjectDetail',
component: () => import('@/views/ProjectDetail.vue')
}
]
}
]
})
router.beforeEach(async (to, from, next) => {
const authStore = useAuthStore()
await authStore.init() // Ensure auth state is loaded
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
next('/login')
} else {
next()
}
})
export default router
13. src/components/ui/Button.vue (Reusable)
vue
<template>
<button
class="btn"
:class="variant === 'primary' ? 'btn-primary' : 'btn-secondary'"
:disabled="loading"
@click="$emit('click')"
>
<slot v-if="!loading" />
<span v-else>⏳</span>
</button>
</template>
<script setup lang="ts">
defineProps<{
variant?: 'primary' | 'secondary'
loading?: boolean
}>()
defineEmits<{
(e: 'click'): void
}>()
</script>
14. src/components/ui/Modal.vue (Reusable)
vue
<template>
<Teleport to="body">
<div v-if="modelValue" class="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4" @click.self="close">
<div class="bg-white rounded-xl shadow-2xl max-w-md w-full max-h-[90vh] overflow-y-auto">
<div class="p-6">
<slot />
</div>
<div class="px-6 pb-6 flex gap-3 justify-end">
<Button variant="secondary" @click="close">Cancel</Button>
<Button variant="primary" :loading="saving" @click="$emit('save')">
Save
</Button>
</div>
</div>
</div>
</Teleport>
</template>
<script setup lang="ts">
import Button from './Button.vue'
import { ref } from 'vue'
const props = defineProps<{
modelValue: boolean
saving?: boolean
}>()
const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void
(e: 'save'): void
}>()
const close = () => emit('update:modelValue', false)
</script>
15. src/components/ProjectCard.vue
vue
<template>
<div class="bg-white border rounded-lg p-6 shadow-sm hover:shadow-md transition-shadow">
<h3 class="text-xl font-bold mb-2">{{ project.name }}</h3>
<p class="text-gray-600 mb-4">{{ project.description }}</p>
<div class="flex justify-between items-center">
<span class="text-sm text-gray-500">{{ project.tasks.length }} tasks</span>
<router-link
:to="{ name: 'ProjectDetail', params: { id: project.id } }"
class="text-blue-600 hover:underline"
>
View
</router-link>
</div>
</div>
</template>
<script setup lang="ts">
import type { Project } from '@/types'
defineProps<{
project: Project
}>()
</script>
16. src/components/TaskItem.vue
vue
<template>
<div class="flex items-center gap-3 p-3 border rounded-md">
<input
type="checkbox"
:checked="task.completed"
@change="$emit('toggle', task.id)"
class="w-5 h-5 rounded"
/>
<label :class="{ 'line-through text-gray-500': task.completed }">
{{ task.title }}
</label>
</div>
</template>
<script setup lang="ts">
import type { Task } from '@/types'
defineProps<{
task: Task
}>()
defineEmits<{
(e: 'toggle', taskId: number): void
}>()
</script>
17. src/layouts/DefaultLayout.vue
vue
<template>
<div class="min-h-screen bg-gray-50">
<aside class="w-64 bg-white border-r shadow-sm h-screen fixed inset-y-0 left-0 z-40 lg:flex">
<nav class="p-6 w-full">
<h1 class="text-2xl font-bold mb-8">Project Mgmt</h1>
<ul class="space-y-4">
<li>
<router-link to="/dashboard" class="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-100">
<i data-lucide="layout" class="w-5 h-5" />
<span>Projects</span>
</router-link>
</li>
<li>
<button @click="logout" class="w-full flex items-center gap-3 p-3 rounded-lg hover:bg-gray-100 text-left">
<i data-lucide="log-out" class="w-5 h-5" />
<span>Logout</span>
</button>
</li>
</ul>
</nav>
</aside>
<main class="lg:ml-64 p-8">
<slot />
</main>
</div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { LucideIcon } from 'lucide-vue-next'
const router = useRouter()
const authStore = useAuthStore()
const logout = () => {
authStore.logout()
router.push('/login')
}
</script>
18. src/views/Login.vue
vue
<template>
<div class="min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100 py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full space-y-8 bg-white p-10 rounded-2xl shadow-xl">
<div>
<h2 class="mt-6 text-3xl font-bold text-gray-900 text-center">Sign in</h2>
</div>
<form class="space-y-6" @submit.prevent="handleLogin">
<div>
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">Email</label>
<input
id="email"
v-model="email"
type="email"
required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
/>
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Password</label>
<input
id="password"
v-model="password"
type="password"
required
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
/>
</div>
<Button :loading="loading" class="w-full">Sign in</Button>
<div v-if="error" class="text-red-600 text-sm text-center">{{ error }}</div>
</form>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import Button from '@/components/ui/Button.vue'
const router = useRouter()
const authStore = useAuthStore()
const email = ref('')
const password = ref('')
const loading = ref(false)
const error = ref('')
const handleLogin = async () => {
try {
loading.value = true
error.value = ''
await authStore.login(email.value, password.value)
router.push('/dashboard')
} catch (err: any) {
error.value = err.message || 'Login failed'
} finally {
loading.value = false
}
}
</script>
19. src/views/ProjectList.vue
vue
<template>
<div>
<div class="flex justify-between items-center mb-8">
<h1 class="text-3xl font-bold text-gray-900">Projects</h1>
<Button @click="showCreateModal = true">+ New Project</Button>
</div>
<div v-if="projectsStore.loading" class="flex justify-center py-12">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600" />
</div>
<div v-else-if="projectsStore.error" class="text-red-600 text-center py-12">
Error: {{ projectsStore.error }}
<Button @click="projectsStore.fetchProjects" class="ml-4">Retry</Button>
</div>
<div v-else-if="projectsStore.projects.length === 0" class="text-center py-12 text-gray-500">
No projects yet. Create one!
</div>
<div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<ProjectCard
v-for="project in projectsStore.projects"
:key="project.id"
:project="project"
/>
</div>
<!-- Create Modal -->
<Modal v-model="showCreateModal" :saving="saving" @save="createProject" @update:modelValue="showCreateModal = $event">
<h3 class="text-lg font-semibold mb-4">New Project</h3>
<input
v-model="newProjectName"
placeholder="Project Name"
class="w-full p-3 border rounded-md mb-4"
required
/>
<textarea
v-model="newProjectDesc"
placeholder="Description"
class="w-full p-3 border rounded-md"
rows="3"
/>
</Modal>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import ProjectCard from '@/components/ProjectCard.vue'
import Modal from '@/components/ui/Modal.vue'
import Button from '@/components/ui/Button.vue'
import { useProjectsStore } from '@/stores/projects'
const projectsStore = useProjectsStore()
const showCreateModal = ref(false)
const saving = ref(false)
const newProjectName = ref('')
const newProjectDesc = ref('')
const createProject = async () => {
saving.value = true
try {
await projectsStore.createProject(newProjectName.value, newProjectDesc.value)
showCreateModal.value = false
newProjectName.value = ''
newProjectDesc.value = ''
} finally {
saving.value = false
}
}
onMounted(() => {
projectsStore.fetchProjects()
})
</script>
20. src/views/ProjectDetail.vue
vue
<template>
<div>
<router-link
to="/dashboard"
class="inline-flex items-center gap-2 text-blue-600 hover:underline mb-8"
>
<i data-lucide="arrow-left" class="w-4 h-4" />
Back to Projects
</router-link>
<div v-if="loading" class="flex justify-center py-12">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600" />
</div>
<div v-else-if="project" class="space-y-6">
<div>
<h1 class="text-3xl font-bold">{{ project.name }}</h1>
<p class="text-gray-600 mt-2">{{ project.description }}</p>
</div>
<div class="flex gap-4">
<Button @click="showAddTaskModal = true">+ Add Task</Button>
</div>
<div class="space-y-3">
<TaskItem
v-for="task in project.tasks"
:key="task.id"
:task="task"
@toggle="toggleTask"
/>
</div>
</div>
<div v-else class="text-center py-12 text-gray-500">Project not found</div>
<!-- Add Task Modal -->
<Modal v-model="showAddTaskModal" :saving="savingTask" @save="addTask" @update:modelValue="showAddTaskModal = $event">
<h3 class="text-lg font-semibold mb-4">New Task</h3>
<input
v-model="newTaskTitle"
placeholder="Task Title"
class="w-full p-3 border rounded-md"
required
/>
</Modal>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { useProjectsStore } from '@/stores/projects'
import TaskItem from '@/components/TaskItem.vue'
import Modal from '@/components/ui/Modal.vue'
import Button from '@/components/ui/Button.vue'
import type { Project, Task } from '@/types'
const route = useRoute()
const projectsStore = useProjectsStore()
const projectId = Number(route.params.id)
const loading = ref(true)
const project = computed(() => projectsStore.projects.find(p => p.id === projectId))
const showAddTaskModal = ref(false)
const savingTask = ref(false)
const newTaskTitle = ref('')
const addTask = async () => {
savingTask.value = true
try {
if (!project.value) return
await projectsStore.addTask(project.value.id, newTaskTitle.value)
showAddTaskModal.value = false
newTaskTitle.value = ''
} finally {
savingTask.value = false
}
}
const toggleTask = async (taskId: number) => {
if (!project.value) return
const task = project.value.tasks.find(t => t.id === taskId)
if (task) {
await projectsStore.toggleTask(taskId, project.value.id, task.completed)
}
}
onMounted(async () => {
await projectsStore.fetchProjects()
loading.value = false
})
</script>
Mock Backend (Optional)
For realism, create a simple JSON Server:
bash
npm install -g json-server
# Create db.json with { "projects": [...], "auth": {} }
json-server --watch db.json --port 3000
Update useApi baseUrl to /api.
Scaling Further
- Real API: Replace
useApi with Axios + interceptors
- State Persistence: Pinia-plugin-persistedstate
- Forms: VeeValidate
- UI Lib: shadcn-vue or Vuetify
- Testing: Vitest + Vue Test Utils
- i18n: vue-i18n
- PWA: Vite PWA plugin
This app is production-ready for large-scale: performant, type-safe, modular. Demo login: user@example.com / password. Expand as needed! 🚀