A Photo Blog which you can seamlessly deploy locally
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.
- 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
- 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
orgo build
- 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
- 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