Skip to content

web app for a photographer to manage their users, galleries and photos

Notifications You must be signed in to change notification settings

nicoxeye/PhotoGallery

Repository files navigation

Photo Gallery

A web app for a photographer to make photos accesible to users online. Users can view their galleries. Admin can create Users, create Galleries for Users (only one per User) and upload photos to existing Galleries.

Dependencies

dependency version
java 17
spring framework 4.0.0
MySQL latest compatible (9.5.0)
dependency management 1.1.7
docker compose 3.8

App Preview

LOGIN PAGE: image 1 ST ACCOUNT: image image 2ND ACCOUNT: image ADMIN: image MANAGE USERS: image image MANAGE GALLERIES: image image image

Dev Log

  1. creating a docker container + docker compose yml for mysql and connecting with the database in the app
  2. making a simplified diagram how the app relationships would look like for reference
  3. creating all basic empty classes and interfaces such as: models, services, repositories, controllers and database
  4. making a data loading class to make the database have some users etc.
  5. setting up spring security that makes it available for the users in the database to log in
  6. creating APIs + testing them in POSTMAN to see how they look
  7. user: setting up the gallery page for existing users
  8. admin: creation of users + creation of galleries for existing users
  9. admin: adding photos to existing gallery
  10. adding css and fonts
  11. better documentation with features, screenshots :]

Project Set Up

Clone the project

  git clone https://github.com/nicoxeye/PhotoGallery

Change to your own passwords

  # docker-compose.yml file

  MYSQL_ROOT_PASSWORD: "EXAMPLE"
  # application.properties file
  
  spring.datasource.password=EXAMPLE

Use Docker compose

  docker compose up -d

Run the project ^^

Default data

[CHANGE spring.jpa.hibernate.ddl-auto=create-drop TO 'update' IF YOU DON'T WANT THE DATABASE TO REFRESH EACH TIME THE APP RESTARTS AND DELETE LoadData CLASS]

Login: JaneAusten
Password: 1234
Role: USER

Login: AnneRice
Password: 1234
Role: USER

Login: admin
Password: 999
Role: ADMIN

Helpful Things

for spring security:

https://www.youtube.com/watch?v=nhsdPVXhbHo

https://www.youtube.com/watch?v=RhIXP5tjHkk

for fetching data using thymeleaf:

https://www.youtube.com/watch?v=TLtksmnrSII

for photo upload:

https://www.baeldung.com/spring-boot-thymeleaf-image-upload

Project File Structure

└── src/
    ├── main/java/com/photogallery/
    │   ├── apicontroller/                       → api rest controllers, not really used anywhere, i did them to test requests in postman to see how data in json looked like for reference
    │   │   ├── GalleryController.java             
    │   │   ├── PhotoController.java               
    │   │   └── UserController.java               
    │   ├── config/                              → spring security configuration for logging in + user authentication
    │   │   └── WebSecurityConfig.java
    │   ├── controller/                          → main controller, redirects pages between each other and also sends data to thymeleaf that pages retrieve
    │   │   └── PageController.java
    │   ├── database/                            → i did a create-drop table from the start to avoid littering the database when doing testing so i decided to load some example data each time
    │   │   └── LoadData.java
    │   ├── model/                               → database entities + role enum
    │   │   ├── Gallery.java
    │   │   ├── Photo.java
    │   │   ├── Role.java
    │   │   └── User.java
    │   ├── PhotoGalleryApplication.java
    │   ├── repository/                         → model repositories extend jpa repositories that provides all the basic methods for handling data
    │   │   ├── GalleryRepository.java
    │   │   ├── PhotoRepository.java
    │   │   └── UserRepository.java
    │   └── service/                            → holds business logic, interacts with repositories with additional data checking logic
    │   │   ├── CustomUserDetailService.java
    │   │   ├── GalleryService.java
    │   │   ├── GalleryServiceImpl.java
    │   │   ├── PhotoService.java
    │   │   ├── PhotoServiceImpl.java
    │   │   ├── UserService.java
    │   │   └── UserServiceImpl.java
    └── resources/
    │       ├── application.properties
    │       ├── static/
    │       └── templates/
    │           ├── admin/                        → admin related pages, those with user role do not have access to them
    │           │   ├── admin_creategallery.html
    │           │   ├── admin_createuser.html
    │           │   ├── admin_galleries.html
    │           │   ├── admin_index.html
    │           │   └── admin_users.html
    │           ├── index.html
    │           ├── login.html
    │           └── user_gallery.html
    └── uploads/                         → photos to use while loading user photos in gallery from database, in reality would be somewhere else (on a server/disk)
        └── trees.jpg

About

web app for a photographer to manage their users, galleries and photos

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published