β¨ Features β’ π οΈ Tech Stack β’ π API Endpoints β’ βοΈ Installation β’ π Running β’ π§ͺ Testing β’ π¦ Deployment β’ π License
Secure Β· Scalable Β· Modern
Camly API is a robust Spring Boot application providing backend services for photo storage and sharing. It allows users to create accounts, upload photos, create and manage posts, like content, and follow other users. The application follows RESTful principles and includes comprehensive security features with JWT authentication.
π Secure | JWT-based authentication and authorization |
β‘ Fast | Redis caching for high performance |
π Scalable | Docker containerization for easy deployment |
π Testable | Comprehensive test suite with high coverage |
-
User Management
- User registration and authentication
- JWT-based authentication with access and refresh tokens
- Email verification
- Password reset functionality
- User search and filtering
- Follow/unfollow functionality
-
Post Management
- Create, read, update, and delete posts
- Add captions to posts
- Filter posts by caption text or username
- Like/unlike posts
- Engagement rate calculation
-
Image Handling
- Upload and store images securely
- Comprehensive validation of image files
- Integration with MinIO object storage
-
Social Features
- Follow other users
- Like posts
- View user profiles and posts
- Track post engagement statistics
-
Caching
- Redis-based caching for improved performance
-
Documentation
- OpenAPI/Swagger documentation for all endpoints
- Java 21 - Core programming language
- Spring Boot - Application framework
- Spring Security - Authentication and authorization
- Spring Data JPA - Data persistence
- PostgreSQL - Primary database
- Redis - Caching solution
- MinIO - Object storage for images
- JWT - Token-based authentication
- OpenAPI 3 - API documentation
- JUnit 5 & RestAssured - Testing framework
- Testcontainers - Integration testing with containers
- Docker - Containerization
- GitHub Actions - CI/CD pipeline
POST /api/v1/account
- Create a new user accountPOST /api/v1/account/send-action-email
- Send verification or password reset emailPOST /api/v1/account/verify
- Verify email addressPOST /api/v1/account/reset-password
- Reset passwordPOST /api/v1/token
- Get access and refresh tokensPOST /api/v1/token/refresh
- Refresh access tokenPOST /api/v1/token/revoke
- Revoke token
GET /api/v1/users
- Get all users with optional filteringGET /api/v1/users/{id}
- Get user by IDPUT /api/v1/users/{id}/followers
- Follow/unfollow a user
POST /api/v1/posts
- Create a new postGET /api/v1/posts
- Get all posts with filteringGET /api/v1/posts/{id}
- Get post by IDPUT /api/v1/posts/{id}
- Update a postDELETE /api/v1/posts/{id}
- Delete a postPUT /api/v1/posts/{id}/likes
- Like/unlike a postGET /api/v1/posts/stats
- Get post statistics for the current userGET /api/v1/users/{userId}/posts
- Get all posts for a specific user
POST /api/v1/images
- Upload an image
- Java 21 JDK
- Maven
- Docker and Docker Compose (for local development)
- PostgreSQL
- Redis
- MinIO
-
Clone the repository:
git clone https://github.com/andrehsvictor/Camly-API.git cd Camly-API
-
Generate RSA keys for JWT authentication:
chmod +x rsa-keys.sh ./rsa-keys.sh
-
Configure 9294 the application:
Create an
application.properties
orapplication.yml
file with the following configuration (modify as needed):# Database spring.datasource.url=jdbc:postgresql://localhost:5432/camly spring.datasource.username=camly spring.datasource.password=yourpassword # Redis spring.data.redis.host=localhost spring.data.redis.port=6379 # MinIO camly.minio.endpoint=http://localhost:9000 camly.minio.admin.username=minio camly.minio.admin.password=minio123 camly.minio.bucket.name=camly # Email (for verification and password reset) spring.mail.host=localhost spring.mail.port=1025
./mvnw spring-boot:run
Build the Docker image:
docker build -t camly-api .
Run the container:
docker run -p 8080:8080 camly-api
./mvnw test
./mvnw failsafe:integration-test
Integration tests use Testcontainers to spin up PostgreSQL, Redis, MinIO, and MailHog containers automatically for testing.
The project includes a GitHub Actions workflow for CI/CD in .github/workflows/main.yml
. It:
- Builds the application
- Runs unit and integration tests
- Creates and pushes a Docker image to Docker Hub
To deploy:
-
Set up GitHub repository secrets:
DOCKER_USERNAME
: Your Docker Hub usernameDOCKER_PASSWORD
: Your Docker Hub password
-
Push to the main branch or create a tag to trigger the workflow.
When the application is running, OpenAPI documentation is available at:
This project is licensed under the MIT License.
- AndrΓ© Victor - andrehsvictor@gmail.com
- GitHub: https://github.com/andrehsvictor