Skip to content

faidhi066/arba-dbapp-fullstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Media API with Authentication

A simple social media API built with FastAPI, SQLite, and React, designed for users to create accounts, authenticate, post content, comment on posts, and perform CRUD operations on posts and comments. This project is containerized with Docker and deployed on ECS using a free-tier EC2 instance.

Tech Stack

Backend

  • Python with FastAPI
  • SQLite for local database storage

Frontend

  • TypeScript with React
  • shadcn for component styling

Deployment

  • Docker and Docker Compose for containerization
  • Amazon ECS, ECR, and EC2 for deployment on AWS

Features

User Model

  • Email: Unique user email address
  • Password: Securely hashed password
  • Name: Display name of the user

Post Model

  • User: The author of the post
  • Image: Optional image associated with the post
  • Caption: Text content of the post

Comment Model

  • User: The author of the comment
  • Post: The post being commented on
  • Text: Content of the comment

Core Functionality

  • User Authentication: Register, login, and secure access to user-specific actions
  • Create, Read, Update, Delete (CRUD):
    • Users can create posts with optional images and captions.
    • Users can comment on posts.
    • Users can edit and delete their own posts and comments.

Additional Features

  • Containerized Deployment: Deployed as Docker containers on Amazon ECS.
  • Simple Frontend: A basic interface to demonstrate API usage with React.

Getting Started

Prerequisites

  • Docker and Docker Compose
  • AWS Account with access to ECS and ECR
  • Basic knowledge of FastAPI, React, and TypeScript

Backend Setup

  1. Clone the repository:

    git clone https://github.com/faidhi066/arba-dbapp-fullstack.git
    cd arba-dbapp-fullstack
  2. Build and run the Docker containers:

    docker compose up --build
  3. API will be accessible at http://localhost:8000.

  4. Endpoints:

    • /register - Register a new user
    • /token - Authenticate user and retrieve token
    • /posts - CRUD operations for posts
    • /comments - CRUD operations for comments

Frontend Setup

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Run the frontend:

    npm start
  4. Frontend will be accessible at http://localhost:3000.

Deployment on AWS

  1. Push the Docker image to Amazon ECR:

    aws ecr create-repository --repository-name social-media-api
    docker tag <local-image-id> <aws-account-id>.dkr.ecr.<region>.amazonaws.com/social-media-api:latest
    docker push <aws-account-id>.dkr.ecr.<region>.amazonaws.com/social-media-api:latest
  2. Deploy on ECS using the docker-compose.yml configuration and set up the necessary EC2 instance.

API Documentation

Visit http://localhost:8000/docs for interactive API documentation generated by FastAPI's Swagger UI.

Testing the API

Use the following details to test the API:

  • User Registration: Register by providing email, password, and name.
  • Login: Retrieve a token by logging in with email and password.
  • Create a Post: Authenticate and send a POST request with caption and image (optional).
  • Comment on a Post: Authenticate and send a POST request with text on the specific post.

License

This project is licensed under the MIT License.


Note: This project is set up for demonstration purposes and should not be used in production without implementing secure practices and additional error handling.

About

Fullstack dbapp for Arba Travel

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published