A RESTful API service for managing physics experiments. Built with Go (Golang), following Clean Architecture principles, and containerized with Docker.
- Language: Go 1.25
- Database: PostgreSQL
- ORM: GORM
- Router: Chi Router
- Migrations: golang-migrate
- Architecture: Clean Architecture (Repository <- Service <- Handler)
- Deployment: Docker & Docker Compose
git clone https://github.com/ali-nur31/online-physics-experiments.git
cd online-physics-experimentsCreate a .env file in the root directory. You can copy from .env.example file
🐳 Run with Docker (Recommended)
You can run the entire application (API + Database) with a single command. The migrations will be applied automatically.
# Build and start services
docker compose up --build# To stop services
docker compose downThe server will start at http://localhost:8080. 🏃 Run Locally
If you want to run Go without Docker (you still need a running Postgres database):
Ensure PostgreSQL is running.
Run migrations (using CLI or let the app handle it if configured).
Start the app:
go run ./cmd/app/main.go🔌 API Endpoints Experiments Method URL Description
GET /experiments Get all experiments
GET /experiments/{id} Get specific experiment details
GET /experiments/{category} Get experiments by category field
📂 Project Structure
The project follows the standard Go project layout and Clean Architecture:
.
├── cmd
│ └── app
│ └── main.go # Entry point, dependency injection
├── internal
│ ├── api
│ │ ├── handlers # HTTP Handlers (Controllers)
│ │ └── router.go # Router
│ ├── app
│ │ └── app.go # App initializer
│ ├── model # Database models (GORM structs)
│ ├── repository # Data Access Layer (SQL/GORM operations)
│ │ └── migrations # SQL migration files
│ └── service # Business Logic Layer
├── Dockerfile
├── docker-compose.yaml
└── go.mod