Skip to content

Small Twitter clone to learn testing and Jetpack Compose

License

Notifications You must be signed in to change notification settings

sentrionic/Mirage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mirage

Mirage is a small Twitter clone used to learn testing and Jetpack Compose.

Screenshots

Features

  • Tweet CRUD
  • Following System
  • Search by username or hashtags
  • Retweet-Lite
  • Business Logic fully tested
  • E2E Testing (backend)

Stack Backend

  • Gin for the REST server
  • Gorm as the database ORM
  • PostgreSQL
  • Redis
  • S3 for storing files
  • Github Actions to test on every commit

Stack Mobile

The app structure is based on codingwithmitch's compose course.


Installation

Server

(If you are familiar with make, take a look at the Makefile to quickly setup the following steps)

  1. Install Docker and get the Postgresql and Redis containers
  2. Create a DB
  3. Install Go 1.19 and get all the dependencies (go mod tidy)
  4. Rename .env.example to .env and fill in the values
  • Required

      PORT=8080
      DATABASE_URL="postgresql://<username>:<password>@localhost:5432/db_name"
      REDIS_URL=redis://localhost:6379
      CORS_ORIGIN=http://localhost:3000
      SECRET=SUPERSECRET
      HANDLER_TIMEOUT=5
      MAX_BODY_BYTES=4194304 # 4MB in Bytes = 4 * 1024 * 1024
      COOKIE_NAME=mqk
      DOMAIN=DOMAIN
    
  • Optional: Not needed to run the app, but you won't be able to upload files.

      AWS_ACCESS_KEY=ACCESS_KEY
      AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY
      AWS_STORAGE_BUCKET_NAME=STORAGE_BUCKET_NAME
      AWS_S3_REGION=S3_REGION
    
  1. Run go run github.com/sentrionic/mirage to run the server

App

  1. Clone the repository and open the app directory in Android Studio.
  2. Set the BASE_URL in Constants.kt. If the backend runs locally, make sure to also add android:usesCleartextTraffic="true" to the Android Manifest.
  3. Run the app.

Testing

Server

  1. To test the business logic in the handler and service directories run go test -v -cover ./service/... ./handler/... (or make test).

  2. To test the routes, run go test -run '^\QTestMain_E2E\E$\' (or make e2e)

App

To run the use case tests simply right click the app directory in the test directory and select Run tests in 'xyz.mirage...'


Known Issues

App

  • Backstack keeps growing.
    • Haven't found a good solution to that problem yet.
  • Screen transition animations flicker white when using dark mode.

About

Small Twitter clone to learn testing and Jetpack Compose

Topics

Resources

License

Stars

Watchers

Forks

Languages