This is a multi-tenant school profile application built with Next.js 14+, Prisma, NextAuth (Credentials Provider), and Tailwind CSS. The application displays different school information based on the subdomain accessed, and provides an admin dashboard for authenticated administrators to edit their school’s details.
school1.localhost:3000
).School
and Profile
.my-multi-tenant-app/
├── app/
│ ├── [school]/
│ │ └── page.jsx // Public school profile page (read-only)
│ ├── admin/
│ │ └── page.jsx // Admin dashboard for login and school editing
│ ├── api/
│ │ ├── auth/
│ │ │ └── [...nextauth]/
│ │ │ └── route.js // NextAuth API route (admin authentication)
│ │ └── schools/
│ │ └── [id]/
│ │ └── route.js // API route for fetching/updating school data
│ └── layout.jsx // Root layout (Server Component)
├── components/
│ └── ClientProviders.jsx // Client-only provider wrapper (for NextAuth)
├── lib/
│ └── db.js // Prisma Client and helper functions
├── prisma/
│ └── schema.prisma // Prisma schema defining School and Profile models
├── styles/
│ └── globals.css // Global Tailwind CSS styles
├── next.config.js // Next.js configuration (rewrites, etc.)
├── tailwind.config.js // Tailwind CSS configuration
├── postcss.config.js // PostCSS configuration
├── package.json // Project dependencies and scripts
└── README.md // This file
git clone https://github.com/yourusername/my-multi-tenant-app.git
cd my-multi-tenant-app
npm install
npx prisma migrate dev --name init
npx prisma generate
node prisma/seed.js
npx prisma studio
"Use Studio to inspect and manage your database records."
Running the Application
Start the development server:
npm run dev
Public School Page Access the public profile by visiting a URL based on the subdomain, e.g.: http://school1.localhost:3000 for the school with subdomain school1. The public page displays the school’s name, description, and contact details in read-only mode.
Admin Dashboard Admin Login: Visit http://localhost:3000/admin and log in using your admin credentials (from the Profile table).
Edit School Data: After a successful login, the admin dashboard will display a pre-filled form with the school's details (name, description, and contact). You can update the data and click “Update School Info” to send a PUT request to the API.
Logout: The admin can also log out using the “Logout” button.