Mirage is a small Twitter clone used to learn testing and Jetpack Compose.
- Tweet CRUD
- Following System
- Search by username or hashtags
- Retweet-Lite
- Business Logic fully tested
- E2E Testing (backend)
- Gin for the REST server
- Gorm as the database ORM
- PostgreSQL
- Redis
- S3 for storing files
- Github Actions to test on every commit
- Jetpack Compose to create the views
- Retrofit for HTTP Requests
- Android Room as the cache
- Hilt for depencency injection
The app structure is based on codingwithmitch's compose course.
(If you are familiar with make
, take a look at the Makefile
to quickly setup the following steps)
- Install Docker and get the Postgresql and Redis containers
- Create a DB
- Install Go 1.19 and get all the dependencies (
go mod tidy
) - 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
- Run
go run github.com/sentrionic/mirage
to run the server
- Clone the repository and open the
app
directory in Android Studio. - Set the
BASE_URL
inConstants.kt
. If the backend runs locally, make sure to also addandroid:usesCleartextTraffic="true"
to the Android Manifest. - Run the app.
-
To test the business logic in the handler and service directories run
go test -v -cover ./service/... ./handler/...
(ormake test
). -
To test the routes, run
go test -run '^\QTestMain_E2E\E$\'
(ormake e2e
)
To run the use case tests simply right click the app
directory in the test
directory and select Run tests in 'xyz.mirage...'
- Backstack keeps growing.
- Haven't found a good solution to that problem yet.
- Screen transition animations flicker white when using dark mode.