Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

⚛️ Online Physics Experiments API

A RESTful API service for managing physics experiments. Built with Go (Golang), following Clean Architecture principles, and containerized with Docker.

🚀 Tech Stack

  • Language: Go 1.25
  • Database: PostgreSQL
  • ORM: GORM
  • Router: Chi Router
  • Migrations: golang-migrate
  • Architecture: Clean Architecture (Repository <- Service <- Handler)
  • Deployment: Docker & Docker Compose

🛠️ Getting Started

1. Clone the repository

git clone https://github.com/ali-nur31/online-physics-experiments.git
cd online-physics-experiments

2. Environment Variables

Create 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 down

The 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

Contributors

Languages