This is a fullstack web application built using Spring Boot for the backend and Next.js for the frontend. It includes features such as user authentication, data management, and REST API integration.
- Technologies
- Features
- Project Structure
- Getting Started
- API Documentation
- Environment Variables
- Deployment
- License
- Backend: Spring Boot, Java
- Frontend: Next.js, React
- Database: PostgreSQL (or MySQL, MongoDB, etc.)
- Authentication: JWT (JSON Web Token)
- Docker: For containerization of the application
- Other: REST API, Axios (for API calls), Tailwind CSS (for styling)
- User authentication (sign up, login, JWT-based authentication)
- Role-based access control
- CRUD operations on resources
- Real-time data with WebSockets (if applicable)
- Dockerized setup for easier development and deployment
- Responsive UI with Next.js and Tailwind CSS
.
├── backend # Spring Boot backend
│ ├── src/main # Java source code
│ ├── src/resources # Application configurations
│ └── pom.xml # Maven dependencies
├── frontend # Next.js frontend
│ ├── pages # Next.js pages (routes)
│ ├── components # React components
│ ├── public # Static assets
│ ├── styles # Tailwind CSS styles
│ └── package.json # Node.js dependencies
├── docker-compose.yml # Docker Compose file
└── README.md # Project documentation
Prerequisites
- Java 17+
- Node.js 16+
- Docker
Running the Application Locally Clone the repository:
git clone https://github.com/your-repo/fullstack-app.git
cd fullstack-app
Backend (Spring Boot):
cd backend
./mvnw clean install
Run the Spring Boot application:
./mvnw spring-boot:run
The backend server will start at http://localhost:8080.
Frontend (Next.js):
Navigate to the frontend folder:
cd ../frontend
npm install
Run the Next.js development server:
npm run dev
The frontend server will start at http://localhost:3000.
Run with Docker Compose:
Alternatively, you can run both the backend and frontend using Docker Compose:
docker-compose up
This will start both the Spring Boot backend and Next.js frontend in containers.
The backend REST APIs can be accessed at http://localhost:8081/api.
Example Endpoints:
POST /api/auth/login: User login
GET /api/users: Get all users (admin only)
POST /api/products: Create a new product
For detailed API documentation, you can access Swagger at http://localhost:8080/swagger-ui.html.
Create a .env file in both the backend and frontend directories to set the following environment variables:
Backend
# backend/.env
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/mydb
SPRING_DATASOURCE_USERNAME=your_db_username
SPRING_DATASOURCE_PASSWORD=your_db_password
JWT_SECRET=your_jwt_secret_key
Frontend
# frontend/.env.local
NEXT_PUBLIC_API_URL=http://localhost:8080/api
Using Docker You can deploy the application using Docker. Ensure you have the environment variables set up in a .env file or pass them directly in the Docker Compose configuration.
Build the Docker images:
docker-compose build
Run the containers:
docker-compose up -d
Traditional Deployment For deploying the Spring Boot backend and Next.js frontend separately, you can:
Package the Spring Boot application into a JAR file:
./mvnw clean package
Deploy the target/*.jar file to your preferred cloud provider (e.g., AWS, Heroku, etc.).
For Next.js, you can build the static files using:
npm run build
npm start
Serve the Next.js app using Vercel, Netlify, or any static hosting provider.
This project is licensed under the MIT License. See the LICENSE file for details.