Skip to content

ktsu2i/utopia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utopia - Positive & Supportive Social Media

This project started from CIS 3296: Software Design at TUJ.

Project Members:

Purpose

In today's society, many people use social media daily, often leading to negative interactions such as insults directed at users or celebrities. These hostile exchanges can result in depression, mental health issues, or even suicide. To combat this, I created Utopia, a social media application designed to foster mutual support and positivity.

Tech stack

  • Frontend:

    • TypeScript
    • React
    • Next.js
    • Tailwind CSS
    • Zustand
    • shadcn/ui
  • Backend:

    • Golang
    • Echo
    • Air
    • Gorm
    • Gorilla WebSocket
    • MySQL
    • Groq for LLM API (model: Llama 3 Groq 70B)
  • Infrastructure

    • Docker
    • Docker Compose

Attribution

Features

LP

This landing page is for those who are new to Utopia. You can see brief explanation about Utopia.

lp1 lp2

Sign up & Login

sign-up login

Post, Reply, and Reactions

You can post and reply like other social media. You can react to every post and reply.

post reply

Utopia detects inappropriate content and does NOT allow users to post it.

Utopia detects not only f-words but also offensive, sexual, and any inappropriate content. We ensure to provide the most peaceful place on the Internet.

bad-post bad-reply

Search for Posts and Users

You can search posts and users.

search-post search-user

Notifications

When users do some actions such as follow, react, reply, or send a message, it sends a notification and displays a notification badge until you check the notifications.

notifications notification-badge

Direct Messages

You can send messages directly to other users realtime.

dm chat

Of course, Utopia detects inappropriate content in DMs.

bad-dm

Profile

You can see your own profile and update your information here.

profile edit-profile

Also, you can visit other user's profile. You can follow or unfollow users here.

user-profile

Again, you are not allowed to add any inappropriate content in Utopia.

bad-bio

Settings

Settings feature is coming soon...

settings

Responsive Design

Utopia provides you responsive design for multiple devices such as tablets and smartphones.

Tablets

tablet

Smartphones

phone

For developers

File structures

Overview

.
├── frontend
├── backend
├── .env.example
├── .gitignore
├── compose.yaml
└── README.md

Frontend

Under /app directory, all the directories are routes. However, it ignores directories with parenthesis. For example, if you visit /frontend/app/login/page.tsx, the route would be https://example.com/login or http://localhost:3000/login in development.

Next.js (app router) uses a file-system based router where folders are used to define routes. Each folder represents a route segment that maps to a URL segment. To create a nested route, you can nest folders inside each other.

Source: https://nextjs.org/docs/app/building-your-application/routing/defining-routes

└── frontend
     ├── app
     │   ├── (auth)
     │   │   ├── login
     │   │   │   └── page.tsx
     │   │   └── sign-up
     │   │       └── page.tsx
     │   ├── (authenticated)
     │   │   ├── home
     │   │   │   ├── page.tsx
     │   │   │   └── posts
     │   │   │       └── [postId]
     │   │   │           ├── [replyId]
     │   │   │           │   └── page.tsx
     │   │   │           └── page.tsx
     │   │   ├── layout.tsx
     │   │   ├── messages
     │   │   │   ├── [userId]
     │   │   │   │   └── page.tsx
     │   │   │   ├── _components
     │   │   │   └── page.tsx
     │   │   ├── notifications
     │   │   │   ├── _components
     │   │   │   └── page.tsx
     │   │   ├── profile
     │   │   │   ├── [userId]
     │   │   │   │   └── page.tsx
     │   │   │   ├── edit
     │   │   │   │   └── page.tsx
     │   │   │   └── page.tsx
     │   │   ├── search
     │   │   │   ├── _components
     │   │   │   └── page.tsx
     │   │   └── settings
     │   │       └── page.tsx
     │   ├── fonts
     │   ├── globals.css
     │   ├── layout.tsx
     │   ├── loading.tsx
     │   └── page.tsx
     ├── components
     │   ├── MobileHeader.tsx
     │   ├── MobileNavbar.tsx
     │   ├── MobilePostButton.tsx
     │   ├── PostItem.tsx
     │   ├── ReplyItem.tsx
     │   ├── lp
     │   ├── right-sidebar
     │   ├── sidebar
     │   └── ui                     // shadcn/ui
     ├── components.json
     ├── hooks
     │   ├── useAuth.ts
     │   └── useEmojis.ts
     ├── lib
     │   ├── types.ts
     │   ├── utils.ts
     │   └── validations.ts
     ├── public
     │   └── images
     ├── stores                     // zustand
     │   ├── authStore.ts
     │   └── notificationStore.ts
     └── Dockerfile

Backend

route.go is the place where all APIs are defined.

└── backend
     ├── db
     │   └── db.go
     ├── handlers              // All the handler functions 
     │   ├── auth.go
     │   ├── emoji.go
     │   ├── follower.go
     │   ├── groq.go
     │   ├── message.go
     │   ├── notification.go
     │   ├── post.go
     │   ├── reaction.go
     │   ├── reply.go
     │   ├── user.go
     │   └── websocket.go
     ├── migrations             // All SQL migration files
     ├── models                 // All the defined structures
     │   ├── auth.go
     │   ├── emoji.go
     │   ├── follower.go
     │   ├── groq.go
     │   ├── message.go
     │   ├── notification.go
     │   ├── post.go
     │   ├── reaction.go
     │   ├── reply.go
     │   └── user.go
     ├── .air.toml
     ├── .gitignore
     ├── dbconfig.yml
     ├── Dockerfile
     ├── go.mod
     ├── go.sum
     ├── main.go
     └── route.go

Prerequisites

To run this program, you need to have Docker and Docker Compose installed on your machine.

  • Docker
  • Docker Compose

If you already have them on your machine, you can skip the section below.

For Mac

Go to https://docs.docker.com/desktop/install/mac-install/ and install Docker Desktop.

For Windows

Go to https://docs.docker.com/desktop/install/windows-install/ and install Docker Desktop.

If you face an error saying "WSL 2 installation is incomplete", then you have to install the kernel update and restart your machine.

For Linux

If you are on Ubuntu, go to https://docs.docker.com/desktop/install/linux/ubuntu/ and install Docker Desktop.

There are some instructions for other Linux distributions, so please follow the instructions on the website to install Docker and Docker Compose.

Check if you successfully installed

Run the following command to check the versions of Docker and Docker Compose.

docker --version
docker compose version

How to run

1. Clone this repository

git clone https://github.com/ktsu2i/utopia.git
cd utopia

2. Setup

Copy .env.example and add secret keys.

cp .env.example .env

Warning

If you are NOT using Apple Silicon, comment out this line.

  db:
    image: mysql:8.0
    # platform: linux/amd64

3. Build & run the app

Depending on version of Docker Compose, you might want to use docker-compose instead of docker compose.

docker compose up --build

Once you build the app, you can run the app without --build option unless you don't change Dockerfile or compose.yaml.

docker compose up

Once the container is up, you can go to http://localhost:3000 and either sign up or login with your account.

Optional: How to go inside the container

You may want to run some commands for MySQL CLI. Run this following command to go inside the MySQL container.

docker exec -it utopia_db mysql -u root -p

After you type the password, you will get to the inside the container and run any commands you want. However, if you need to run some queries for utopia_dev database, run this command inside the container.

use utopia_dev;

Then, you will be able to use utopia_dev database and run any queries you want.

mysql query

3. Stop the containers

docker compose stop

If you want to start over, run these commands. But keep in mind that all the data in database will be reset.

docker compose down -v
docker compose build --no-cache
docker compose up

SQL migration

This project is using sql-migrate, which is a SQL schema migration tool for Golang.

Create a new migration file

Go to /backend directory and run the following command to create a migration file under /backend/migrations.

cd backend
sql-migrate new [name]

When you run docker compose up, it automatically migrates the files. Thus, you are just required to add migration files if necessary.

About

Positive and supportive social media for web

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages