Building Responsive Full Stack Applications: A Practical Tutorial
In this technical tutorial, we walk through building a responsive full-stack application from scratch. We will design a simple feedback board using PostgreSQL, Express, React, Node.js (PERN stack), and Tailwind CSS.
Prerequisites
Ensure you have Node.js and PostgreSQL installed on your system. We will use Prisma as our Object-Relational Mapper (ORM).
1. Setting up the Express Backend
First, initialize your project and install the necessary dependencies:
mkdir fullstack-app && cd fullstack-app
npm init -y
npm install express cors dotenv prisma @prisma/client
npx prisma init
Configure your schema.prisma file with a Feedback database model:
model Feedback {
id Int @id @default(autoincrement())
name String
email String
message String
createdAt DateTime @default(now())
}
2. Crafting the Responsive Tailwind Frontend
For the client-side, set up a responsive layout using React. We can implement a clean, accessible layout that scales seamlessly from mobile screens to large desktop monitors:
import React, { useState } from 'react';
export default function FeedbackForm() {
const [formData, setFormData] = useState({ name: '', email: '', message: '' });
const handleSubmit = async (e) => {
e.preventDefault();
const res = await fetch('http://localhost:5000/api/feedback', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData)
});
if (res.ok) alert('Feedback submitted!');
};
return (
<div className="min-h-screen bg-slate-50 flex items-center justify-center p-4 sm:p-6 lg:p-8">
<div className="max-w-md w-full bg-white rounded-xl shadow-md p-8 border border-slate-200">
<h2 className="text-2xl font-bold text-slate-900 mb-6">Send Feedback</h2>
<form onSubmit={handleSubmit} className="space-y-4">
{/* Inputs here */}
<button type="submit" className="w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 rounded-lg">
Submit
</button>
</form>
</div>
</div>
);
}
Conclusion
Combining clean REST boundaries, Prisma database queries, and a mobile-first Tailwind design pattern creates highly robust applications. Try extending this codebase by implementing search indexing or filter tags!
Written by Raj Koirala
Full Stack Developer and Software Engineer building responsive web platforms and cross-platform desktop Tauri solutions.