Skip to main content

Project Structure

Detailed breakdown of the ConsultFlow codebase.

Repository Layout

consultflow/
├── backend/ # Express.js API server
├── frontend/ # Next.js application
├── docs/ # Docusaurus documentation
├── .gitignore
└── README.md

Frontend Structure

frontend/
├── app/ # Next.js App Router
│ ├── layout.tsx # Root layout (fonts, metadata)
│ ├── page.tsx # Landing page (/)
│ ├── globals.css # Global styles + animations
│ │
│ ├── login/
│ │ └── page.tsx # Login page (/login)
│ │
│ ├── dashboard/
│ │ └── page.tsx # Dashboard (/dashboard)
│ │
│ ├── workflow/
│ │ ├── create/
│ │ │ └── page.tsx # Workflow builder (/workflow/create)
│ │ └── execute/
│ │ └── [id]/
│ │ └── page.tsx # Execution page (/workflow/execute/:id)
│ │
│ ├── mom/
│ │ └── page.tsx # MOM generator (/mom)
│ │
│ └── logs/
│ └── page.tsx # Execution logs (/logs)

├── components/
│ ├── Logo.tsx # Animated logo + LoadingLogo + Attribution
│ │
│ └── workflow/
│ ├── WorkflowCanvas.tsx # React Flow canvas wrapper
│ ├── ActionSidebar.tsx # Node palette + config panel
│ └── nodes/
│ ├── TriggerNode.tsx # Custom trigger node
│ └── ActionNode.tsx # Custom action node

├── lib/
│ └── api.ts # Axios API client

├── public/ # Static assets

├── next.config.js
├── tailwind.config.ts
├── tsconfig.json
└── package.json

Key Frontend Files

FilePurpose
app/layout.tsxRoot layout with fonts and global providers
app/globals.cssTailwind imports + custom animations
lib/api.tsCentralized API client for all endpoints
components/Logo.tsxReusable logo with animations
components/workflow/WorkflowCanvas.tsxReact Flow integration

Backend Structure

backend/
├── src/
│ ├── index.ts # Entry point, Express setup
│ │
│ ├── auth/
│ │ └── authService.ts # Azure AD OAuth logic
│ │
│ ├── config/
│ │ └── database.ts # MongoDB connection
│ │
│ ├── controllers/
│ │ ├── authController.ts # /auth route handlers
│ │ ├── workflowController.ts # /workflow handlers
│ │ ├── momController.ts # /mom handlers
│ │ └── logController.ts # /logs handlers
│ │
│ ├── middleware/
│ │ └── auth.ts # Authentication middleware
│ │
│ ├── models/
│ │ ├── User.ts # User schema
│ │ ├── Workflow.ts # Workflow schema
│ │ └── ExecutionLog.ts # Log schema
│ │
│ ├── routes/
│ │ ├── auth.ts # /auth routes
│ │ ├── workflow.ts # /workflow routes
│ │ ├── mom.ts # /mom routes
│ │ └── logs.ts # /logs routes
│ │
│ ├── services/
│ │ ├── ai/
│ │ │ └── momGenerator.ts # OpenAI MOM generation
│ │ ├── graph/
│ │ │ └── graphClient.ts # Microsoft Graph API
│ │ └── workflow/
│ │ └── workflowExecutor.ts # Workflow execution
│ │
│ └── types/
│ └── express-session.d.ts # TypeScript declarations

├── .env # Environment variables (not committed)
├── tsconfig.json
└── package.json

Key Backend Files

FilePurpose
src/index.tsExpress app setup, middleware, routes
src/auth/authService.tsMSAL client, token operations
src/services/graph/graphClient.tsMicrosoft Graph API wrapper
src/services/ai/momGenerator.tsOpenAI integration
src/services/workflow/workflowExecutor.tsAction execution engine

Documentation Structure

docs/
├── docs/
│ ├── intro.md # Introduction
│ ├── getting-started/
│ │ ├── installation.md
│ │ ├── configuration.md
│ │ ├── azure-setup.md
│ │ └── quick-start.md
│ ├── architecture/
│ │ ├── overview.md
│ │ ├── frontend.md
│ │ ├── backend.md
│ │ ├── database.md
│ │ └── authentication.md
│ ├── features/
│ │ ├── workflow-builder.md
│ │ ├── mom-generator.md
│ │ ├── microsoft-integration.md
│ │ └── execution-logs.md
│ ├── api/
│ │ ├── authentication.md
│ │ ├── workflows.md
│ │ ├── mom.md
│ │ └── logs.md
│ └── development/
│ ├── tech-stack.md
│ ├── project-structure.md
│ └── contributing.md
├── src/
│ ├── pages/
│ │ └── index.tsx # Docusaurus home page
│ └── css/
│ └── custom.css # Custom styling
├── static/
│ └── img/
│ └── logo.svg
├── docusaurus.config.ts
├── sidebars.ts
└── package.json

Code Organization Patterns

Controller Pattern

// controllers/workflowController.ts
export const createWorkflow = async (req: Request, res: Response) => {
try {
// Validation
// Business logic
// Response
} catch (error) {
// Error handling
}
}

Service Pattern

// services/graph/graphClient.ts
export class GraphClient {
private client: AxiosInstance

constructor(accessToken: string) {
// Initialize
}

async sendEmail(...) {
// Implementation
}
}

Route Pattern

// routes/workflow.ts
const router = Router()
router.use(requireAuth)
router.post('/', createWorkflow)
router.get('/', getWorkflows)
export default router

Naming Conventions

TypeConventionExample
FilescamelCaseauthService.ts
ComponentsPascalCaseWorkflowCanvas.tsx
FunctionscamelCasehandleSubmit
ConstantsUPPER_SNAKEAPI_BASE_URL
Types/InterfacesPascalCaseIWorkflow
CSS Classeskebab-caseworkflow-canvas