8000 GitHub - andrehsvictor/Camly-API
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andrehsvictor/Camly-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Έ Camly API πŸ“Έ

Camly Logo

License: MIT Java Version Spring Boot Docker Build Status Code Coverage

A modern photo storage and sharing service API

✨ Features β€’ πŸ› οΈ Tech Stack β€’ πŸ”Œ API Endpoints β€’ βš™οΈ Installation β€’ πŸš€ Running β€’ πŸ§ͺ Testing β€’ πŸ“¦ Deployment β€’ πŸ“ License


Secure Β· Scalable Β· Modern

πŸ“‹ Overview

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

✨ Features

  • 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

πŸ› οΈ Tech Stack

  • 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

πŸ”Œ API Endpoints

πŸ” Authentication

  • POST /api/v1/account - Create a new user account
  • POST /api/v1/account/send-action-email - Send verification or password reset email
  • POST /api/v1/account/verify - Verify email address
  • POST /api/v1/account/reset-password - Reset password
  • POST /api/v1/token - Get access and refresh tokens
  • POST /api/v1/token/refresh - Refresh access token
  • POST /api/v1/token/revoke - Revoke token

πŸ‘₯ Users

  • GET /api/v1/users - Get all users with optional filtering
  • GET /api/v1/users/{id} - Get user by ID
  • PUT /api/v1/users/{id}/followers - Follow/unfollow a user

πŸ“± Posts

  • POST /api/v1/posts - Create a new post
  • GET /api/v1/posts - Get all posts with filtering
  • GET /api/v1/posts/{id} - Get post by ID
  • PUT /api/v1/posts/{id} - Update a post
  • DELETE /api/v1/posts/{id} - Delete a post
  • PUT /api/v1/posts/{id}/likes - Like/unlike a post
  • GET /api/v1/posts/stats - Get post statistics for the current user
  • GET /api/v1/users/{userId}/posts - Get all posts for a specific user

πŸ–ΌοΈ Images

  • POST /api/v1/images - Upload an image

βš™οΈ Installation

Prerequisites

  • Java 21 JDK
  • Maven
  • Docker and Docker Compose (for local development)
  • PostgreSQL
  • Redis
  • MinIO

Setup

  1. Clone the repository:

    git clone https://github.com/andrehsvictor/Camly-API.git
    cd Camly-API
  2. Generate RSA keys for JWT authentication:

    chmod +x rsa-keys.sh
    ./rsa-keys.sh
  3. Configure 9294 the application:

    Create an application.properties or application.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

πŸš€ Running

Using Maven

./mvnw spring-boot:run

Using Docker

Build the Docker image:

docker build -t camly-api .

Run the container:

docker run -p 8080:8080 camly-api

πŸ§ͺ Testing

Running Unit Tests

./mvnw test

Running Integration Tests

./mvnw failsafe:integration-test

Integration tests use Testcontainers to spin up PostgreSQL, Redis, MinIO, and MailHog containers automatically for testing.

πŸ“¦ Deployment

The project includes a GitHub Actions workflow for CI/CD in .github/workflows/main.yml. It:

  1. Builds the application
  2. Runs unit and integration tests
  3. Creates and pushes a Docker image to Docker Hub

To deploy:

  1. Set up GitHub repository secrets:

    • DOCKER_USERNAME: Your Docker Hub username
    • DOCKER_PASSWORD: Your Docker Hub password
  2. Push to the main branch or create a tag to trigger the workflow.

πŸ“š API Documentation

When the application is running, OpenAPI documentation is available at:

πŸ“ License

This project is licensed under the MIT License.

πŸ‘¨β€πŸ’» Author

0