Skip to content

emmrys-jay/photo-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

my-photo-blog

A Photo Blog which you can seamlessly deploy locally

Project Description

This a photo blog which allows a user to login and add pictures via a profile. The server path of each picture is saved to the postgres database along with the picture's title, description and username of its author. Picture paths are queried from the database and used to get the served pictures on the server.

How to Set Up this Project Locally

...with docker

  • Ensure docker and docker-compose is installed. Run this command to confirm its installation:
docker -v
docker-compose -v
  • Clone this project from git repository using
git clone https://github.com/Emmrys-Jay/photo-blog.git
  • Run this command in project directory
docker-compose up --build

...without docker

  • Ensure postgresql is installed. Run this command to confirm its installation:
psql --version

If Installed, output should be in this form:

psql (PostgreSQL) 14.2 (Ubuntu 14.2-1.pgdg20.04+1)

If Postgres is installed, ensure postgres service is running using:

systemctl status postgresql

If running, output should be:

postgresql.service - PostgreSQL RDBMS
 Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
 Active: active (exited) since Sun 2022-09-25 10:02:43 WAT; 23min ago
Process: 1072 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1072 (code=exited, status=0/SUCCESS)

Else, run the following command to start service:

systemctl enable postgresql
systemctl start postgresql

NB: You may need root privileges to run some commands above. Add sudo before the command if needed.

  • Create a load.env file in projects root directory and copy the following lines into it:
POSTGRES_PASSWORD=password
POSTGRES_USER=postgres
POSTGRES_DB=photoblog
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
  • Run code using go run main.go or go build

Features

  • User Signup
  • User Login
  • Stateful connection using cookies after user sign in
  • Add a picture at a time with a title and description
  • View all pictures on a general home-page
  • Save pictures on the server
  • Picture path on the server saved to a postgresql database
  • Token authentication with JWT
  • Search database with regular expressions
  • Create, Read, update and delete (CRUD) pictures from database
  • Password base64-encoded before transit to database

Home Page

home-page

Pictures on Home Page

pictures

Search Result Page

search

Sign In Page

sign in

Sign Up Page

sign up

Add Picture Page

add pictures

Backend Features

  • Created HTTP server using net/http package
  • Validate request method
  • Authentication system using JWT
  • Error handling
  • CRUD operations
  • Read database with regex
  • Database server running on Amazon RDS

Home Page Background Photo by Philippe Donn

HTML, CSS and Javascript used for this project was gotten from bootstrapmade.com

NB: Instruction on setting up an Amazon RDS instance can be found here