GithubHelp home page GithubHelp logo

cyberkatze / shwitter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m3hransh/shwitter

1.0 0.0 0.0 2.46 MB

A Persian clone of twitter

License: MIT License

TypeScript 95.03% JavaScript 0.57% HTML 1.49% CSS 1.19% Dockerfile 0.90% Shell 0.82%

shwitter's Introduction

Shwitter

Shwitter is a persian clone of twitter. This example shows how to implement a simple micro-service architecture using modern stack. Following is the C4 of the software architecture:

C4 Diagram of Shwitter

Tech Stack

Backend

Frontend

  • React: front-end JavaScript library for building user interfaces based on UI components
  • React-Hook-Form: Performant, flexible and extensible forms with easy-to-use validation
  • Yup: Yup is a JavaScript schema builder for value parsing and validation
  • TailwindCss: A utility-first CSS framework

Contents

Schema

In this project, we take the schema-first approach, meaning first we create the schema by which back-end and front-end will communicate. Here is the first draft of the schema:

type Query {
  allUsers(data: FilterInputType): AllUsers!
  feed(filter: String, orderBy: [ShweetOrderByInput!], skip: Int, take: Int): Feed!
  me: User
  user: User
}

type Mutation {
  deleteShweet(id: Int!): Shweet!
  editProfile(data: ProfileInput!): Profile
  like(shweetId: Int!): LikedShweet
  login(email: String!, password: String!): AuthPayload!
  shweet(content: String!): Shweet!
  signup(email: String!, name: String!, password: String!, username: String!): AuthPayload!
  updateShweet(content: String!, id: Int!): Shweet!
}

type Feed {
  count: Int!
  shweets: [Shweet!]!
}

type LikedShweet {
  likedAt: DateTime!
  shweet: Shweet
  shweetId: Int!
  user: User
  userId: Int!
}

type Profile {
  avatar: String
  bio: String
  createdAt: DateTime
  location: String
  name: String
  userId: Int!
  website: String
}

type Shweet {
  author: User
  content: String!
  createdAt: DateTime!
  id: Int!
  likedShweet: [LikedShweet!]!
  updatedAt: DateTime!
}

type User {
  email: String!
  id: Int!
  profile: Profile
  shweets: [Shweet!]!
  username: String!
}

enum Sort {
  asc
  desc
}

Getting started

For development environment

Prerequisite

Install latest version of Docker and Docker Compose (Windows users should use WSL!)

  1. First, make sure you provide .env file both for back and front
cp front/env.example front/.env
cp back/env.example back/.env
  1. To fire up the back-end use following command:
docker compose up db back
# use docker-compose if you haven't installed docker compose plugin for docker

This will setup Postgresql database on port 5432 and a GraphQL server on port 4000. Open up this http://localhost:4000 to make sure everything is OK.

  1. Although there is containerized version of the front as well, for smoother experience, I suggest to run it locally. In that case, run the following commands:
# install lts version of yarn in your machine first
yarn install
yarn start

Now you should see the browser staring at http://localhost:3000

optional: To support image upload you need create a cloudinary account and set up unauthorized preset for your cloud path

Project showcase

landing page preview

Todo

  • Create CI/CD for the front and back
  • Signup and Login page
  • Adding GraphQL Schema
  • User can change their profile info
  • Connection to cloudinary
  • Users can shwit
  • Unit test for Front
  • Unit test for back

References

  • HOWTOGRAPHQL: A complete resource for setting up the GraphQL server and client

License

This project is licensed under the terms of the MIT license.

shwitter's People

Contributors

m3hransh avatar cyberkatze avatar

Stargazers

Arman karimi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.