Categorygithub.com/samims/blog-services
repository
0.0.0-20241203124345-d825467226c5
Repository: https://github.com/samims/blog-services.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Blog Backend Microservices

A robust, scalable backend system for a blogging platform, built with Go and following microservices architecture.

๐Ÿš€ Features

  • User authentication and authorization
  • Blog post CRUD operations
  • Scalable microservices architecture
  • PostgreSQL database integration
  • Docker containerization

๐Ÿ›  Tech Stack

  • Go 1.23+
  • PostgreSQL
  • Docker & Docker Compose
  • JWT for authentication
  • Golang Migrate for database migrations

๐Ÿ— Architecture

The system consists of two main microservices:

  1. Auth Service (Port: 8080)

    • Handles user registration, login, and token management
    • Connected to Auth Database (Port: 5433)
  2. Blog Service (Port: 8082)

    • Manages blog post operations (create, read, update, delete)
    • Connected to Blog Database (Port: 5434)

๐Ÿšฆ Getting Started

Prerequisites

  • Docker
  • Docker Compose
  • Go 1.23+

Running the Application

  1. Clone the repository:

    git clone https://github.com/samims/blog-services.git cd blog-services
    
  2. Start all services

docker-compose up -d
  1. Stop all services
docker-compose down

๐Ÿ“ก API Endpoints

Auth Service

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - User login
  • GET /api/auth/verify - Verify JWT token

Blog Service

  • GET /api/posts - Get all posts
  • POST /api/posts - Create a new post
  • GET /api/posts/{id} - Get a specific post
  • PUT /api/posts/{id} - Update a post
  • DELETE /api/posts/{id} - Delete a post

๐Ÿงช Running Tests

To run tests for each service:

Blog Backend Microservices

A robust, scalable backend system for a blogging platform, built with Go and following microservices architecture.

๐Ÿš€ Features

  • User authentication and authorization
  • Blog post CRUD operations
  • Scalable microservices architecture
  • PostgreSQL database integration
  • Docker containerization

๐Ÿ›  Tech Stack

  • Go 1.23+
  • PostgreSQL
  • Docker & Docker Compose
  • JWT for authentication
  • Golang Migrate for database migrations

๐Ÿ— Architecture

The system consists of two main microservices:

  1. Auth Service (Port: 8080)

    • Handles user registration, login, and token management
    • Connected to Auth Database (Port: 5433)
  2. Blog Service (Port: 8082)

    • Manages blog post operations (create, read, update, delete)
    • Connected to Blog Database (Port: 5434)

๐Ÿšฆ Getting Started

Prerequisites

  • Docker
  • Docker Compose
  • Go 1.23+

Running the Application

  1. Clone the repository:

    git clone https://github.com/yourusername/blog-backend.git cd blog-backend
    
  2. Start all services

docker-compose up -d
  1. Stop all services
docker-compose down

๐Ÿ“ก API Endpoints

Auth Service

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - User login
  • GET /api/auth/verify - Verify JWT token

Blog Service

  • GET /api/posts - Get all posts
  • POST /api/posts - Create a new post
  • GET /api/posts/{id} - Get a specific post
  • PUT /api/posts/{id} - Update a post
  • DELETE /api/posts/{id} - Delete a post

๐Ÿงช Running Tests

To run tests for each service:

cd auth-service
go test ./...

cd ../blog-service
go test ./...

Useful Docker Commands

# View logs
docker-compose logs

# View specific service logs
docker-compose logs auth-service
docker-compose logs blog-service

# Rebuild services
docker-compose build

# Rebuild and start specific service
docker-compose up --build auth-service

# Check status
docker-compose ps

๐Ÿ“Š Monitoring and Logging

Logs are available through Docker Compose logs Consider integrating Prometheus and Grafana for advanced monitoring

๐Ÿ”’ Security Considerations

All endpoints are secured with JWT authentication Passwords are hashed before storage HTTPS is recommended for production deployments

๐Ÿš€ Deployment

  1. Ensure all environment variables are properly set
  2. Build and push Docker images to your container registry
  3. Deploy using Docker Compose or Kubernetes (sample manifests will be provided later in /k8s)

๐Ÿ”„ Continuous Integration / Continuous Deployment

GitHub Actions workflows are provided in .github/workflows Automated testing and building on push to main branch Automated deployment to staging environment on successful build

๐Ÿ”„ Continuous Integration / Continuous Deployment

GitHub Actions workflows are provided in .github/workflows Automated testing and building on push to main branch Automated deployment to staging environment on successful build

๐Ÿ“ฌ Contact

Project Link: https://github.com/samims/blog-services