Core code generation and schema engine for Typegen
Fast β’ Secure β’ Extensible
The Typegen Server is the core backend service of the Typegen platform. It is responsible for database schema introspection, validation, and deterministic code generation across supported languages and styles. The API exposes generation capabilities used by the CLI and Dashboard while enforcing strict option schemas, security controls, and runtime validation.
Important: The Typegen Server can be run as a standalone service, but the recommended best practice is to manage its lifecycle, configuration, and runtime using (
typegenctl) and the UI Dashboard, which provide a safer and more convenient control plane for the entire Typegen ecosystem.
| How to use | Description |
|---|---|
| Typegenctl | Typegenctl GitHub |
| Typegen UI | Typegen-Dashboard GitHub |
- Current Support Database Connection: MySQL/Mariadb, MSSQL, and PostgreSQL.
- Code Generation:
- Typescript: DTOs and Zod schemas.
- Java: Records and DTOs.
- Mappers: Java XML and Annotation-based mappers.
- Security: Rate limiting, and CORS support.
- Health Monitoring: Integrated health check endpoints.
Pre-built Docker images are available for this project and can be pulled from the registry:
docker pull ghcr.io/khanalsaroj/typegen-server:latestβββ cmd/
β βββ api/ # Application entry point
βββ data/ # SQLite database files
βββ internal/
β βββ config/ # Configuration loading (Viper)
β βββ domain/ # Domain models and interfaces
β βββ infrastructure/ # DB connectors (MySQL, Postgres)
β βββ middleware/ # Gin middlewares (CORS, Logger, Rate Limit)
β βββ modules/ # Business logic by module
β β βββ connection/ # Connection management
β β βββ gentype/ # Type generation logic
β β βββ health/ # Health check logic
β β βββ mapper/ # Mapper generation logic
β βββ pkg/ # Shared utilities (Crypto, Logger, Response)
β βββ query/ # SQL queries
β βββ server/ # HTTP server setup and routing
βββ .env.dev # Development environment variables
βββ Dockerfile # Multi-stage Docker build
βββ go.mod # Go module definition
Response:
{
"status": "ok",
"version": "v1.2.3",
"uptime": 172800,
"database": {
"connected": true,
"latency": 12
}
}HTTP Status: 200 OK
Request Body Example:
{
"dbType": "postgres",
"host": "localhost",
"port": 5432,
"username": "admin",
"password": "securepassword",
"schemaName": "public",
"databaseName": "mydb"
}Response Example:
{
"connectionId": 123,
"message": "Connection established successfully",
"success": true,
"pingMs": 15,
"tablesFound": 3,
"sizeMb": 42.7,
"tables": [
{
"name": "users",
"columnCount": 12
},
{
"name": "orders",
"columnCount": 8
}
]
}HTTP Status: 200 OK
Request Body Example:
{
"dbType": "postgres",
"host": "localhost",
"port": 5432,
"username": "admin",
"password": "securepassword",
"schemaName": "public",
"databaseName": "mydb"
}Response Success Example:
{
"success": true,
"message": "User fetched successfully",
"connection": {
"dbType": "postgres",
"host": "localhost",
"port": 5432,
"username": "admin",
"password": "securepassword",
"schemaName": "public",
"databaseName": "mydb"
}
}HTTP Status: 200 OK
Response Error Example:
{
"success": false,
"message": "Failed to create connection",
"error": "user not found"
}
HTTP Status: 500 InternalServerError
Response Example:
[
{
"connectionId": 101,
"name": "main-db",
"dbType": "postgres",
"host": "localhost",
"port": 5432,
"databaseName": "mydb",
"schemaName": "public",
"username": "admin"
},
{
"connectionId": 102,
"name": "analytics-db",
"dbType": "mysql",
"host": "db.example.com",
"port": 3306,
"databaseName": "analytics",
"schemaName": "default",
"username": "root"
}
]
HTTP Status: 200 OK
Request Body Example:
Note: The
optionsobject is dynamic. Its available fields differ depending on the chosenlanguageandstyle, as each combination exposes its own configuration options. For the full list of supported options, see the documentation here.
{
"connectionId": 102,
"options": {
"getter": true,
"setter": true,
"noArgsConstructor": true,
"allArgsConstructor": true,
"builder": true,
"data": true,
"swaggerAnnotations": true,
"serializable": true,
"jacksonAnnotations": true,
"extraSpacing": true
},
"prefix": "Foo",
"suffix": "Response",
"style": "DTO",
"language": "java",
"tableNames": [
"users",
"orders"
]
}Response Example:
"generated message"HTTP Status: 200 OK
Request Body Example:
{
"connectionId": 123,
"options": {
"allCrud": true
},
"prefix": "Db",
"suffix": "Type",
"style": "struct",
"language": "go",
"tableNames": [
"users",
"orders"
]
}Response Example:
"generated message"HTTP Status: 200 OK
- Issues: Report bugs and feature requests
- Developer: Khanal Saroj (waytosarojkhanal@gmail.com)
