Spring Boot backend for the Trix social platform. This service covers authentication, users, posts, comments, follows, notifications, search indexing, media upload/storage, Trix short videos, settings, SMTP email flows, OAuth2 login, Valkey caching, Kafka/WebSocket realtime events, and async media processing.
- Java 21
- Maven
- MySQL or H2 for local development
- Valkey if you want cache-backed rate limiting and cached reads
- Kafka if you want realtime notifications and async media jobs
- SMTP credentials if you want password reset and verification emails to send for real
mvn spring-boot:runBy default the app starts on http://localhost:8080 and uses H2 for local development.
- API base:
http://localhost:8080/api/v1 - Swagger UI:
http://localhost:8080/swagger-ui.html - OpenAPI JSON:
http://localhost:8080/v3/api-docs - Health:
http://localhost:8080/api/v1/health - Actuator health:
http://localhost:8080/actuator/health - Actuator info:
http://localhost:8080/actuator/info
Use environment variables to switch between local and production services.
| Variable | Purpose | Default |
|---|---|---|
TRIX_DB_URL |
Database JDBC URL | H2 in-memory |
TRIX_DB_USERNAME |
Database username | sa |
TRIX_DB_PASSWORD |
Database password | empty |
TRIX_JWT_SECRET |
JWT signing secret | change-this-secret-before-production-use |
TRIX_FRONTEND_BASE_URL |
Frontend redirect base | http://localhost:5173 |
TRIX_OAUTH2_REDIRECT_URI |
OAuth2 success redirect | http://localhost:5173/auth/oauth2/success |
TRIX_SMTP_HOST |
SMTP host | localhost |
TRIX_SMTP_PORT |
SMTP port | 1025 |
TRIX_SMTP_USERNAME |
SMTP username | empty |
TRIX_SMTP_PASSWORD |
SMTP password | empty |
TRIX_MAIL_FROM |
Sender address | no-reply@trix.local |
TRIX_GOOGLE_CLIENT_ID |
Google OAuth client id | empty |
TRIX_GOOGLE_CLIENT_SECRET |
Google OAuth client secret | empty |
TRIX_GITHUB_CLIENT_ID |
GitHub OAuth client id | empty |
TRIX_GITHUB_CLIENT_SECRET |
GitHub OAuth client secret | empty |
TRIX_VALKEY_HOST |
Valkey host | localhost |
TRIX_VALKEY_PORT |
Valkey port | 6379 |
TRIX_KAFKA_BOOTSTRAP_SERVERS |
Kafka bootstrap servers | localhost:9092 |
TRIX_STORAGE_PROVIDER |
local or object-storage |
local |
TRIX_MEDIA_STORAGE_DIR |
Local media directory | temp folder |
TRIX_OBJECT_STORAGE_ENDPOINT |
S3-compatible endpoint | empty |
TRIX_OBJECT_STORAGE_BUCKET |
Object storage bucket | empty |
TRIX_OBJECT_STORAGE_ACCESS_KEY_ID |
Object storage access key | empty |
TRIX_OBJECT_STORAGE_SECRET_ACCESS_KEY |
Object storage secret key | empty |
TRIX_OBJECT_STORAGE_PUBLIC_BASE_URL |
Public media URL base | empty |
local: files are written to the local media directory and served from/media/**object-storage: files are stored in an S3-compatible object store
POST /api/v1/auth/registerPOST /api/v1/auth/loginPOST /api/v1/auth/refreshPOST /api/v1/auth/logoutPOST /api/v1/auth/password-reset/requestPOST /api/v1/auth/password-reset/confirmPOST /api/v1/auth/email-verification/requestPOST /api/v1/auth/email-verification/confirmPOST /api/v1/auth/mfa/setupPOST /api/v1/auth/mfa/verifyPOST /api/v1/auth/mfa/disableGET /api/v1/auth/oauth2/providersPOST /api/v1/auth/oauth2/link
GET /api/v1/users/mePUT /api/v1/users/meGET /api/v1/users/{username}GET /api/v1/users/search?q=...POST /api/v1/users/{userId}/followDELETE /api/v1/users/{userId}/followGET /api/v1/users/{userId}/followersGET /api/v1/users/{userId}/following
POST /api/v1/postsGET /api/v1/posts/{postId}PUT /api/v1/posts/{postId}DELETE /api/v1/posts/{postId}GET /api/v1/posts/feedGET /api/v1/posts/user/{userId}POST /api/v1/posts/{postId}/likeDELETE /api/v1/posts/{postId}/likePOST /api/v1/posts/{postId}/repostPOST /api/v1/posts/{postId}/bookmarkGET /api/v1/posts/{postId}/commentsPOST /api/v1/posts/{postId}/comments
POST /api/v1/media/uploadPOST /api/v1/media/upload/externalDELETE /api/v1/media/{mediaId}GET /api/v1/media/{mediaId}/thumbnail
GET /api/v1/search?q=...GET /api/v1/settingsPUT /api/v1/settingsGET /api/v1/settings/sessionsDELETE /api/v1/settings/sessions/{sessionId}GET /api/v1/notificationsPUT /api/v1/notifications/{id}/readPUT /api/v1/notifications/read-allDELETE /api/v1/notifications/{id}POST /api/v1/trixGET /api/v1/trix/{trixId}GET /api/v1/trix/feedGET /api/v1/trix/featuredPOST /api/v1/trix/{trixId}/likePOST /api/v1/trix/{trixId}/view
The most important response types are:
AuthResponse: access token, refresh token, expiry, and current userUserProfileResponse: user profile summaryPostResponse: post details and countersCommentResponse: comment details and countersMediaResponse: uploaded media metadata and processing statusSearchResponse: matched users and postsNotificationResponse: notification list itemsTrixResponse: short video details and counters
Swagger UI is enabled at http://localhost:8080/swagger-ui.html. Use the Authorize button and paste your JWT access token as a bearer token:
Bearer <your-access-token>
The generated OpenAPI spec is available at http://localhost:8080/v3/api-docs.
Import the collection from:
docs/postman/trix-backend.postman_collection.jsondocs/postman/trix-backend.postman_environment.json
After login, save the accessToken and refreshToken variables in the Postman environment.
- H2 is enabled for local development.
- Real email delivery requires SMTP configuration.
- OAuth2 login requires Google or GitHub client credentials.
- Kafka must be running for realtime notifications and async media jobs.
- Valkey is used for cache-backed rate limiting and cached hot reads.