XClone is a Go-based application built with a modular architecture, integrating Chi as a router, PostgreSQL as the database, and JWT for secure authentication and authorization. The codebase implements a Hexagonal Architecture, separating concerns into domain, service, and adapter layers. Database migrations are handled using the PostgreSQL package, and the server is configured to run on port 8080.
-
Modular Architecture: Built with a modular structure, incorporating Chi as a router, PostgreSQL for the database, and JWT for secure authentication and authorization.
-
Hexagonal Architecture: The codebase follows a Hexagonal Architecture, distinguishing domain, service, and adapter layers to maintain separation of concerns.
-
Database Migrations: PostgreSQL package is used for seamless handling of database migrations.
-
GraphQL API: Powered by gqlgen, the application provides a GraphQL playground at the root endpoint and a query endpoint at "/query".
-
Testing: The application includes comprehensive test coverage to ensure reliability and robustness.
-
Token Service: Innovative token service is employed for user authentication.
/xclone
|-- auth.go
|-- auth_test.go
|-- config
|-- domain
|-- go.sum
|-- Makefile
|-- README.md
|-- tweet.go
|-- context.go
|-- faker
|-- gqlgen.yml
|-- init-scripts
|-- mocks
|-- refresh_token.go
|-- user.go
|-- cmd
|-- docker-compose.yml
|-- go.mod
|-- graph
|-- jwt
|-- postgres
|-- server_go
|-- uuid
To test the app, follow these steps:
- Install mockery:
brew install mockery
- Run tests:
go test ./domain -v
- Make migrations:
make migrations
For GraphQL functionality, refer to the How To GraphQL guide.
mutation {
register(
input: {
email: "[email protected]"
username: "xxxxxxxx"
password: "xxxxxxxx"
confirmPassword: "xxxxxxxx"
}
) {
accessToken
user {
id
email
username
createdAt
}
}
}
mutation {
login(input: {
email: "[email protected]"
password: "xxxxxxxx"
}) {
accessToken
user {
id
email
}
}
}
Feel free to contribute, report issues, or provide feedback. Let's collaborate to enhance and optimize the XClone application!