Skip to content

amirhasanpour/bama-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Car Sales Management Web API (Inspired by bama.ir)

A scalable, observable, and modular RESTful API for managing a car sales platform. Built with Go using the Gin framework, the architecture follows clean coding practices and is containerized using Docker Compose.


System Design Diagram

System Design Diagram


Features and Tools

  • JWT-based authentication and authorization for securing protected routes
  • Car sales management including creating, updating, deleting, and browsing listings
  • Clean architecture using Gin framework (router → handler → service → contracts → infra)
  • Input validation using validator for secure and strict endpoint validation
  • Environment and configuration management via viper with support for .env and YAML
  • PostgreSQL as the main relational database engine
  • PgAdmin as a visual tool for inspecting and managing the PostgreSQL database
  • GORM as the ORM layer for interacting with PostgreSQL using models and struct-based queries
  • Docker Compose for orchestrating all services like DB, Redis, Elasticsearch, Prometheus, and more
  • Redis caching to reduce database load and enhance performance for hot data
  • Prometheus for real-time metrics collection and monitoring
  • Grafana dashboards for visualizing performance and system metrics
  • Centralized logging pipeline using Elasticsearch, Filebeat, and Kibana
  • Structured logging using both zap and zerolog for performant, JSON-formatted logs
  • Auto-generated API documentation with Swagger UI for easy testing and development

How to run?

1- Start Dependencies on Docker

cd to the docker directory and run this command:

docker compose -f "docker/docker-compose.yaml" up -d setup elasticsearch kibana filebeat postgres pgadmin redis prometheus node-exporter alertmanager grafana

2- Install Swagger CLI

on the root level of project run this command:

go install github.com/swaggo/swag/cmd/swag@latest

3- Install Go Dependencies

on the root level of project run this command:

go mod download

4- Run the Application

cd to cmd directory:

cd src/cmd

and then run:

go run main.go

5- Visit the Application

Web API run on http://localhost:10000

Token Url: http://localhost:10000/api/v1/users/login-by-username
Username: admin
Password: 12345678
Username: elastic
Password: changeme
Username: admin
Password: foobar
Username: amirhossinhp10@gmail.com
Password: admin

Postgres Server info:

Host: postgres_container
Port: 5432
Username: postgres
Password: admin

6- Stop all Services

docker compose -f "docker/docker-compose.yaml" down

Project preview

Swagger

swagger preview

Kibana

kibana preview

Grafana

grafana preview

PgAdmin

pgadmin preview

About

Scalable, observable, and Dockerized RESTful API for a car sales management platform, built with Go (Gin), PostgreSQL, Redis, and integrated with Prometheus, Grafana, and ELK for monitoring and logging.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors