Skip to content

Hexacoder5678/ImageGram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📸 ImageGram Backend API

A robust, scalable social media backend service designed to handle user authentication, post management, and secure media uploads.

🚀 Key Features

  • Secure Media Storage: Direct integration with AWS S3 buckets for highly available and scalable image hosting.
  • RESTful Architecture: Clean, modular API design following industry best practices for routing and controller logic.
  • Database Management: Efficient data modeling and querying using MongoDB and Mongoose.
  • Authentication: Secure user session management and password hashing (Custom auth flow, no third-party OAuth providers).
  • Caching & Performance: Integration with Redis to optimize data retrieval and API response times.

🛠️ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB
  • Cloud Storage: AWS S3
  • Caching: Redis

📡 Core API Endpoints

Here is a high-level overview of the primary RESTful routes:

Method Endpoint Description Auth Required
POST /api/users/register Register a new user No
POST /api/users/login Authenticate and start session No
POST /api/posts/upload Upload image to AWS S3 & create post Yes
GET /api/posts/feed Retrieve paginated user feed Yes
DELETE /api/posts/:id Remove post and associated S3 media Yes

🏗️ System Architecture & Database

Here is a high-level overview of how the backend services interact and the structure of our data.

Architecture

graph TD
    Client[📱 Client / Frontend] -->|API Request| API[🚀 Express API Server]
    
    subgraph "Backend Services (Node.js)"
    API -->|1. Auth Middleware| Auth[🔒 JWT Auth]
    Auth -->|2. Route Handler| API
    end
    
    subgraph "Data & Storage Layers"
    API <-->|Cache Lookup/Write| Redis[(🧠 Redis Cache)]
    API <-->|CRUD Operations| DB[(🍃 MongoDB Database)]
    API <-->|Image Upload/Delete| S3[(☁️ AWS S3 Bucket)]
    end

    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef server fill:#bbf,stroke:#333,stroke-width:2px;
    classDef storage fill:#dfd,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    class Client client;
    class API server;
    class Auth,Redis,DB,S3 storage;
Loading

Database Schema (ERD)

erDiagram
    USER ||--o{ POST : creates
    
    USER {
        ObjectId _id PK
        string username
        string email
        string passwordHash
        date createdAt
    }
    
    POST {
        ObjectId _id PK
        ObjectId userId FK
        string s3ImageUrl
        string s3Key
        string caption
        date createdAt
    }
Loading

⚙️ Environment Variables

To run this project, you will need to add the following environment variables to your .env file:

PORT MONGO_URI AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_BUCKET_NAME REDIS_URL

💻 Local Setup

  1. Clone the repository:
    git clone https://github.com/Hexacoder5678/ImageGram.git

About

A scalable Social Media Backend API featuring AWS S3 image uploads, Redis caching, and JWT authentication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors