
Building a Full-Stack Student Task Manager with AWS Blocks
Learn how to build a secure, beginner-friendly task management application using AWS Blocks, React, and TypeScript with zero AWS infrastructure setup required for local development.
INTRODUCTION
- As a student developer exploring full-stack development, I wanted to build something practical while learning modern cloud development patterns.
- I discovered AWS Blocks, a framework that lets you write type-safe infrastructure and runtime code together.
- The best part is that everything runs locally first with zero AWS account required.
- In this article, I'll walk you through building a Student Task Manager application that demonstrates:
- Authentication
- Data storage
- Secure API design
- AWS Blocks Building Blocks
WHAT YOU'LL BUILD
- A complete task management application where students can:
- ✅ Sign up and sign in securely
- ✅ Create, edit, and delete their own tasks
- ✅ Mark tasks as complete/incomplete
- ✅ View only their own data
- ✅ Enforce user isolation on the backend
TECH STACK
- Backend:
- AWS Blocks
- AuthBasic
- KVStore
- ApiNamespace
- Frontend:
- React 18
- TypeScript
- Local Development:
- Built-in AWS Blocks local mock implementations
- Deployment:
- One command to AWS when ready
WHY AWS BLOCKS?
Traditional full-stack development requires:
- Setting up separate backend and frontend projects
- Configuring databases, authentication, and APIs independently
- Writing infrastructure-as-code separately from application code
- Managing type safety across the stack manually
AWS Blocks changes this:
- Write backend and frontend in one project
- Import backend APIs directly in frontend code
- Get type-safe API communication
- Develop locally with zero AWS setup
- Deploy to production AWS with one command
PROJECT SETUP
- Create a new AWS Blocks project:
npm create @aws-blocks/blocks-app@latest student-task-manager
cd student-task-manager
npm install
- Install React dependencies:
npm install react react-dom
npm install -D @types/react @types/react-dom @vitejs/plugin-react
ARCHITECTURE OVERVIEW
BUILDING BLOCKS USED
- AuthBasic
- Username/password authentication with JWT
- KVStore
- Two instances are used for tasks and indexes
- Provides key-value storage
- ApiNamespace
- Provides type-safe RPC endpoints
DATA MODEL
Each task contains:
- id: string
- title: string
- completed: boolean
- createdAt: number
- userId: string
STORAGE STRATEGY
- Two KVStore instances are used for better type safety.
- taskStore:
- Stores individual task objects
- Key pattern: tasks:{userId}:{taskId}
- Schema: Zod taskSchema
- indexStore:
- Stores per-user task ID lists
- Key pattern: task-index:{userId}
- Schema: Zod taskIdListSchema
This approach provides:
- Type validation on every read/write
- User data isolation
- Easy querying of a user's tasks
BACKEND IMPLEMENTATION
- The backend lives in aws-blocks/index.ts
- AUTHENTICATION SETUP
- Import the required modules:
import { ApiNamespace, Scope, AuthBasic } from '@aws-blocks/blocks';
import { KVStore } from '@aws-blocks/bb-kv-store';
import { z } from 'zod';
- Create the scope:
const scope = new Scope('student-task-manager');
- Configure authentication:
const auth = new AuthBasic(scope, 'auth', {
passwordPolicy: { minLength: 8 },
crossDomain: process.env.BLOCKS_SANDBOX === 'true',
});
- Create the authentication API:
export const authApi = auth.createApi();
- STORAGE SETUP WITH ZOD SCHEMAS
- Define the task schema:
const taskSchema = z.object({
id: z.string(),
title: z.string(),
completed: z.boolean(),
createdAt: z.number(),
userId: z.string(),
});
- Define the task ID list schema:
const taskIdListSchema = z.array(z.string());
- Create the Task type:
export type Task = z.infer;
- Create the KVStore instances:
const taskStore = new KVStore(scope, 'task-objects', { schema: taskSchema });
const indexStore = new KVStore(scope, 'task-indexes', { schema: taskIdListSchema });
- SECURITY-FIRST KEY MANAGEMENT
- Critical security principle:
- The userId always comes from the authenticated context on the backend.
- The userId should never come from frontend input.
- Task key:
function taskKey(userId: string, taskId: string) {
return
tasks:${userId}:${taskId} ;
}- Index key:
function indexKey(userId: string) {
return
task-index:${userId} ;
}- Get task IDs:
async function getTaskIds(userId: string): Promise<string[]> {
return (await indexStore.get(indexKey(userId))) ?? [];
}
- Save task IDs:
async function saveTaskIds(userId: string, ids: string[]): Promise {
await indexStore.put(indexKey(userId), ids);
}
- TYPE-SAFE API ENDPOINTS
- Create Task:
- Authenticate the user
- Get the authenticated userId
- Generate a unique task ID
- Store the task
- Update the user's task index
- Return the created task
- List Tasks:
- Authenticate the user
- Get the user's task IDs
- Retrieve each task
- Return tasks sorted by creation time
- Update Task:
- Authenticate the user
- Find the task using the authenticated user's ID
- Update the title
- Save the updated task
- Toggle Task:
- Authenticate the user
- Find the task
- Toggle the completed status
- Save the updated task
- Delete Task:
- Authenticate the user
- Find the task
- Delete the task
- Remove the task ID from the user's index
FRONTEND IMPLEMENTATION
- The frontend is located in src/index.tsx
- It is a React single-page application.
- It demonstrates the type-safe import pattern.
THE MAGIC: IMPORT BACKEND DIRECTLY
- Import the backend API directly:
import { api, authApi, type Task } from 'aws-blocks';
import { onAuthChange, broadcastAuthChange } from '@aws-blocks/blocks/ui';
- AWS Blocks tooling provides:
- ✅ Knowledge of all API methods
- ✅ Full TypeScript autocomplete
- ✅ Type checking for arguments and return values
- ✅ Automatic serialization
AUTHENTICATION FLOW
- AuthBasic uses a state-machine pattern.
- The sign-in process:
- Prevents the default form submission
- Clears previous errors
- Shows the loading state
- Calls authApi.setAuthState()
- Checks whether the user is signed in
- Broadcasts the authentication change
- Displays an error when authentication fails
- Stops the loading state
CALLING BACKEND APIs
- Create a task:
const task = await api.createTask(title);
- Toggle a task:
const updated = await api.toggleTask(id);
- TypeScript automatically knows:
- createTask() accepts a string
- createTask() returns Promise
- toggleTask() accepts a string
- toggleTask() returns Promise
- Incorrect method names produce compile errors
- Incorrect argument types produce compile errors
SECURITY HIGHLIGHTS
USER DATA ISOLATION
- Every API endpoint starts by authenticating the user:
const user = await auth.requireAuth(context);
const userId = user.userId;
- This ensures:
- Unauthenticated requests are rejected
- userId comes from the JWT token
- userId does not come from user input
- Users can only access their own data
EXAMPLE ATTACK PREVENTION
- A malicious user may try to access another user's task by guessing a taskId.
- The backend prevents this by:
- Getting the authenticated user's ID
- Building the task key using that user ID
- Searching only within that user's namespace
- Returning "Task not found" if the task belongs to another user
- Example:
const user = await auth.requireAuth(context);
const userId = user.userId;
const task = await taskStore.get(taskKey(userId, taskId));
if (!task) throw new Error('Task not found');
- Even if an attacker knows another user's task ID, they cannot access it because the key includes their own authenticated userId.
RUNNING LOCALLY
- Start the development server:
npm run dev
- This starts:
- AWS Blocks local server
- Vite development server for hot reload
- No AWS account is required.
- Local mocks provide:
- Authentication using local file storage
- KVStore using local file storage
- Data stored in the local data directory
USER EXPERIENCE FEATURES
AUTHENTICATION
- Sign up and sign in forms
- Form validation
- Minimum password length of 8 characters
- Error handling
- Loading states
- Automatic session persistence
TASK MANAGEMENT
- Add tasks using a simple input
- Double-click or click ✏️ to edit
- Click the checkbox to toggle completion
- Click 🗑️ to delete
- Tasks sorted by creation time
- Task counter showing remaining tasks
UI STATES
- ⏳ Loading state while fetching
- 🎉 Empty state for new users
- ⚠️ Error banners for failed operations
- ✅ Success feedback
RESPONSIVE DESIGN
- Mobile-friendly layout
- Clean and minimal styling
- Accessible UI
- ARIA labels
- Keyboard navigation
DEPLOYING TO AWS
- When ready to deploy to production AWS:
npm run sandbox
- This command:
- Deploys Building Blocks to AWS
- Creates or uses DynamoDB
- Creates or uses Cognito
- Creates or uses API Gateway
- Deploys Lambda functions
- Uploads the frontend to CloudFront CDN
- Provides a production URL
- Automatically manages infrastructure
- No manual AWS Console configuration is required.
KEY LEARNINGS
- TYPE SAFETY ACROSS THE STACK
- Backend APIs can be imported directly into the frontend.
- Full type checking is available.
- API contracts do not need to be manually synchronized.
- LOCAL-FIRST DEVELOPMENT
- No AWS credentials are required during local development.
- No database setup is required.
- No infrastructure management is required locally.
- This reduces friction while learning.
- SECURITY BY DEFAULT
- Always read userId from auth.requireAuth(context).
- This makes it harder to accidentally introduce security vulnerabilities.
- BUILDING BLOCKS COMPOSITION
- Multiple KVStore instances can be combined.
- Zod schemas provide type safety.
- Each Building Block has a focused responsibility.
- REACT INTEGRATION
- onAuthChange
- broadcastAuthChange
These utilities make authentication state management across tabs and sessions easier.
CHALLENGES AND SOLUTIONS
CHALLENGE 1: UNDERSTANDING THE STATE MACHINE
- Challenge:
- AuthBasic uses a state-machine pattern instead of simple signIn() / signUp() methods.
- Solution:
- Reading the documentation for getAuthState() and setAuthState() clarified how to handle authentication states such as confirmingSignUp.
CHALLENGE 2: TYPE RESOLUTION
- Challenge:
- Initially had issues importing KVStore from the wrong entry point.
- Solution:
- Import KVStore directly from @aws-blocks/bb-kv-store
- Instead of re-exporting it through @aws-blocks/blocks
CHALLENGE 3: USER DATA ISOLATION
- Challenge:
- Ensuring users could not access each other's tasks required careful key design.
- Solution:
- Always use userId from auth.requireAuth(context)
- Build keys using tasks:{userId}:{taskId}
WHAT'S NEXT?
Potential enhancements include:
- 📅 Due dates and reminders
- 🏷️ Task categories and tags
- 📊 Progress tracking and statistics
- 👥 Shared tasks between students
- 🔔 Push notifications using AWS Blocks Realtime
- 📱 Progressive Web App (PWA) support
CONCLUSION
- Building with AWS Blocks taught me that full-stack development does not have to be complex.
- The local-first approach allows developers to focus on application logic rather than infrastructure setup.
- The type-safe RPC pattern eliminates an entire class of bugs.
- The Building Blocks abstraction makes it easier to add authentication and storage.
- Students and beginner developers can build and test applications locally.
- Applications can later be deployed to production AWS.
- CloudFormation or Terraform is not required for this workflow.

Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article