Skip to content

Web application built with Angular, Spring Boot, and MySQL. It features secure user authentication, blog reading, user interaction, user and post management. The application supports local and Azure deployments, and can be exported to Windows and mobile applications.

License

Notifications You must be signed in to change notification settings

56duong/angular-springboot-blog-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BLOG WEB APPLICATION

The application allows users to read blog posts, login or signup to like a post, and for staff/admin to manage posts and users. If you have a passion for writing and sharing your thoughts, this app is for you.

While the code may not be perfect and may still contain bugs, the goal is to provide a practical, hands-on experience in building a real-world application. Your feedback and contributions are always welcome.

Table of Contents

  1. Demo
  2. Features
  3. Tech Stack Versions
  4. YouTube Series
  5. File Tree
  6. Configuration
  7. Getting Started
  8. Build and Deployment
  9. Who i am?
  10. License
  11. Contact

πŸŽ₯ Demo

PostShare

🌟 Features

  • User Authentication: Secure authentication using JWT tokens for user login and signup.

  • Blog Reading: Users can read blog posts and view details about each post.

  • Interaction: Users can like posts to engage with the content.

  • User Management: Staff/Admin can manage user accounts, including adding, updating users.

  • Post Management: Staff/Admin members can create, edit, or delete blog posts.

πŸ“Œ Tech Stack Versions

Please note that the versions listed below are the ones used during the development of this application. The application may work with other versions as well, but these are the ones that have been tested and confirmed to work.

  • Java: 17

  • Spring Boot: 3.2.5

  • JWT: 0.11.5

  • MySQL: 8.0

  • Angular CLI: 16.2.10

  • Node.js: 18.20.2

  • npm: 10.5.0

  • PrimeNG: 17.15.0

  • Electron: 30.0.2

  • Capacitor: 6.0.0

πŸŽ₯ YouTube Series

This project is part of my YouTube series, where I document the development process and share insights on building real-world applications. You can follow along with the series to view more about the application's architecture, implementation details, and best practices.

πŸ“ File Tree

PostShare
β”œβ”€β”€β”€backend
β”‚   β”œβ”€β”€β”€src
β”‚   β”‚   └───main
β”‚   β”‚       β”œβ”€β”€β”€java
β”‚   β”‚       β”‚   └───org
β”‚   β”‚       β”‚       └───duong
β”‚   β”‚       β”‚           └───backend
β”‚   β”‚       β”‚               β”œβ”€β”€β”€config
β”‚   β”‚       β”‚               β”œβ”€β”€β”€controller
β”‚   β”‚       β”‚               β”œβ”€β”€β”€dto
β”‚   β”‚       β”‚               β”œβ”€β”€β”€enums
β”‚   β”‚       β”‚               β”œβ”€β”€β”€exception
β”‚   β”‚       β”‚               β”œβ”€β”€β”€filter
β”‚   β”‚       β”‚               β”œβ”€β”€β”€model
β”‚   β”‚       β”‚               β”œβ”€β”€β”€repository
β”‚   β”‚       β”‚               └───service
β”‚   β”‚       └───resources
β”‚   β”‚           β”œβ”€β”€β”€static
β”‚   β”‚           └───templates
β”‚   β”‚           └───application.properties
β”‚   └───target
β”‚       β”œβ”€β”€β”€backend-0.0.1-SNAPSHOT.jar
β”‚       β”œβ”€β”€β”€...
β”œβ”€β”€β”€frontend
β”‚   β”œβ”€β”€β”€android
β”‚   β”‚   β”œβ”€β”€β”€app
β”‚   β”‚   β”œβ”€β”€β”€release
β”‚   β”‚   β”‚   β”œβ”€β”€β”€app-release.apk
β”‚   β”‚   β”‚   β”œβ”€β”€β”€...
β”‚   β”‚   └───...
β”‚   β”œβ”€β”€β”€dist
β”‚   β”‚   └───frontend
β”‚   β”œβ”€β”€β”€PostShare-win32-x64
β”‚   β”‚   β”œβ”€β”€β”€PostShare.exe
β”‚   β”‚   └───...
β”‚   └───src
β”‚       β”œβ”€β”€β”€app
β”‚       β”‚   β”œβ”€β”€β”€core
β”‚       β”‚   β”‚   β”œβ”€β”€β”€config
β”‚       β”‚   β”‚   β”œβ”€β”€β”€guard
β”‚       β”‚   β”‚   β”œβ”€β”€β”€interceptor
β”‚       β”‚   β”‚   β”œβ”€β”€β”€interface
β”‚       β”‚   β”‚   β”œβ”€β”€β”€pipe
β”‚       β”‚   β”‚   └───service
β”‚       β”‚   β”œβ”€β”€β”€shared
β”‚       β”‚   β”‚   └───component
β”‚       β”‚   β”‚       β”œβ”€β”€β”€like-button
β”‚       β”‚   β”‚       β”œβ”€β”€β”€login
β”‚       β”‚   β”‚       β”œβ”€β”€β”€not-found
β”‚       β”‚   β”‚       β”œβ”€β”€β”€post
β”‚       β”‚   β”‚       β”œβ”€β”€β”€post-details
β”‚       β”‚   β”‚       └───signup
β”‚       β”‚   β”œβ”€β”€β”€staff
β”‚       β”‚   β”‚   └───component
β”‚       β”‚   β”‚       β”œβ”€β”€β”€feed
β”‚       β”‚   β”‚       └───user-management
β”‚       β”‚   └───user
β”‚       β”‚       └───component
β”‚       β”‚           └───feed
β”‚       └───assets
β”œβ”€β”€β”€installer
β”‚       β”œβ”€β”€β”€postshare-1.0.2.exe
β”‚       └───scripts.iss
└───tsv

