Skip to content

joybiswas007/blog

Repository files navigation

Blog

A personal blog built with Go (backend) & React (frontend).


Getting Started

Follow these steps to set up the project for development or production.


1. Database Setup

  1. Install PostgreSQL

  2. Create a Database

  3. Run Migrations
    Install migrate and apply migrations:

    migrate -path=./migrations -database="postgres://bloguser:yourpassword@localhost:5432/blogdb?sslmode=disable" up

    To roll back migrations:

    migrate -path=./migrations -database="postgres://bloguser:yourpassword@localhost:5432/blogdb?sslmode=disable" down

Redis

Make sure redis is already installed and setuped as we're using redis for cacheing.


2. Installation

You can run the blog with Docker or manually.

Docker

  1. Prepare Environment Variables:
    • Copy env.example to .env inside the web directory and configure as needed:
      cp web/env.example web/.env
      # Edit web/.env to match your environment
  2. Build and Start:
    make build-docker
  3. Rebuild (if needed):
    make re-build-docker 
  4. Stop:
    make down-docker

Manual

Frontend

  1. Install Node.js and npm.
  2. In the web directory:
    cd web
    npm install
    cp env.example .env
    # Edit .env as needed
  3. Start development server:
    npm run dev
  4. Build for production:
    npm run build

Backend

  1. Install Go 1.24+ and ensure it is in your PATH.
  2. Copy and edit config:
    cp example.blog.yaml .blog.yaml
  3. Build:
    make build
  4. Run:
    ./blog --conf .blog.yaml
  5. Build CLI tool:
    make build-cli
  6. Manage users:
    ./blog_cli --help
    ./blog_cli --name 'Your Name' --email [email protected] --pass "Pass"
    ./blog_cli --email [email protected] --pass "newPass"
    • If no password is provided, a secure password is generated.

Makefile

View available commands:

make help
  • If you change BINARY_NAME or CLI_BINARY_NAME in the Makefile, update the binary names accordingly.

Notes

  • PostgreSQL and migrations must be set up before running the backend or Docker container.
  • The frontend only supports login; registration must be done via the CLI.

Contributing

Contributions are welcome. Open issues or submit pull requests.


License

MIT License.