Skip to content

Abhinav7903/SalonBackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salon SaaS

A full-stack salon management application with a Go backend and React frontend.

Tech Stack

Backend

  • Language: Go 1.24
  • Framework: Gorilla Mux
  • Database: PostgreSQL
  • Configuration: Viper
  • Logging: Slog

Frontend

  • Framework: React 19
  • Build Tool: Vite
  • Styling: Tailwind CSS
  • Icons: Lucide React
  • Charts: Recharts
  • Routing: React Router DOM

Project Structure

salon-saas/
├── cmd/
│   └── server/
│       └── main.go              # Application entry point
├── internal/
│   ├── analytics/               # Analytics service and handlers
│   ├── auth/                    # JWT authentication
│   ├── db/                      # Database connection
│   ├── handler/                 # HTTP handlers and routing
│   ├── middleware/             # Auth and RBAC middleware
│   ├── models/                  # Database models
│   ├── repository/             # Data access layer
│   └── service/                # Business logic
├── migrations/                 # SQL schema migrations
├── web/                        # React frontend
│   ├── src/
│   │   ├── api/                # API client
│   │   ├── components/         # Reusable UI components
│   │   ├── context/            # React context (Auth)
│   │   ├── pages/              # Page components
│   │   ├── App.jsx             # Main app component
│   │   └── main.jsx            # React entry point
│   ├── package.json
│   └── vite.config.js
└── config.yaml                 # Application configuration

Database Schema

Tables

  • salons: Multi-tenant salon records
  • admins: Staff accounts with roles (owner, manager, staff)
  • customers: Client information
  • services: Salon services offered
  • payments: Payment/invoice records
  • payment_items: Line items for payments
  • appointments: Booking records
  • shifts: Staff working schedules
  • products: Inventory products

Key Features

  • Soft deletes on all tables
  • Automatic updated_at timestamps
  • UUID primary keys
  • Multi-tenant isolation by salon_id

API Endpoints

Public

Method Endpoint Description
POST /login Admin login
POST /register Register new salon
GET /health Health check

Protected (requires JWT)

All protected routes are prefixed with /api and require authentication.

Admins

Method Endpoint Description Roles
GET /api/admins List all admins owner
POST /api/admins Create admin owner
GET /api/admins/{id} Get admin owner
PUT /api/admins/{id} Update admin owner
DELETE /api/admins/{id} Delete admin owner

Services

Method Endpoint Description Roles
GET /api/services List services all
POST /api/services Create service owner, manager
GET /api/services/{id} Get service all
PUT /api/services/{id} Update service owner, manager
DELETE /api/services/{id} Delete service owner, manager

Customers

Method Endpoint Description Roles
GET /api/customers List customers all
POST /api/customers Create customer owner, manager
GET /api/customers/{id} Get customer all
PUT /api/customers/{id} Update customer owner, manager
DELETE /api/customers/{id} Delete customer owner, manager

Products

Method Endpoint Description Roles
GET /api/products List products all
POST /api/products Create product owner, manager
GET /api/products/{id} Get product all
PUT /api/products/{id} Update product owner, manager
DELETE /api/products/{id} Delete product owner, manager

Appointments

Method Endpoint Description Roles
GET /api/appointments List appointments all
POST /api/appointments Create appointment owner, manager
PUT /api/appointments/{id}/status Update status owner, manager

Shifts

Method Endpoint Description Roles
GET /api/admins/{id}/shifts List shifts owner, manager
PUT /api/admins/{id}/shifts Update shifts owner, manager

Analytics

Method Endpoint Description
GET /api/analytics/daily Daily summary
GET /api/analytics/range Date range analytics
GET /api/analytics/payment-methods Payment method breakdown
GET /api/analytics/top-services Most popular services
GET /api/analytics/staff-performance Staff performance metrics
GET /api/analytics/revenue-trend Revenue trends

Checkout & Invoices

Method Endpoint Description Roles
POST /api/checkout Process payment all
GET /api/invoices/{invoice_number} Get invoice all

Salon

Method Endpoint Description
GET /api/salons/me Get current salon

Getting Started

Prerequisites

  • Go 1.24+
  • Node.js 18+
  • PostgreSQL 14+

Backend Setup

  1. Configure the database in config.yaml:
db:
  host: localhost
  port: 5432
  user: your_user
  password: your_password
  name: salon
  sslmode: disable
  1. Run database migrations:
psql -U your_user -d salon -f migrations/20260226212258_001.up.sql
psql -U your_user -d salon -f migrations/20260227183056_002.up.sql
psql -U your_user -d salon -f migrations/20260227200329_003.up.sql
psql -U your_user -d salon -f migrations/20260406120000_004.up.sql
  1. Start the backend server:
go run cmd/server/main.go

The server runs on port 8080 by default.

Frontend Setup

  1. Navigate to the web directory:
cd web
  1. Install dependencies:
npm install
  1. Create a .env.local file:
VITE_API_BASE=http://localhost:8080
  1. Start the development server:
npm run dev

The frontend runs on port 5173 by default.

Build

Backend

go build -o server cmd/server/main.go

Frontend

cd web
npm run build

Authentication

The system uses JWT tokens for authentication. Upon login, a token is returned that must be included in the Authorization header:

Authorization: Bearer <token>

Roles

  • owner: Full access to all features
  • manager: Can manage staff, services, customers, appointments
  • staff: Read-only access to most data, can process checkout

Development

Running Tests

Backend:

go test ./...

Frontend:

cd web
npm run lint

Code Structure Conventions

  • Handlers: HTTP entry points, request parsing, response formatting
  • Services: Domain logic and orchestration
  • Repositories: Data access layer (SQL queries)
  • Models: Database schema and API types
  • Middleware: Auth and RBAC logic

Context Helpers

Use helpers in internal/middleware/auth_middleware.go to get context values:

  • GetAdminID(r.Context())
  • GetSalonID(r.Context())
  • GetRole(r.Context())

License

MIT

About

A full-stack salon management application with a Go backend and React frontend.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors