Backend API untuk aplikasi marketplace OLX Clone menggunakan ASP.NET Core 9.0.
- Framework: ASP.NET Core 9.0
- Database: PostgreSQL (Entity Framework Core)
- Authentication: JWT Bearer Token
- Object Storage: ImageKit
- Payment Gateway: Midtrans
- Email: SMTP (Gmail)
- Maps: Google Maps API
- Real-time: SignalR (Chat Hub)
- .NET 9.0 SDK
- PostgreSQL 12+
- Akun ImageKit (gratis)
- Akun Midtrans Sandbox (gratis)
- Gmail App Password
git clone https://github.com/Eka051/olx-be-api
cd olx-be-apicp .env.example .envEdit file .env dan isi semua credentials.
dotnet restoredotnet ef database updatedotnet runAPI akan berjalan di https://localhost:8080
- Swagger UI - Tersedia di
/swaggersaat aplikasi running
Setelah aplikasi berjalan, buka Swagger UI untuk melihat semua endpoints:
https://localhost:8080/swagger
- Auth: Register, Login, JWT Authentication
- Products: CRUD products dengan upload gambar
- Profile: Update user profile dan avatar
- Chat: Real-time chat menggunakan SignalR
- Payment: Integrasi Midtrans payment gateway
- Maps: Geocoding menggunakan Google Maps API
The application uses a passwordless authentication system (Email OTP) for both registration and login.
-
Request OTP
- Endpoint:
POST /api/auth/email/otp - Body:
{ "email": "user@example.com" } - Response: 201 Created. An OTP will be sent to the registered email address.
- Endpoint:
-
Verify OTP
- Endpoint:
POST /api/auth/email/verify - Body:
{ "email": "user@example.com", "otp": "123456" } - Response: Returns a JWT Token.
{ "success": true, "message": "OTP berhasil diverifikasi", "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } }
- Endpoint:
-
Authentication Header Include the token in the Authorization header for protected endpoints:
Authorization: Bearer <your_token>
Lihat file .env.example untuk template dan ENV_SETUP.md untuk panduan lengkap.
ConnectionStrings__DefaultConnection- PostgreSQL connection stringJwt__Key,Jwt__Issuer,Jwt__Audience- JWT configurationImageKit__PrivateKey,ImageKit__PublicKey,ImageKit__UrlEndpoint- Object storageSmtpSettings__*- Email configurationGoogleMaps__ApiKey- Maps APIMidtrans__*- Payment gateway
olx-be-api/
βββ Controllers/ # API Controllers
βββ Services/ # Business logic & external services
βββ Models/ # Database models
βββ DTO/ # Data Transfer Objects
βββ Helpers/ # Utility helpers
βββ Middleware/ # Custom middleware
βββ Hubs/ # SignalR hubs
βββ Data/ # DbContext dan seeding
βββ Migrations/ # EF Core migrations
βββ Program.cs # Application entry point
dotnet run --environment Development# Add new migration
dotnet ef migrations add MigrationName
# Update database
dotnet ef database update
# Rollback migration
dotnet ef database update PreviousMigrationNamedotnet run seeddocker build -t olx-be-api .
docker run -p 8080:8080 --env-file .env olx-be-apiUntuk pertanyaan atau issue, silakan hubungi saya melalui instagram/linkedin.