# Packages
# 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:
-
Auth Service (Port: 8080)
- Handles user registration, login, and token management
- Connected to Auth Database (Port: 5433)
-
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
-
Clone the repository:
git clone https://github.com/samims/blog-services.git cd blog-services
-
Start all services
docker-compose up -d
- Stop all services
docker-compose down
๐ก API Endpoints
Auth Service
POST /api/auth/register
- Register a new userPOST /api/auth/login
- User loginGET /api/auth/verify
- Verify JWT token
Blog Service
GET /api/posts
- Get all postsPOST /api/posts
- Create a new postGET /api/posts/{id}
- Get a specific postPUT /api/posts/{id}
- Update a postDELETE /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:
-
Auth Service (Port: 8080)
- Handles user registration, login, and token management
- Connected to Auth Database (Port: 5433)
-
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
-
Clone the repository:
git clone https://github.com/yourusername/blog-backend.git cd blog-backend
-
Start all services
docker-compose up -d
- Stop all services
docker-compose down
๐ก API Endpoints
Auth Service
POST /api/auth/register
- Register a new userPOST /api/auth/login
- User loginGET /api/auth/verify
- Verify JWT token
Blog Service
GET /api/posts
- Get all postsPOST /api/posts
- Create a new postGET /api/posts/{id}
- Get a specific postPUT /api/posts/{id}
- Update a postDELETE /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
- Ensure all environment variables are properly set
- Build and push Docker images to your container registry
- 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