Giter Site home page Giter Site logo

hexagontk / twitter_clone Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 0.0 242 KB

Mini Twitter Clone application developed using HexagonKt, Pebble and MongoDB

Home Page: https://hexagontk.com

Dockerfile 1.15% Kotlin 79.10% CSS 0.41% HTML 19.34%
kotlin jvm example hacktoberfest

twitter_clone's Introduction

Twitter Clone

This is a Mini Twitter Clone application developed using Hexagon, based on this Spark tutorial. It makes use of Pebble to render pages, and MongoDB for database functions.

Requirements

  • Java + Kotlin
  • Gradle
  • MongoDB

How to run

Navigate to the project's root folder and run the following commands in order

  1. ./gradlew build
  2. ./gradlew installDist
  3. ./gradlew run

Open http://localhost:2010/ in your browser.

General Functionality

  • Sign up and register
  • Public and personal timelines
  • Follow/unfollow users
  • User pages

Architecture

The main class, which starts the server, is Application.kt.

The models package contains the models to be stored in the database.

The routes package contains the routing logic files.

Utils.kt contains some general-purpose helper methods used in other parts of the application.

Inside resources, the templates folder contains the Pebble templates used to render webpages. base.html contains some common components such as the navbar, and other templates extend from this file.

The service.yaml file defines several local settings such as the server port number, MongoDB URL, etc. This can be modified, if required, based on local settings.

Endpoints

Note: for all POST endpoints, data is expected in the form of form parameters (x-www-form-url-encoded).

ANY /ping

A simple ping endpoint to check if the server is up and running.

GET /

The homepage. If no user is logged in, this redirects to /public, else a feed of messages of users followed by the currently logged in user is shown.

GET /public

Shows the list of messages from all users.

GET /register

Renders the registration page.

POST /register

Registers the user.

Expected data:

  • username
  • email
  • password

If registration is successful, redirects to /login.

GET /login

Renders the login page.

POST /login

Logs the user in. Logged in users are tracked using Session variables.

Expected data:

  • email
  • password

If login is successful, redirects to the home page (/).

GET /logout

Logs the user out and redirects to the home page (/).

GET /user/follow/:username

Adds the currently logged in user as a follower of the user specified in the path.

GET /user/unfollow/:username

Removes the currently logged in user from the list of followers of the user specified in the path.

GET /user/:username

Renders the user page, containing the feed of messages sent by the user.

POST /message

Creates a message and associates it with the currently logged in user.

Expected data:

  • message

If successful, redirects to the public timeline (/public).

twitter_clone's People

Contributors

bikramjeetsingh avatar jaguililla avatar

Stargazers

Assim Zemouchi avatar Arichido avatar  avatar Ashish Sadhwani avatar Ekin Yücel avatar Imanol Pérez Iriarte avatar Enes Açıkoğlu avatar

Watchers

 avatar James Cloos avatar Kostas Georgiou avatar  avatar

twitter_clone's Issues

Port Twitter clone to Hexagon v3

Update dependency to Hexagon v3.0.x. Tests should complete properly.

Some modules (like 'dependency injection') may have been moved to the hexagon_extra repository.

In the process of porting the example, maybe the documentation is not complete enough and you have to rely on the code. Don't miss this opportunity to improve the documentation 😉 .

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.