This is the source code of my gallery website on https://gallery.basarsubasi.com.tr
You are very welcome to fork it and make it yours as well!
gallery/
├── backend/ # Express.js API server (Node.js + TypeScript)
│ └── Dockerfile
│
├── frontend/ # Public gallery interface (React.js + TypeScript)
│ └── Dockerfile
│
│
│
├── interface/ # Admin interface for photo management (React.js + TypeScript)
│ └─ Dockerfile
│
│
├── traefik/ # Reverse proxy configuration
│ └── docker-compose.yaml.example
│
├── docker-compose.yaml.example # Main Docker Compose configuration
└── .env.example # Environment variables template
- Homepage: Main gallery landing page
- Color Photos: Display color photographs
- Black & White Photos: Display black and white photographs
- Single Image Page: Detailed view of individual photos
- Responsive Grid Layout: Photo grid display
- Authentication: JWT-based login system
- Photo Upload: Add new photos with metadata
- Photo Management: Edit and delete existing photos
- Backend: Node.js , Express.js, TypeScript
- Frontend: React.js, Vite, TypeScript
- Database: MariaDB
- Authentication: JWT (JSON Web Tokens)
- Containerization: Docker & Docker Compose
- Reverse Proxy: Traefik (optional)
- Docker and Docker Compose installed
- Git for cloning the repository
git clone https://github.com/basarsubasi/gallery.git
cd galleryCopy the example environment file and configure your settings:
cp .env.example .envEdit .env with your preferred values
Copy the Docker Compose example file:
cp docker-compose.yaml.example docker-compose.yaml- Build & Deploy the Gallery Services:
docker-compose up -d --build- Deploy Traefik:
cd traefik
cp docker-compose.yaml.example docker-compose.yaml
docker-compose up -dAccess the services:
- Public Gallery:
http://gallery.localhost - Admin Interface:
http://galleryinterface.localhost - Backend API:
http://gallerybackend.localhost
-
Modify your docker-compose.yaml:
- Uncomment the
portssections for each service (maybe except for database) - Comment out or remove the
labelssections - Remove the
networkssections
- Uncomment the
-
Update API configurations:
Edit
frontend/src/utils/api.tsandinterface/src/utils/api.tsto point to your backend URL:const API_BASE_URL = 'http://localhost:6767'; // or your server IP:Port
-
Build & Deploy:
docker-compose up -d --buildAccess URLs:
- Public Gallery:
http://localhost:6769 - Admin Interface:
http://localhost:6770 - Backend API:
http://localhost:6767
cd backend
npm install
npm run devcd frontend
npm install
npm run devcd interface
npm install
npm run devThe application uses MariaDB with automatic database initialization. The database schema is created automatically when the backend starts for the first time.
Be aware that MariaDB is only used for storing metadata of the pictures, you need to provide an accessible image URL for gallery to display the image.
POST /auth/login- User loginGET /auth/verify- Verify JWT token
GET /images- Get all imagesGET /images/:id- Get a single image with all its detailsPOST /images- Add new image to gallery (requires auth)PUT /images/:id- Update image details (requires auth)DELETE /images/:id- Delete image (requires auth)
The backend is configured to accept requests from all domains by default, if you want to restrict it to specific domains. Update the CORS configuration in backend/src/app.ts for your domains:
app.use(cors({
origin: ['https://your-gallery-domain.com', 'https://your-admin-domain.com'],
// ... other CORS options..
}));