Alapa Directory Structure
When you generate a new Alapa project using the command npx create-alapa-app [ProjectName]
, youβll get a well-organized and modular directory structure designed to make development intuitive, scalable, and maintainable. Below is a detailed breakdown of the key directories and files in an Alapa starter project:
/
βββ dev/
β βββ index.js
β βββ refresh.js
βββ docs/
β βββ generate.ts
β βββ schemas/
βββ migration-runner/
β βββ data-source.ts
β βββ generate.ts
β βββ run.ts
βββ public/
β βββ src/
β βββ styles/
β βββ application.scss
βββ src/
β βββ index.ts
β βββ api/
β β βββ routes.ts
β β βββ index.ts
β βββ apps/
β β βββ routes.ts
β β βββ index.ts
β βββ config/
β βββ models/
β β βββ user.ts
β βββ shared/
β βββ index.ts
βββ static/
β βββ images/
β βββ js/
β β βββ app.js
β βββ css/
β β βββ app.css
β β βββ styles.css
βββ test/
βββ node_modules/
βββ views/
β βββ components/
β βββ error/
β βββ index.html
βββ .env
βββ Dockerfile
βββ alapa-env.d.ts
βββ eslint.config.mjs
βββ package.json
βββ package-lock.json
βββ postcss.config.js
βββ readme.md
βββ tailwind.config.js
βββ tsconfig.json
Root Directory (/
)β
The root directory contains configuration files, environment settings, and project metadata. Hereβs what youβll find:
.env
: Stores environment variables such as API keys, database credentials, and other sensitive or environment-specific settings.Dockerfile
: Defines the Docker image configuration for containerizing the application.alapa-env.d.ts
: A TypeScript declaration file for environment variables or custom types.eslint.config.mjs
: Configuration file for ESLint, ensuring code quality and consistency.package.json
andpackage-lock.json
: Define project dependencies, scripts, and metadata.postcss.config.js
: Configuration for PostCSS, used for processing CSS with plugins like Tailwind CSS.readme.md
: Documentation for the project, including setup instructions, usage, and other relevant information.tailwind.config.js
: Configuration file for Tailwind CSS, a utility-first CSS framework.tsconfig.json
: TypeScript configuration file, defining compiler options and project settings.
Development Tools (/dev
)β
This directory contains scripts and tools for development purposes:
index.js
: The entry point for development-specific scripts or tools.refresh.js
: A script to refresh browsers on changes.
Documentation (/docs
)β
Alapaβs documentation is generated and maintained here:
generate.ts
: A script for generating API documentation.schemas/
: Contains schema definitions (e.g.,user.yaml
) for reference in your API documentation.
Database Migrations (/migration-runner
)β
This directory handles database migrations, ensuring smooth schema updates:
data-source.ts
: Configuration for database migrations, likely using an ORM like TypeORM.generate.ts
: A script to generate new database migrations.run.ts
: A script to execute database migrations.
Public (/public
)β
This directory contains assets that are compiled using Webpack to generate static files:
src/
: Contains source files for public assets (e.g., JavaScript, CSS, TypeScript).styles/
: Stores stylesheets, including preprocessed SCSS files.application.scss
: The main SCSS file for global styles.
Source Code (/src
)β
The core of the Alapa application, organized into modules for better maintainability:
index.ts
: The main entry point of the application. This file initializes and starts the Alapa application, tying together all the modules and configurations.api/
: Contains API-related logic.routes.ts
: Defines API routes.index.ts
: Entry point for the API module.
apps/
: Houses application-specific logic or sub-applications.routes.ts
: Defines routes for the application.index.ts
: Entry point for the application module.
config/
: Houses configuration files for various aspects of the application. Files like api.ts, database.ts, auth.ts, etc., provide modular configuration for APIs, databases, authentication, and more.models/
: Contains data models, such asuser.ts
, defining the structure and behavior of database entities.shared/
: Stores shared utilities, helpers, or common functionality used across the application.
Static Files (/static
)β
Static files like images, JavaScript, and CSS are organized here:
images/
: Stores static image assets.js/
: Contains JavaScript files, such asapp.js
, for client-side functionality.css/
: Houses CSS files, includingapp.css
andstyles.css
, for styling the application.
Testing (/test
)β
This directory is reserved for test files (e.g., unit tests, integration tests) to ensure the application functions as expected. (Note: This directory is currently empty but is typically used for testing purposes.)
Views (/views
)β
The views
directory is used for server-side rendering or templating:
components/
: Stores reusable UI components.error/
: Contains error pages (e.g., 404, 500).index.html
: The main HTML file for the applicationβs front end.
Other Files and Directoriesβ
node_modules/
: Contains installed dependencies managed by npm or Yarn.
Why This Structure?β
Alapaβs directory structure is designed with the following principles in mind:
- Modularity: Separating concerns (e.g.,
api/
,apps/
,models/
) makes the codebase easier to maintain and scale. - Flexibility: The
config/
directory allows developers to add custom configurations as needed, ensuring the structure adapts to the projectβs requirements. - Static Assets: The
static/
andpublic/
directories ensure that static files like CSS, JavaScript, and images are organized and accessible. - Documentation and Tooling: The
docs/
anddev/
directories highlight a focus on documentation and development tooling. - TypeScript Support: The presence of TypeScript files (
*.ts
) andtsconfig.json
ensures strong typing and modern JavaScript practices.
Getting Startedβ
To explore Alapaβs directory structure in action, generate a new project using the command:
npx create-alapa-app [ProjectName]
This will create a starter project with the above structure, ready for you to customize and build upon. Each directory is designed to be self-explanatory, making it easy for developers to understand and contribute to the project.
For more details on how to use Alapa, check out the Installation Guide.
This structure reflects Alapaβs commitment to simplicity, flexibility, and developer productivity. Whether youβre building a small project or a large-scale application, Alapaβs organized approach ensures a smooth development experience.