Overview
The XGP Photo API is a production-ready REST API built with ASP.NET Core 9.0 that provides a complete backend solution for managing photography projects and their associated image galleries. The API features secure JWT-based authentication, role-based access control, and a clean architecture designed for scalability.This API uses PostgreSQL as its database and automatically handles migrations and seeding during startup.
Key Features
Secure Authentication
- JWT Bearer Token Authentication - Industry-standard token-based authentication
- Client Credential Validation - Multiple client applications supported with unique credentials
- Role-Based Authorization - Admin and user roles with granular permissions
- ASP.NET Core Identity Integration - Built on Microsoft’s proven identity framework
Project Management
- CRUD Operations - Full create, read, update capabilities for photography projects
- Project Details - Support for multiple images per project with metadata
- Active Status Tracking - Soft delete functionality with IsActive flags
- Relationship Management - One-to-many relationships between projects and details
Developer Experience
- Swagger/OpenAPI Documentation - Interactive API documentation in development mode
- Clean Architecture - Separation of concerns with Domain, Application, Infrastructure, and API layers
- Entity Framework Core - Code-first database approach with migration support
- Automatic Database Seeding - Default admin user created on first run
Architecture
The API follows Clean Architecture principles with clear separation of concerns:Technology Stack
Framework
ASP.NET Core 9.0
Database
PostgreSQL with EF Core 9.0
Authentication
JWT Bearer + ASP.NET Identity
API Documentation
Swagger/OpenAPI 3.0
Data Models
The API manages two primary entities:Project Entity
Represents a photography project with banner information and metadata.Program.cs
ProjectDetail Entity
Represents individual images within a project.Program.cs
API Endpoints
Authentication Endpoints
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/login | Authenticate and receive JWT token | No |
Project Endpoints
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/projects | Get all active projects | No |
| GET | /api/projects/{id} | Get project by ID | No |
| POST | /api/projects | Create new project | Admin only |
| PUT | /api/projects/{id} | Update existing project | Admin only |
Security Features
JWT Token Configuration
The API uses industry-standard JWT tokens with configurable settings:appsettings.json
Client Authentication
Multiple client applications can be configured with unique credentials:appsettings.json
Role-Based Access Control
The API implements role claims in JWT tokens for fine-grained authorization:Program.cs
Both standard .NET role claims and JWT role claims are included for maximum compatibility with different client types.
Database Management
Automatic Migrations
The API automatically applies Entity Framework migrations on startup:Program.cs
Default Admin User
A default administrator account is created during first run:- Email:
[email protected] - Password:
XgpPhoto!2025$Secure - Role: Admin
CORS Configuration
The API is configured to allow requests from any origin in development:Program.cs
For production deployments, configure specific allowed origins for security.
Next Steps
Quickstart
Get the API running in minutes
Authentication
Learn how to authenticate and use JWT tokens
API Reference
Explore all available endpoints
Deployment
Deploy to production environments