βš™οΈ Configuration

The application can be configured by modifying the application.properties file and the config.ts file in your JavaScript project. Here are some of the configurations you might need to change:

  • Database Connection: Update the spring.datasource.url, spring.datasource.username, and spring.datasource.password properties in the application.properties file to match your own database connection details. You can choose to connect to a local database or an Azure database.

    #localhost
    spring.datasource.url=jdbc:mysql://your-localhost-database-url:3306/your-database-name?createDatabaseIfNotExist=true
    spring.datasource.username=your-localhost-username
    spring.datasource.password=your-localhost-password
    
    #azure
    spring.datasource.url=jdbc:mysql://your-azure-database-url:3306/your-database-name?useSSL=true
    spring.datasource.username=your-azure-username
    spring.datasource.password=your-azure-password
  • API URL: In your config.ts file, change the API URL to your own API URL as follows:

    // localhost
    export const API_URL = 'http://your-localhost-api-url';
    
    // azure
    export const API_URL = 'https://your-azure-api-url';

πŸš€ Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

  1. Clone the repository: git clone https://github.com/56duong/angular-springboot-blog-webapp.git

  2. Navigate to the project directory: cd angular-springboot-blog-webapp

Database

  1. Run the Project: Ensure your project is running to allow DDL auto to create the necessary tables in your database.

  2. Import TSV Data:

    • In IntelliJ IDEA's Database tool, find the role table, right-click, and choose "Import Data From File".

    • Select the TSV file containing role data, map columns, and confirm import.

    • Note: Import data for the role table before proceeding to the user table.

    • After importing data for the role table, find the user table, right-click, and select "Import Data From File".

    • Choose the TSV file containing user data, map columns, and confirm import.

Backend

  1. Navigate to the backend directory: cd backend

  2. Install dependencies: mvn install

  3. Run the application: mvn spring-boot:run

Frontend

  1. Navigate to the frontend directory: cd frontend

  2. Install dependencies: npm install

  3. Run the application: npm start

πŸ”§ Build and Deployment

1. Deploy MySQL Database to Azure: Watch my video for setup.

2. Angular Build and Copy Files to resources/static:

  • Use the Angular CLI to build your project with the command ng build.

  • Then, copy the output files to the resources/static directory in your Spring Boot project.

3. Docker Build and Push to Docker Hub: Use Docker to build an image of your application and then push it to Docker Hub.

docker build -t your-dockerhub-username/your-image-name .

docker push your-dockerhub-username/your-image-name

4. Deploy Container to Azure: Watch my video for setup.

5. Mobile App Export: Use Capacitor to prepare your app for mobile app.

  • First, ensure that your capacitor.config.json file is properly configured. If not, delete it and create a new one using npx cap init.

  • Next, install the necessary Capacitor packages:

     # For Android 
     npm i @capacitor/android
    
     # For iOS 
     npm i @capacitor/ios
  • Then, add Android and iOS as platforms to your Capacitor project:

     # For Android 
     npx cap add android
    
     # For iOS 
     npx cap add ios
  • Sync your project:

     npx cap sync
  • Finally, open your project in Android Studio and Xcode to generate the APK and IPA files respectively:

     # For Android 
     npx cap open android
    
     # For iOS 
     npx cap open ios
  • In Android Studio, use the "Generate Signed Bundle / APK" option in the "Build" menu to export your Android app. In Xcode, use the "Product" -> "Archive" option to export your iOS app.

  • Note: When you run the npx cap sync command, Capacitor copies the built web assets (the output of your npm run build command) into each platform's native project. For Android, these assets are copied to android/app/src/main/assets/public. For iOS, they are copied to ios/App/App/public. This ensures that the latest version of your web app is included in the native project each time you build it.

6. Windows App Export:

  • Build your Electron app:

    npm run electron-build
  • Package your app with Electron Packager: This will generate a folder named PostShare-win32-x64 in the project root directory, which contains the Windows executable (.exe) file.

    electron-packager ./ PostShare --platform=win32

    Please replace the PostShare with your actual app name if it's different.

  • Delete all folders inside PostShare-win32-x64/resources/app except for the dist folder. Note: Only delete folders, do not delete any files.

  • Use Inno Setup to create an installer for your app. Watch my video for setup.

πŸ‘‹ Who i am?

A young developer, who dedicated to developing usable apps, not just 'homework apps'.

I delight in sharing my knowledge and experiences, hoping to inspire others to embark on their own journey in application development. Also, I have a fondness for sour soup πŸ₯£.

βš–οΈ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“¨ Contact

If you want to contact me you can reach me at 56duong@gmail.com. If you'd like to contribute, please fork the repository and use a pull request for changes.

About

Web application built with Angular, Spring Boot, and MySQL. It features secure user authentication, blog reading, user interaction, user and post management. The application supports local and Azure deployments, and can be exported to Windows and mobile applications.

Topics

Resources

License

Stars

Watchers

Forks