This project is a basic Content Management System (CMS) application developed as a REST API using Spring Boot. The API allows users to perform CRUD (Create, Read, Update, Delete) operations on articles and manage images associated with those articles. It also includes JWT user authentication.
A Docker image of the application is also available on Docker Hub, making it easy to deploy the application in a containerized environment.
- Login: Admin users can log in with a username and password.
- Guest Access: Guests can browse articles without logging in.
- Create Article: Admin can create a new article and upload an associated image.
- Read Articles: Both admins and guests can view a list of articles, read individual articles, and view associated images.
- Update Article: Admin can edit existing articles and update images.
- Delete Article: Admin can delete articles and their associated images.
- Upload Image: Admins can upload images to be associated with articles.
- View Image: Both admins and guests can view images along with articles.
- Admin: Can create, read, update, and delete articles, and upload images.
- Guest: Can only read articles and view images.
- POST /api/auth/login
- Description: Admin user login.
- Request Body:
{ "username": "admin", "password": "password" } - Response: Authentication token.
- POST /api/aritles
- Description: Create a new article.
- Request Body:
{ "title": "Article Title", "content": "Article content", "image": "image_path" } - Role: Admin.
- GET /api/articles
- Description: Retrieve a list of all articles.
- Response: List of articles.
- Role: Admin, Guest.
- GET /api/articles/{id}
- Description: Retrieve a single article by ID.
- Response: Article details.
- Role: Admin, Guest.
- PUT /api/articles/{id}
- Description: Update an existing article.
- Request Body:
{ "title": "Updated Title", "content": "Updated content", "image": "new_image_path" } - Role: Admin.
- DELETE /api/articles/{id}
- Description: Delete an article by ID.
- Role: Admin.
- POST /api/images
- Description: Upload an image.
- Request Body:
{ "image": "image_path" } - Role: Admin.
- GET /api/images/{id}
- Description: Retrieve an image by ID.
- Response: Image data.
- Role: Admin, Guest.
- Ensure you have
Java 21andMavenInstalled - Ensure you have a MySQL server running. You can use XAMPP to start a MySQL server locally.
- Docker installed for running the application via Docker
- Download and install XAMPP
- Start MySQL server:
- Open the XAMPP Control Panel
- Clicke the "Start" button next to Apache.
- Click the "Start" button next to MySQL to start the MySQL server.
- Create a new database:
- Open
phpMyAdmin(accessible from the XAMPP Control Panel). - Create a database named cms_db
- Open
- Clone the repository:
git clone https://github.com/dkalaitz/cms-api-cloud-native-deloitte.git - Open the project in your preferred IDE
- Build and run the application:
- In your IDE, locate the main application file, typically named
CmsApiApplication.java, and run it as a Java application.
- In your IDE, locate the main application file, typically named
- The API will be available at http://localhost:8080/
- Pull the Docker image:
docker pull dkalaitz/cms-api:latest - Navigate to the project's directory and run:
docker-compose up - The API will be available at http://localhost:8080/
To access the Swagger UI for API documentation and testing, navigate to (while running the application):
http://localhost:8080/swagger-ui/index.html#/
The Docker image for this application is available on Docker Hub:
- Image URL:
https://hub.docker.com/repository/docker/dkalaitz/cms-api/general