Cinevo is a backend service for a movie ticket booking application, built with Go and PostgreSQL designed to handle movie management, ticket booking, user authentication, and transaction history.
| Method | Endpoint | Description |
|---|---|---|
| POST | /admin | Add a new movie |
| GET | /admin/sales-chart | Get Sales Chart |
| GET | /admin/ticket-sales | Get Ticket Sales |
| DELETE | /admin/{id} | Delete a movie |
| PATCH | /admin/{id} | Update a movie |
| GET | /transactions | Ticket Result |
| POST | /transactions | Booking Tickets |
| GET | /transactions/history | Transactions History |
| GET | /user | Get User Profile |
| PATCH | /user | Update User Profile |
| POST | /auth/forgot-password | Forgot Password |
| POST | /auth/login | Login a user |
| POST | /auth/register | Register a new user |
| POST | /auth/reset-password | Reset Password |
| GET | /movies | Get all movies |
| GET | /movies/now-showing | Get now showing movies |
| GET | /movies/upcoming | Get upcoming movies |
erDiagram
direction LR
movies ||--o{ movie_genres : "has"
movies ||--o{ movie_directors : "has"
movies ||--o{ movie_casts : "has"
movies ||--o{ transactions : "purchased"
movies {
int id PK
string title
string overview
int vote_average
string poster_path
string backdrop_path
date release_date
int runtime
int popularity
int admin_id FK
timestamp created_at
timestamp updated_at
}
genres {
int id PK
string name
timestamp created_at
timestamp updated_at
}
movie_genres }o--|| genres : "categorized"
movie_genres {
int movie_id PK "FK"
int genre_id PK "FK"
}
directors {
int id PK
string name
timestamp created_at
timestamp updated_at
}
movie_directors }o--|| directors : "directed by"
movie_directors {
int movie_id PK "FK"
int director_id PK "FK"
}
casts {
int id PK
string name
timestamp created_at
timestamp updated_at
}
movie_casts }o--|| casts : "acts by"
movie_casts {
int movie_id PK "FK"
int cast_id PK "FK"
timestamp created_at
timestamp updated_at
}
transactions ||--o{ transaction_details : "contains"
transaction_details {
int id PK
string seat
int transaction_id FK
timestamp created_at
timestamp updated_at
}
payment_method ||--o{ transactions : "used in"
payment_method {
int id PK
string name
timestamp created_at
timestamp updated_at
}
transactions {
int id PK
string customer_fullname
string customer_email
string customer_phone
decimal amount
string cinema
string location
time show_time
date show_date
int users_id FK
int movie_id FK
int payment_method_id FK
timestamp created_at
timestamp updated_at
}
users ||--o{ movies : "manages"
users ||--o{ transactions : "makes"
users ||--|| profiles : "has"
users {
int id PK
string email
string password
string roles "admin, user"
int profile_id FK
timestamp created_at
timestamp updated_at
}
profiles {
int id PK
string fullname
string phone
timestamp created_at
timestamp updated_at
}
Follow these steps to set up the Cinevo backend locally:
-
Clone the Repository:
git clone https://github.com/VsalCode/fgo24-be-tickitz.git cd fgo24-be-tickitz -
Install Dependencies:
go mod tidy
-
Set Up Environment Variables: Create a
.envfile in the project root and add the required environment variables (see Environment Variables). -
Run the Application:
go run main.go
To view and interact with the API documentation using Swagger:
-
Generate Swagger Documentation:
Generate the Swagger documentation:
swag init
-
Run the Application: Start the application if not already running:
go run main.go
-
Access Swagger UI: Open your browser and navigate to:
http://localhost:8080/docs/index.htmlThis assumes the application is running on the default port (8080). Adjust the port if your configuration differs.
Create a .env file in the project root with the following variables:
PGUSER=your_postgres_username
PGPASSWORD=your_postgres_password
PGHOST=your_postgres_host
PGPORT=your_postgres_port
PGDATABASE=your_postgres_database
APP_SECRET=your_app_secret_key
APP_PASSWORD=your_app_password
REDIS_ADDR=localhost:6379
REDIS_PASSWORD=your_redis_passwordEnsure these values are correctly configured for your PostgreSQL and Redis instances.
The project relies on the following Go packages:
- Gin Gonic - Web framework
- JWT v5 - JSON Web Token support
- PGX - PostgreSQL driver
- Godotenv - Environment variable management
- Go-Redis - Redis client
- Bcrypt - Password hashing
- Go-Swaggo - API documentation
- Go-Migrate - Database migrations
Install dependencies using:
go mod tidyPull requests are welcome! For major changes, please open an issue first to discuss your proposed changes.
This project is licensed under the MIT License