A full-stack TypeScript framework combining Next.js frontend with Fastify backend, featuring type-safe API communication and modern development tools.
This repository follows a monorepo structure with clear separation between frontend and backend applications:
frourio-framework/
βββ frontend-web/ # Next.js frontend application
βββ backend-api/ # Fastify backend API
βββ scripts/ # Deployment and utility scripts
βββ Docker/ # Docker configuration files
βββ docker-compose.yml # Local development database
- Framework: Fastify - High-performance Node.js web framework
- Language: TypeScript with strict type checking
- Database: PostgreSQL with Prisma ORM
- API Generation: Frourio for type-safe API development
- Authentication: JWT with admin/user role separation
- Testing: Vitest with Prisma Fabbrica for test data generation
- Build Tool: ESBuild for fast compilation
- Framework: Next.js 15 with React 19
- Language: TypeScript with strict type checking
- Styling: Tailwind CSS with Flowbite components
- State Management: Jotai for atomic state management
- Data Fetching: SWR with type-safe API client
- Forms: React Hook Form with Zod validation
- Storage: Supabase integration for file uploads
- Testing: Vitest for unit testing
- Type Safety: Aspida for end-to-end type safety between frontend and backend
- Code Generation: Automatic API client and path generation
- Database: PostgreSQL with Docker for local development
- Deployment: Support for Railway, AWS Amplify, and ECS
- Aspida: Generates type-safe API clients from backend route definitions
- Shared Types: Common types and constants shared between frontend and backend
- Automatic Generation: API clients and route paths generated automatically
- Dual Role System: Separate authentication for admin and user roles
- JWT Tokens: Secure token-based authentication
- Middleware: Route protection with role-based access control
- Prisma ORM: Type-safe database operations with automatic migrations
- Code Generation: Database models and factory functions auto-generated
- Seeding: Separate seed files for development and production environments
- Hot Reload: Both frontend and backend support hot reloading
- Parallel Development: Run both applications simultaneously with
npm run dev
- Type Checking: Continuous type checking across the entire stack
- Linting: Consistent code style with ESLint and Prettier
backend-api/
βββ api/ # API route definitions (Frourio)
βββ app/ # Application utilities and helpers
βββ config/ # Configuration files (CORS, JWT, etc.)
βββ domain/ # Domain models and business logic
βββ middleware/ # Authentication and request middleware
βββ prisma/ # Database schema, migrations, and seeds
βββ service/ # Application services and Fastify setup
βββ tests/ # Test files and setup
frontend-web/
βββ src/
β βββ components/ # Reusable UI components
β βββ features/ # Feature-specific code (auth, UI hooks)
β βββ layouts/ # Page layout components
β βββ pages/ # Next.js pages and API routes
β βββ styles/ # Global styles and Tailwind config
β βββ utils/ # Utility functions and API clients
β βββ views/ # Page view components
βββ public/ # Static assets
- frourio-framework-prisma-generators
- prisma generator that keeps your DX and speed π
# At root dir
cd frourio-framework
Setup .env
# With makefile
make env-setup-local
Run the app
# Let's run DB containers to begin with
docker-compose up -d
# Run npm install for all the directories
make install
# Run dev server for both frontend & backend
npm run dev
β
# move directory to frontend
cd frontend-web
β‘
# initialize supabase cofiguration
npx supabase init
β’
# Let's staet Supabase
npx supabase start
After a moment, local keys and configurations will be generated.
β£
Create fields for "NEXT_PUBLIC_SUPABASE_URL" and "NEXT_PUBLIC_SUPABASE_ANON_KEY" in your .env.local file, and set their values to the "API URL" and "anon key", respectively.
β€
Access the Studio URL for initial setup.
1)Navigate to the Storage section and create a new bucket.
2)Go to the Policies section under Storage and create your storage policies (make sure to pay attention to the bucket name, folder name, and allowed file extensions, as they are case-sensitive).
β₯
Finally, call the API to perform actual uploads and other operations.
- AWS CLI
- [AWS SSM Plugin](https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/session-manager-working-with-install-plugin. html)
$ cd frourio-framework
$ sh . /scripts/ecs_exec_stg -t ((task-id)) # Example) . /scripts/ecs_exec_stg -t 941f8694308b4adea44cb07ff9e50c30
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- cd ../
- npm install --prefix frontend-web
- npm install --prefix backend-api
build:
commands:
- cd frontend-web
- npm run build
artifacts:
baseDirectory: .next
files:
- "**/*"
cache:
paths:
- .next/cache/**/*
- .npm/**/*
appRoot: frontend-web