This is a RESTful API built with Rust, designed to handle posts, likes, and user authentication features including logins and sign-ups. The service uses PostgreSQL for efficient data storage and retrieval, supporting scalability as user interactions increase.
- Posts Management: Create, update, and delete posts.
- Likes: Users can like posts.
- User Authentication: Support for user logins and sign-ups.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You will need PostgreSQL installed on your machine. Follow the instructions for your operating system:
sudo apt update
sudo apt install postgresql postgresql-contrib
brew install postgresql
brew services start postgresql
Download and install PostgreSQL from the official website.
Ensure you have Rust installed:
rustup update
rustup install stable
-
Start PostgreSQL service:
sudo service postgresql start # Ubuntu brew services start postgresql # macOS
-
Create a new PostgreSQL database:
sudo -u postgres psql # Ubuntu psql postgres # macOS or Windows (if added to PATH)
In the PostgreSQL shell:
CREATE DATABASE your_database_name; \q
Making Tables
CREATE TABLE users ( id SERIAL PRIMARY KEY, username TEXT NOT NULL UNIQUE, email TEXT NOT NULL UNIQUE, password_hash TEXT NOT NULL, created_at TIMESTAMP NOT NULL ); CREATE TABLE tweets ( id SERIAL PRIMARY KEY, content TEXT NOT NULL, likes INTEGER, created_at TIMESTAMP NOT NULL );
-
Set up your
.env
file with the PostgreSQL connection string:DATABASE_URL=postgres://username:password@localhost/your_database_name JWT_SECRET=your_jwt_secret
Clone the repository and navigate to the project directory:
git clone https://github.com/your_username/your_project.git
cd your_project
Run the application:
cargo run
This will start the server on http://localhost:8080
.
This project is licensed under the MIT License - see the LICENSE file for details.