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.
- Python with FastAPI
- SQLite for local database storage
- TypeScript with React
- shadcn for component styling
- Docker and Docker Compose for containerization
- Amazon ECS, ECR, and EC2 for deployment on AWS
- Email: Unique user email address
- Password: Securely hashed password
- Name: Display name of the user
- User: The author of the post
- Image: Optional image associated with the post
- Caption: Text content of the post
- User: The author of the comment
- Post: The post being commented on
- Text: Content of the comment
- 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.
- Containerized Deployment: Deployed as Docker containers on Amazon ECS.
- Simple Frontend: A basic interface to demonstrate API usage with React.
- Docker and Docker Compose
- AWS Account with access to ECS and ECR
- Basic knowledge of FastAPI, React, and TypeScript
-
Clone the repository:
git clone https://github.com/faidhi066/arba-dbapp-fullstack.git cd arba-dbapp-fullstack -
Build and run the Docker containers:
docker compose up --build
-
API will be accessible at
http://localhost:8000. -
Endpoints:
/register- Register a new user/token- Authenticate user and retrieve token/posts- CRUD operations for posts/comments- CRUD operations for comments
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Run the frontend:
npm start
-
Frontend will be accessible at
http://localhost:3000.
-
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
-
Deploy on ECS using the
docker-compose.ymlconfiguration and set up the necessary EC2 instance.
Visit http://localhost:8000/docs for interactive API documentation generated by FastAPI's Swagger UI.
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
captionandimage(optional). - Comment on a Post: Authenticate and send a POST request with
texton the specific post.
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.