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.
- 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
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 grafanaon the root level of project run this command:
go install github.com/swaggo/swag/cmd/swag@lateston the root level of project run this command:
go mod downloadcd to cmd directory:
cd src/cmdand then run:
go run main.goWeb API run on http://localhost:10000
Swagger on http://localhost:10000/swagger/index.html#/
Token Url: http://localhost:10000/api/v1/users/login-by-username
Username: admin
Password: 12345678Kibana on http://localhost:5680
Username: elastic
Password: changemePrometheus on http://localhost:30090
Grafana on http://localhost:3000
Username: admin
Password: foobarPgAdmin on http://localhost:8888
Username: amirhossinhp10@gmail.com
Password: adminHost: postgres_container
Port: 5432
Username: postgres
Password: admindocker compose -f "docker/docker-compose.yaml" down



